Commit 3abbeca1 by jscat

nyx weapp: 页面更新

1. 添加订单结算页
parent b1816497
<!-- /page/post/edit/edit 添加分类的标签,以及自定义标签 --> <!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
<!-- /page/post/edit/edit 添加分类的标签,以及自定义标签 --> <!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
<wxs module="tutil" src="./../../../utils/date.wxs"></wxs> <wxs module="tutil" src="./../../../utils/date.wxs"></wxs>
<view class="page" style="height:100%;width:100%"> <view class="page" style="height:100%;width:100%">
......
// pages/my/my-orders/my-orders.js // pages/my/my-orders/my-orders.js
...@@ -19,9 +19,10 @@ Page({ ...@@ -19,9 +19,10 @@ Page({
orderItems: [], // 子活动列表 orderItems: [], // 子活动列表
/* 数量加减 */ /* 数量加减 */
num: 0, totalPrice: 0,
curIndex: 0, curIndex: 0,
selected_all : 0,
totalCount: 0,
}, },
...@@ -48,24 +49,30 @@ Page({ ...@@ -48,24 +49,30 @@ Page({
var orderInfo = _this.__data__.orderInfo || {} var orderInfo = _this.__data__.orderInfo || {}
var orderItems = [] var orderItems = []
var curIndex = 0 var curIndex = 0
var totalPrice = 0.0
var totalCount = 1
if (Object.keys(orderInfo).length==0 && options.title != "") if (Object.keys(orderInfo).length==0 && options.title != "")
{ {
orderInfo['activity_id'] = options.activity_id; orderInfo['activity_id'] = options.activity_id;
orderInfo['product_image'] = options.product_image orderInfo['product_image'] = options.product_image
orderInfo['member_name'] = options.member_name orderInfo['member_name'] = options.member_name
orderInfo['title'] = options.title orderInfo['title'] = options.title
curIndex = options.curIndex curIndex = options.curIndex
orderItems = JSON.parse(options.products_string) orderItems = JSON.parse(options.products_string)
orderInfo['item_height'] = 100 + 120*(orderItems.length) + 30 * (orderItems.length+1) orderInfo['item_height'] = 100 + 120*(orderItems.length) + 30 * (orderItems.length+1)
for(var i=0; i<orderItems.length; i++) for(var i=0; i<orderItems.length; i++)
{ {
if(curIndex == i) if(curIndex == i)
( {
orderItems[i]['quantity'] = 1 orderItems[i]['quantity'] = 1
) orderItems[i]['selected'] = 1
totalPrice = orderItems[i]['unit_price']
totalPrice = totalPrice.toFixed(2)
}
else else
{ {
orderItems[i]['quantity'] = 0 orderItems[i]['quantity'] = 0
orderItems[i]['selected'] = 0
} }
} }
...@@ -73,7 +80,8 @@ Page({ ...@@ -73,7 +80,8 @@ Page({
_this.setData({ orderInfo }) _this.setData({ orderInfo })
_this.setData({ orderItems }) _this.setData({ orderItems })
_this.setData({ curIndex }) _this.setData({ curIndex })
_this.setData({ totalPrice })
_this.setData({ totalCount })
}, },
...@@ -125,86 +133,88 @@ Page({ ...@@ -125,86 +133,88 @@ Page({
}, },
// 用户自定义函数 // 用户自定义函数
/* /* 加数
*/
/* 点击barcode */
onClickBarcode: function(e){ */
var _this = this;
//指明具体是list的哪一个item
var indexId = e.currentTarget.dataset.id
var qrcode_url = _this.__data__.orders[indexId].order_qrcode
var qrcode = _this.__data__.orders[indexId].order_id
    this.setData({
      showModalBarcode : true,
qrcode : qrcode,
qrcode_url : qrcode_url
    })
},
  // 弹出层里面的弹窗
  ok: function () {
    this.setData({
      showModalPoints: false,
showModalBarcode: false
    })
  },
/**
* tab切换
*/
tab: function(e) {
var _this = this;
var pageIndex = _this.__data__.pageIndex
//js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var id = e.currentTarget.id;
var dataId = e.currentTarget.dataset.id
_this.getOrders(0, 1, 4, dataId);
_this.setData({
selectTab: dataId,
})
},
/**
* 用户自定义函数
*
*/
/* 加数 */
addCount: function (e) { addCount: function (e) {
console.log("刚刚您点击了加1"); var _this = this;
var orderItems = this.data.orderItems; console.log("===刚刚您点击了加1");
var orderItems = _this.data.orderItems;
var totalPrice = 0;
var totalCount = 0;
var selected_all = _this.data.selected_all;
//js的e.currentTarget.id 对应wxml的 id="tab0" //js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0" //js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var index = e.currentTarget.dataset.index var index = e.currentTarget.dataset.index
// 总数量+1 // 总数量+1
if (orderItems[index]['quantity'] < 1000) { if (orderItems[index]['quantity'] < 1000) {
orderItems[index]['quantity']++; orderItems[index]['quantity'] = orderItems[index]['quantity']+1;
orderItems[index]['selected'] = 1;
} }
// 如果所有 商品的selected==1, 则selected_all=1
// 因为是addCount, 所以假定selected_all为1
selected_all = orderItems[index]['selected']
for(var i=0; i< orderItems.length; i++)
{
selected_all = orderItems[i]['selected'] == 1?selected_all && 1 : 0
totalPrice = orderItems[i]['selected'] == 1 ? _this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unit_price'])) : totalPrice
totalCount = orderItems[i]['selected'] == 1?totalCount+orderItems[i]['quantity']:totalCount
}
totalPrice = totalPrice.toFixed(2)
// 将数值与状态写回 // 将数值与状态写回
this.setData({ _this.setData({
orderItems orderItems,
totalPrice,
totalCount,
selected_all,
}); });
}, },
/* 减数 */ /* 减数 */
delCount: function (e) { delCount: function (e) {
var _this = this;
console.log("刚刚您点击了减1"); console.log("刚刚您点击了减1");
var orderItems = this.data.orderItems; var orderItems = _this.data.orderItems;
var totalPrice = 0;
var totalCount = 0;
var selected_all = _this.data.selected_all;
//js的e.currentTarget.id 对应wxml的 id="tab0" //js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0" //js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var index = e.currentTarget.dataset.index var index = e.currentTarget.dataset.index
// 商品总数量-1 // 商品总数量-1
if (orderItems[index]['quantity'] > 0) { if (orderItems[index]['quantity'] > 1) {
orderItems[index]['quantity']--; orderItems[index]['quantity'] = orderItems[index]['quantity'] - 1;
orderItems[index]['selected'] = 1;
}
// 如果减到0
// 当前商品的selected = 0
// 所有商品的selected_all = 0
else if(orderItems[index]['quantity'] == 1)
{
orderItems[index]['quantity'] = 0;
orderItems[index]['selected'] = 0;
selected_all = 0;
} }
//计算totalPrice和totalCount
for(var i=0; i< orderItems.length; i++)
{
totalPrice = orderItems[i]['selected'] == 1 ? _this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unit_price'])) : totalPrice
totalCount = orderItems[i]['selected'] == 1?totalCount+orderItems[i]['quantity']:totalCount
}
totalPrice = totalPrice.toFixed(2)
// 将数值与状态写回 // 将数值与状态写回
this.setData({ _this.setData({
orderItems orderItems,
totalPrice,
selected_all,
totalCount,
}); });
}, },
...@@ -218,5 +228,126 @@ Page({ ...@@ -218,5 +228,126 @@ Page({
}); });
}, },
//加法
add : function (arg1, arg2) {
var r1, r2, m;
try {
r1 = arg1.toString().split(".")[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.toString().split(".")[1].length
} catch (e) {
r2 = 0
}
m = Math.pow(10, Math.max(r1, r2))
return (arg1 * m + arg2 * m) / m
},
//减法
sub : function (arg1, arg2) {
var _this = this;
return _this.add(arg1, -arg2);
},
//乘法
mul : function (arg1, arg2) {
var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
try {
m += s1.split(".")[1].length
} catch (e) { }
try {
m += s2.split(".")[1].length
} catch (e) { }
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
},
//除法
div : function (arg1, arg2) {
var t1 = 0, t2 = 0, r1, r2;
try {
t1 = arg1.toString().split(".")[1].length
} catch (e) { }
try {
t2 = arg2.toString().split(".")[1].length
} catch (e) { }
r1 = Number(arg1.toString().replace(".", ""))
r2 = Number(arg2.toString().replace(".", ""))
return (r1 / r2) * pow(10, t2 - t1);
},
// 单个商品 选择按钮
// 改变多选框状态 orderItems[i]['selected']: true || false
// 同步更新selected_all
// 同步改变totalPrice
radioTap: function(e){
var _this = this
//js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var dataId = e.currentTarget.dataset.id
var orderItems = _this.data.orderItems
var selected_all = _this.data.selected_all
var totalPrice = 0;
var totalCount = 0;
// 如果quantity==0, 则selected=0, selected_all=0
orderItems[dataId].selected = orderItems[dataId].selected==1 ? 0 :
(orderItems[dataId]['quantity']>0 ? 1 : 0)
//确定selected_all的值
selected_all = orderItems[dataId].selected
for(var i=0; i<orderItems.length; i++)
{
selected_all = orderItems[i]['selected'] == 1 ? selected_all && 1 : 0
totalPrice = orderItems[i].selected == 0 ? totalPrice :
_this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unit_price']))
totalCount = orderItems[i].selected == 0 ? totalCount : totalCount + orderItems[i]['quantity']
}
totalPrice = totalPrice.toFixed(2)
_this.setData({
orderItems,
selected_all,
totalCount,
totalPrice,
})
},
// 全选按钮
// 改变多选框状态 orderItems[i]['selected']: true || false
// 同步改变totalPrice
radioChangeAll: function (e){
var _this = this
var orderItems = _this.data.orderItems
var selected_all = _this.data.selected_all
var totalPrice = 0;
var totalCount = 0;
// 改变状态
selected_all = selected_all == 1 ? 0 : 1
// 改变后计算
for(var i=0; i< orderItems.length; i++)
{
orderItems[i]['selected'] = selected_all == 1 ? (orderItems[i]['quantity']>0 ? 1 : 0) : 0
totalPrice = selected_all == 0 ? 0 :
_this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unit_price']))
totalCount = orderItems[i].selected == 0 ? totalCount : totalCount + orderItems[i]['quantity']
}
totalPrice = totalPrice.toFixed(2)
_this.setData({
orderItems,
selected_all,
totalCount,
totalPrice,
})
},
}) })
\ No newline at end of file
<view class="page"> <view class="page">
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<checkbox-group class="check-group" bindchange="radioChange"> <checkbox-group class="check-group" bindchange="radioChange">
<view class="note-row align"> <view class="note-row align">
<checkbox class="wx-checkbox-input wx-checkbox-input-checked"> <!-- <checkbox class="wx-checkbox-input wx-checkbox-input-checked">
</checkbox> </checkbox> -->
<view class="note-info"> <view class="note-info">
<view class="note-member" style="font-weight: bold"> <view class="note-member" style="font-weight: bold">
<view class="member-left">{{orderInfo.member_name}}</view> <view class="member-left">{{orderInfo.member_name}}</view>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<block wx:for="{{orderItems}}" wx:for-item="sub_item" wx:key="{{index}}"> <block wx:for="{{orderItems}}" wx:for-item="sub_item" wx:key="{{index}}">
<view class="note-row align"> <view class="note-row align">
<checkbox class="wx-checkbox-input wx-checkbox-input-checked" data-id="{{index}}" checked="{{sub_item.quantity>0?true:false}}" /> <checkbox class="wx-checkbox-input wx-checkbox-input-checked" value="{{index}}" id="{{index}}" data-id="{{index}}" checked="{{sub_item.selected>0?true:false}}" bindtap="radioTap" />
<image class="writer-image" src="{{orderInfo.product_image}}"/> <image class="writer-image" src="{{orderInfo.product_image}}"/>
<view class="note-column"> <view class="note-column">
<span>{{sub_item.product_desc}}</span> <span>{{sub_item.product_desc}}</span>
...@@ -54,11 +54,12 @@ ...@@ -54,11 +54,12 @@
<view class="page__bd"> <view class="page__bd">
<view class="weui-tabbar"> <view class="weui-tabbar">
<view style="display:flex; flex-direction: row; align-items:center; vertical-align:middle;"> <view style="display:flex; flex-direction: row; align-items:center; vertical-align:middle;">
<checkbox-group class="check-group" bindchange="radioChange" style="margin-top:-8rpx"> <checkbox-group class="check-group" bindchange="radioChangeAll" style="margin-top:-8rpx">
<checkbox class="wx-checkbox-input wx-checkbox-input-checked" > <checkbox class="wx-checkbox-input wx-checkbox-input-checked"
checked="{{selected_all==1?true:false}}">
<text style="font-size:30rpx;margin-left:10rpx;">全选</text>
</checkbox> </checkbox>
</checkbox-group> </checkbox-group>
<text style="font-size:30rpx;margin-left:10rpx;">全选</text>
</view> </view>
<!-- todo toBuy 因为现在还没跟商家谈妥 --> <!-- todo toBuy 因为现在还没跟商家谈妥 -->
...@@ -71,10 +72,10 @@ ...@@ -71,10 +72,10 @@
<view class="weui-tabbar__item"> <view class="weui-tabbar__item">
<view class="note-row align" style="margin-bottom:0; justify-content: flex-end"> <view class="note-row align" style="margin-bottom:0; justify-content: flex-end">
<view style="font-size:30rpx;margin-right:20rpx;color:#000">合计: <view style="font-size:30rpx;margin-right:20rpx;color:#000">合计:
<text style="color:#FF6600">¥21341223.00</text> <text style="color:#FF6600">¥{{totalPrice}}</text>
</view> </view>
<view style="width:200rpx"> <view style="width:200rpx">
<button class="button-red" bindtap="toOrder">确定(2)</button> <button class="button-red" bindtap="toOrder">确定({{totalCount}})</button>
</view> </view>
</view> </view>
</view> </view>
......
<!-- /page/post/edit/edit 添加分类的标签,以及自定义标签 --> <!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
<!-- /page/post/edit/edit 添加分类的标签,以及自定义标签 --> <!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
<view class="page" style="height:100%;width:100%"> <view class="page" style="height:100%;width:100%">
<block> <block>
<button type="default" bindtap="navigateToSubmit">下一步</button> <button type="default" bindtap="navigateToSubmit">下一步</button>
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
</view> </view>
</view> </view>
<view class="weui-cells__title">#添加标签</view> <view class="weui-cells__title">#添加亮点</view>
<view class="weui-cells weui-cells_after-title"> <view class="weui-cells weui-cells_after-title">
<view class="weui-cell "> <view class="weui-cell ">
<view class="weui-cell__bd"> <view class="weui-cell__bd">
<input class="weui-input" bindinput="bindKeyTag" placeholder="请输入标签" /> <input class="weui-input" bindinput="bindKeyTag" placeholder="请输入亮点" />
</view> </view>
</view> </view>
</view> </view>
......
<!-- /page/member/quiz-post/quiz-edit/quiz-edit 添加分类的标签,以及自定义标签 --> <!-- /page/member/quiz-post/quiz-edit/quiz-edit 添加分类的特点,以及自定义特点 -->
<!-- /page/member/quiz-post/quiz-edit/quiz-edit 添加分类的标签,以及自定义标签 --> <!-- /page/member/quiz-post/quiz-edit/quiz-edit 添加分类的特点,以及自定义特点 -->
<wxs module="tutil" src="./../../../../utils/date.wxs"></wxs> <wxs module="tutil" src="./../../../../utils/date.wxs"></wxs>
<view class="page" style="height:100%;width:100%"> <view class="page" style="height:100%;width:100%">
......
<!-- /page/post/edit/edit 添加分类的标签,以及自定义标签 --> <!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
<!-- /page/post/edit/edit 添加分类的标签,以及自定义标签 --> <!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
<view class="page" style="height:100%;width:100%"> <view class="page" style="height:100%;width:100%">
<block> <block>
<button type="default" bindtap="navigateToSubmit">下一步</button> <button type="default" bindtap="navigateToSubmit">下一步</button>
</block> </block>
<view class="weui-cells__title">#添加标签</view> <view class="weui-cells__title">#添加亮点</view>
<view class="weui-cells weui-cells_after-title"> <view class="weui-cells weui-cells_after-title">
<view class="weui-cell "> <view class="weui-cell ">
<view class="weui-cell__bd"> <view class="weui-cell__bd">
<input class="weui-input" bindinput="bindKeyInput" placeholder="请输入标签" /> <input class="weui-input" bindinput="bindKeyInput" placeholder="请输入亮点" />
</view> </view>
</view> </view>
</view> </view>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论