Commit 658a3e40 by jscat

nyx weaqq: 页面更新 & 功能更新

1. 完成toOrder的操作
parent a5dfd4c2
//config.js API全局域名配置 //config.js API全局域名配置
...@@ -48,6 +48,7 @@ var config={ ...@@ -48,6 +48,7 @@ var config={
activity_query_url: host_key + "/api/nyx/activity/query", activity_query_url: host_key + "/api/nyx/activity/query",
activity_period_query_url: host_key + "/api/nyx/activity/query/period", activity_period_query_url: host_key + "/api/nyx/activity/query/period",
order_detail_query_url: host_key + "/api/nyx/order/detail/query", order_detail_query_url: host_key + "/api/nyx/order/detail/query",
order_add_url: host_key + "/api/nyx/add/order",
match_query_url: host_key + "/api/nyx/match/query", match_query_url: host_key + "/api/nyx/match/query",
match_query_by_id_url: host_key + "/api/nyx/match/query/id", match_query_by_id_url: host_key + "/api/nyx/match/query/id",
match_query_then_update_url: host_key + "/api/nyx/match/queryThenUpdate/id", match_query_then_update_url: host_key + "/api/nyx/match/queryThenUpdate/id",
......
// pages/activity/activity-info/activity-info.js // pages/activity/activity-info/activity-info.js
...@@ -233,11 +233,11 @@ Page({ ...@@ -233,11 +233,11 @@ Page({
var products_string = {} var products_string = {}
for (var i = 0; i < res.data.data.length; i++) { for (var i = 0; i < res.data.data.length; i++) {
var result = {} var result = {}
result["product_id"] = res.data.data[i].productId result["productId"] = res.data.data[i].productId
result["product_desc"] = res.data.data[i].productDesc result["productDesc"] = res.data.data[i].productDesc
result["unit_price"] = res.data.data[i].unitPrice result["unitPrice"] = res.data.data[i].unitPrice
result["stock"] = res.data.data[i].stock result["stock"] = res.data.data[i].stock
result["default_status"] = res.data.data[i].defaultStatus result["defaultStatus"] = res.data.data[i].defaultStatus
products.push(result) products.push(result)
} }
_this.setData({ products }) _this.setData({ products })
......
<wxs module="tutil" src="./../../../utils/date.wxs"></wxs> <wxs module="tutil" src="./../../../utils/date.wxs"></wxs>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<view class="note"> <view class="note">
<view class="note-price" style="font-weight: bold"> <view class="note-price" style="font-weight: bold">
<view class="clone"> <view class="clone">
<view class="clone-left">¥{{products[curIndex].unit_price}}</view> <view class="clone-left">¥{{products[curIndex].unitPrice}}</view>
<!-- start 点赞 like --> <!-- start 点赞 like -->
<block> <block>
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<span>类别: <span>类别:
<view class="cate-list {{curIndex==index?'on':''}}" wx:for="{{products}}" <view class="cate-list {{curIndex==index?'on':''}}" wx:for="{{products}}"
wx:for-item="sub_item" wx:key="{{index}}" data-index="{{index}}" bindtap="switchCategory"> wx:for-item="sub_item" wx:key="{{index}}" data-index="{{index}}" bindtap="switchCategory">
{{sub_item.product_desc}} {{sub_item.productDesc}}
</view> </view>
</span> </span>
......
<wxs module="tutil" src="./../../utils/date.wxs"></wxs> <wxs module="tutil" src="./../../utils/date.wxs"></wxs>
...@@ -45,13 +45,6 @@ ...@@ -45,13 +45,6 @@
<text>积分</text> <text>积分</text>
</view> --> </view> -->
<!-- todo 0728 热销暂时也不实现 --> <!-- todo 0728 热销暂时也不实现 -->
<!-- todo 0828 我的活动暂时也不实现 -->
<!-- <view class="items">
<navigator url="/pages/my/my-orders/my-orders">
<image src="../../icon/activity/order.png"></image>
</navigator>
<text>我的活动</text>
</view> -->
<!-- jscat20200816 添加活动日历 for convinience --> <!-- jscat20200816 添加活动日历 for convinience -->
<block> <block>
<view class="items"> <view class="items">
...@@ -69,6 +62,14 @@ ...@@ -69,6 +62,14 @@
</navigator> </navigator>
</view> </view>
<!-- todo 0828 我的活动暂时也不实现 -->
<view class="items">
<navigator url="/pages/my/my-orders/my-orders">
<image src="../../icon/activity/order.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
</navigator>
<text>我的活动</text>
</view>
</view> </view>
</view> </view>
......
// pages/my/my-orders/my-orders.js // pages/my/my-orders/my-orders.js
...@@ -20,9 +20,9 @@ Page({ ...@@ -20,9 +20,9 @@ Page({
/* 数量加减 */ /* 数量加减 */
totalPrice: 0, totalPrice: 0,
totalCount: 0,
curIndex: 0, curIndex: 0,
selected_all : 0, selected_all : 0,
totalCount: 0,
}, },
...@@ -65,14 +65,14 @@ Page({ ...@@ -65,14 +65,14 @@ Page({
if(curIndex == i) if(curIndex == i)
{ {
orderItems[i]['quantity'] = 1 orderItems[i]['quantity'] = 1
orderItems[i]['selected'] = 1 orderItems[i]['defaultStatus'] = 1
totalPrice = orderItems[i]['unit_price'] totalPrice = orderItems[i]['unitPrice']
totalPrice = totalPrice.toFixed(2) totalPrice = totalPrice.toFixed(2)
} }
else else
{ {
orderItems[i]['quantity'] = 0 orderItems[i]['quantity'] = 0
orderItems[i]['selected'] = 0 orderItems[i]['defaultStatus'] = 0
} }
} }
...@@ -151,17 +151,17 @@ Page({ ...@@ -151,17 +151,17 @@ Page({
// 总数量+1 // 总数量+1
if (orderItems[index]['quantity'] < 1000) { if (orderItems[index]['quantity'] < 1000) {
orderItems[index]['quantity'] = orderItems[index]['quantity']+1; orderItems[index]['quantity'] = orderItems[index]['quantity']+1;
orderItems[index]['selected'] = 1; orderItems[index]['defaultStatus'] = 1;
} }
// 如果所有 商品的selected==1, 则selected_all=1 // 如果所有 商品的defaultStatus==1, 则selected_all=1
// 因为是addCount, 所以假定selected_all为1 // 因为是addCount, 所以假定selected_all为1
selected_all = orderItems[index]['selected'] selected_all = orderItems[index]['defaultStatus']
for(var i=0; i< orderItems.length; i++) for(var i=0; i< orderItems.length; i++)
{ {
selected_all = orderItems[i]['selected'] == 1?selected_all && 1 : 0 selected_all = orderItems[i]['defaultStatus'] == 1?selected_all && 1 : 0
totalPrice = orderItems[i]['selected'] == 1 ? _this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unit_price'])) : totalPrice totalPrice = orderItems[i]['defaultStatus'] == 1 ? _this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unitPrice'])) : totalPrice
totalCount = orderItems[i]['selected'] == 1?totalCount+orderItems[i]['quantity']:totalCount totalCount = orderItems[i]['defaultStatus'] == 1?totalCount+orderItems[i]['quantity']:totalCount
} }
totalPrice = totalPrice.toFixed(2) totalPrice = totalPrice.toFixed(2)
...@@ -189,23 +189,23 @@ Page({ ...@@ -189,23 +189,23 @@ Page({
// 商品总数量-1 // 商品总数量-1
if (orderItems[index]['quantity'] > 1) { if (orderItems[index]['quantity'] > 1) {
orderItems[index]['quantity'] = orderItems[index]['quantity'] - 1; orderItems[index]['quantity'] = orderItems[index]['quantity'] - 1;
orderItems[index]['selected'] = 1; orderItems[index]['defaultStatus'] = 1;
} }
// 如果减到0 // 如果减到0
// 当前商品的selected = 0 // 当前商品的defaultStatus = 0
// 所有商品的selected_all = 0 // 所有商品的selected_all = 0
else if(orderItems[index]['quantity'] == 1) else if(orderItems[index]['quantity'] == 1)
{ {
orderItems[index]['quantity'] = 0; orderItems[index]['quantity'] = 0;
orderItems[index]['selected'] = 0; orderItems[index]['defaultStatus'] = 0;
selected_all = 0; selected_all = 0;
} }
//计算totalPrice和totalCount //计算totalPrice和totalCount
for(var i=0; i< orderItems.length; i++) 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 totalPrice = orderItems[i]['defaultStatus'] == 1 ? _this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unitPrice'])) : totalPrice
totalCount = orderItems[i]['selected'] == 1?totalCount+orderItems[i]['quantity']:totalCount totalCount = orderItems[i]['defaultStatus'] == 1?totalCount+orderItems[i]['quantity']:totalCount
} }
totalPrice = totalPrice.toFixed(2) totalPrice = totalPrice.toFixed(2)
...@@ -218,16 +218,6 @@ Page({ ...@@ -218,16 +218,6 @@ Page({
}); });
}, },
// 跳转到支付页面
// 目前暂时跳转到 /page/my/my.wxml
toPay: function (e) {
var _this = this;
var url = "/pages/my/my"
wx.switchTab({
url: url
});
},
//加法 //加法
add : function (arg1, arg2) { add : function (arg1, arg2) {
var r1, r2, m; var r1, r2, m;
...@@ -278,7 +268,7 @@ Page({ ...@@ -278,7 +268,7 @@ Page({
}, },
// 单个商品 选择按钮 // 单个商品 选择按钮
// 改变多选框状态 orderItems[i]['selected']: true || false // 改变多选框状态 orderItems[i]['defaultStatus']: true || false
// 同步更新selected_all // 同步更新selected_all
// 同步改变totalPrice // 同步改变totalPrice
radioTap: function(e){ radioTap: function(e){
...@@ -291,18 +281,18 @@ Page({ ...@@ -291,18 +281,18 @@ Page({
var selected_all = _this.data.selected_all var selected_all = _this.data.selected_all
var totalPrice = 0; var totalPrice = 0;
var totalCount = 0; var totalCount = 0;
// 如果quantity==0, 则selected=0, selected_all=0 // 如果quantity==0, 则defaultStatus=0, selected_all=0
orderItems[dataId].selected = orderItems[dataId].selected==1 ? 0 : orderItems[dataId].defaultStatus = orderItems[dataId].defaultStatus==1 ? 0 :
(orderItems[dataId]['quantity']>0 ? 1 : 0) (orderItems[dataId]['quantity']>0 ? 1 : 0)
//确定selected_all的值 //确定selected_all的值
selected_all = orderItems[dataId].selected selected_all = orderItems[dataId].defaultStatus
for(var i=0; i<orderItems.length; i++) for(var i=0; i<orderItems.length; i++)
{ {
selected_all = orderItems[i]['selected'] == 1 ? selected_all && 1 : 0 selected_all = orderItems[i]['defaultStatus'] == 1 ? selected_all && 1 : 0
totalPrice = orderItems[i].selected == 0 ? totalPrice : totalPrice = orderItems[i].defaultStatus == 0 ? totalPrice :
_this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unit_price'])) _this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unitPrice']))
totalCount = orderItems[i].selected == 0 ? totalCount : totalCount + orderItems[i]['quantity'] totalCount = orderItems[i].defaultStatus == 0 ? totalCount : totalCount + orderItems[i]['quantity']
} }
totalPrice = totalPrice.toFixed(2) totalPrice = totalPrice.toFixed(2)
...@@ -317,7 +307,7 @@ Page({ ...@@ -317,7 +307,7 @@ Page({
}, },
// 全选按钮 // 全选按钮
// 改变多选框状态 orderItems[i]['selected']: true || false // 改变多选框状态 orderItems[i]['defaultStatus']: true || false
// 同步改变totalPrice // 同步改变totalPrice
radioChangeAll: function (e){ radioChangeAll: function (e){
var _this = this var _this = this
...@@ -332,10 +322,10 @@ Page({ ...@@ -332,10 +322,10 @@ Page({
// 改变后计算 // 改变后计算
for(var i=0; i< orderItems.length; i++) for(var i=0; i< orderItems.length; i++)
{ {
orderItems[i]['selected'] = selected_all == 1 ? (orderItems[i]['quantity']>0 ? 1 : 0) : 0 orderItems[i]['defaultStatus'] = selected_all == 1 ? (orderItems[i]['quantity']>0 ? 1 : 0) : 0
totalPrice = selected_all == 0 ? 0 : totalPrice = selected_all == 0 ? 0 :
_this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unit_price'])) _this.add(totalPrice, _this.mul(orderItems[i]['quantity'], orderItems[i]['unitPrice']))
totalCount = orderItems[i].selected == 0 ? totalCount : totalCount + orderItems[i]['quantity'] totalCount = orderItems[i].defaultStatus == 0 ? totalCount : totalCount + orderItems[i]['quantity']
} }
totalPrice = totalPrice.toFixed(2) totalPrice = totalPrice.toFixed(2)
...@@ -349,5 +339,50 @@ Page({ ...@@ -349,5 +339,50 @@ Page({
}, },
// 跳转到支付页面
// 目前暂时跳转到 /page/my/my.wxml
toPay: function (e) {
var _this = this;
var strUrl = config.order_add_url
config.debug == 1?console.log("===uploadOrder strUrl "+strUrl):""
wx.request({
url: strUrl,
method: 'POST',
data: {
activityId: _this.__data__.orderInfo["activity_id"],
userId: _this.data.nyxCode,
productImage: _this.__data__.orderInfo['product_image'],
totalPrice: _this.data.totalPrice,
totalCount: _this.data.totalCount,
orderItemString: JSON.stringify(_this.data.orderItems),
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': wx.getStorageSync('cookieKey'),
},
dataType: "json",
success: function (res) {
if ( res.data.resultCode == 200 ) {
//表示提交成功
console.log("===订单上传成功");
//重置数据
//回到首页
_this.toHome();
}
}
})
},
//跳转到首页
toHome: function (e) {
wx.switchTab({
url: "/pages/activity/activity"
});
},
}) })
\ No newline at end of file
<view class="page"> <view class="page">
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
<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" value="{{index}}" id="{{index}}" data-id="{{index}}" checked="{{sub_item.selected>0?true:false}}" bindtap="radioTap" /> <checkbox class="wx-checkbox-input wx-checkbox-input-checked" value="{{index}}" id="{{index}}" data-id="{{index}}" checked="{{sub_item.defaultStatus>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>
<span> <span>
<view class="price-row"> <view class="price-row">
<view class="sub-price">¥{{sub_item.unit_price}}</view> <view class="sub-price">¥{{sub_item.unitPrice}}</view>
<!-- start 数量加减 --> <!-- start 数量加减 -->
<view class="stepper"> <view class="stepper">
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
<text style="color:#FF6600">¥{{totalPrice}}</text> <text style="color:#FF6600">¥{{totalPrice}}</text>
</view> </view>
<view style="width:200rpx"> <view style="width:200rpx">
<button class="button-red" bindtap="toOrder">确定({{totalCount}})</button> <button class="button-red" bindtap="toPay">确定({{totalCount}})</button>
</view> </view>
</view> </view>
</view> </view>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论