From 7cae5f4a04f267d7ee2bf73547fcec7c6b301d6e Mon Sep 17 00:00:00 2001 From: caichunsheng Date: Fri, 5 Aug 2022 16:06:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/order/orderList/index.js | 90 +++++++++++++++++++++++++++----- pages/order/orderList/index.wxml | 10 +++- pages/order/orderList/index.wxss | 17 ++++-- pages/order/postOrder/index.js | 8 +-- pages/order/postOrder/index.wxml | 6 +-- pages/order/scene/index.js | 6 ++- pages/order/scene/index.wxml | 4 +- pages/user/cartlist/list.js | 18 ++++--- 8 files changed, 124 insertions(+), 35 deletions(-) diff --git a/pages/order/orderList/index.js b/pages/order/orderList/index.js index 7aadf7f..30cc91c 100644 --- a/pages/order/orderList/index.js +++ b/pages/order/orderList/index.js @@ -7,46 +7,110 @@ Page({ * 页面的初始数据 */ data: { - goodsList: [], - ticketList: [], + goodsList: [], + ticketList: [], productPrice: 0, - ticketPrice: 0 + ticketPrice: 0, + product:"", + sku_id: '', + kjId: null, + gp_id: null, + showPrice: 0, + postFee: 0, + coupon:null, + select_allowance: false, + allowance_data: null, + allowance_price: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - console.log(app.globalData.kjId) this.setData({ goodsList: app.globalData.postProduct, - ticketList: app.globalData.list + ticketList: app.globalData.list, + kjId: app.globalData.kjId, + gp_id: app.globalData.gp_id || app.globalData.team_id, }) - console.log(this.data.goodsList,this.data.ticketList) + console.log(app.globalData); + let price = 0, sku_id = []; + app.globalData.postProduct.map(item => { + if (!app.globalData.kjId && !this.data.gp_id) { + price = price + item.sku.price * item.productNum; + } + else if (this.data.gp_id) { + price = price + item.sku.event_price * item.productNum; + } + sku_id.push(item.sku.id) + }) + app.globalData.list.map(item => { + price = price + item.sku.price * item.num; + sku_id.push(item.sku.id) + }) + this.setData({ + showPrice: app.globalData.kjId ? 0 : price, + sku_id: sku_id.join(",") + }) + if (!this.data.kjId && !this.data.gp_id) { + this.couponCom = this.selectAllComponents("#coupon")[0]; + } + console.log(this.data.showPrice) }, order: function (){ + console.log(app.globalData.createDate); + app.globalData.createDate.coupon_id= this.data.coupon ? this.data.coupon.id : null; let service = "order/create", postData = {data: JSON.stringify(app.globalData.createDate)} commonApi.user_post(service, postData).then(res => { }) }, - + changePrice: function () { + let product = this.data.product, price = 0; + product.map(item => { + price = price + item.sku.price * item.productNum; + if (this.data.allowance_data && this.data.select_allowance && this.data.allowance_price) { + let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price); + price -= this.data.allowance_price * item.productNum < spread_price ? this.data.allowance_price * item.productNum : spread_price + } + }) + if (this.data.coupon && this.data.showPrice != price) { + wx.showToast({ + title: '订单价格发生变化,请重新选择优惠券', + icon: 'none' + }) + app.globalData.couponInfo = null; + if (!this.data.kjId && !this.data.gp_id) { + this.couponCom.setNullCoupon() + } + this.setData({ + coupon: null + }) + } + this.setData({ + showPrice: app.globalData.kjId ? 0 : price + }) + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, - + inputRemark: function (e) { + app.globalData.createDate.product_list.map((item)=>{ + if (item.type.includes('post')) { + item.remark = e.detail.value; + } + }) + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - this.setData({ - productPrice: app.globalData.productPrice, - ticketPrice: app.globalData.ticketPrice - }) - console.log(app.globalData.productPrice,app.globalData.ticketPrice) + this.setData({ + coupon: app.globalData.couponInfo + }) }, /** diff --git a/pages/order/orderList/index.wxml b/pages/order/orderList/index.wxml index 2838721..fe628a0 100644 --- a/pages/order/orderList/index.wxml +++ b/pages/order/orderList/index.wxml @@ -6,7 +6,7 @@ {{item.product.title}} - ¥{{item.product.price/100}} + ¥{{item.sku.price/100}} @@ -48,10 +48,16 @@ + + 订单备注: + + + + 合计: - ¥{{productPrice + ticketPrice}} + ¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}} 下一步 \ No newline at end of file diff --git a/pages/order/orderList/index.wxss b/pages/order/orderList/index.wxss index e3fe5ab..42bac92 100644 --- a/pages/order/orderList/index.wxss +++ b/pages/order/orderList/index.wxss @@ -1,9 +1,8 @@ page{ - background: #f5f5f5; + background: #f5f5f5; } .box{ - width: 700rpx; - margin: 30rpx auto; + margin: 30rpx 25rpx; background: white; padding: 20rpx; } @@ -50,4 +49,16 @@ page{ color: #D62828; font-size: 36rpx; margin-left: 10rpx; +} +.box-title { + height: 113rpx; + padding: 0 20rpx; + font-size: 31rpx; + color: #000; + font-weight: 500; + display: flex; + align-items: center; + background-color: #fff; + margin: 30rpx 25rpx; + } \ No newline at end of file diff --git a/pages/order/postOrder/index.js b/pages/order/postOrder/index.js index 9130250..cb20054 100644 --- a/pages/order/postOrder/index.js +++ b/pages/order/postOrder/index.js @@ -21,6 +21,7 @@ Page({ allowance_data: null, allowance_price: 0, showAllowance: false, + flag:null, }, /** @@ -31,7 +32,8 @@ Page({ from: options.from, kjId: app.globalData.kjId, gp_id: app.globalData.gp_id || app.globalData.team_id, - prizeId: wx.getStorageSync('prizeId') + prizeId: wx.getStorageSync('prizeId'), + flag:options.flag }) let price = 0, sku_id = []; app.globalData.postProduct.map(item => { @@ -143,7 +145,7 @@ Page({ let data = { source: "WECHATXCX", product_list: product_list, - coupon: this.data.coupon ? this.data.coupon.id : null, + coupon_id: this.data.coupon ? this.data.coupon.id : null, originate_order_id: this.data.kjId, gp_id: app.globalData.gp_id, team_id: app.globalData.team_id @@ -185,7 +187,7 @@ Page({ app.globalData.createDate = data console.log(app.globalData.createDate) wx.navigateTo({ - url: '/pages/order/scene/index', + url: '/pages/order/scene/index?flag='+this.data.flag, }) } }, diff --git a/pages/order/postOrder/index.wxml b/pages/order/postOrder/index.wxml index a9106db..6c3ab93 100644 --- a/pages/order/postOrder/index.wxml +++ b/pages/order/postOrder/index.wxml @@ -29,8 +29,8 @@ 运费 {{item.postFee?(item.postFee==0?'包邮':(item.postFee/100)):item.sku.sku_model.post_template_name}} - - 订单备注: + + 订单备注: @@ -47,7 +47,7 @@ - + 合计: - - + 订单备注 diff --git a/pages/user/cartlist/list.js b/pages/user/cartlist/list.js index caf910a..d6a16bb 100644 --- a/pages/user/cartlist/list.js +++ b/pages/user/cartlist/list.js @@ -17,7 +17,8 @@ Page({ list:[], allChecked:false, allPrice:0, - productType:'' + productType:'', + flag:false,//判断订单是否同时有商品和票 }, /** @@ -109,7 +110,6 @@ Page({ }) }, order:function(){ - console.log(this.data.productType) app.globalData.couponInfo = null; util.pagePoint({ event:'cart_order' @@ -117,7 +117,6 @@ Page({ let list = this.data.list,price=0,product=[],product1=[] list.map(item=>{ if(item.checked){ - console.log(item) // item.product.type="post"; if(item.product.type == 'post'){ product.push({ @@ -128,11 +127,10 @@ Page({ }else{ product1.push(item) app.globalData.list = product1 - } + } if(item.product.type.includes('post')){ this.data.productType = 'post' } - console.log(this.data.productType) } }) if(product.length==0 && product1.length==0) { @@ -142,13 +140,19 @@ Page({ }) return; } + if (product.length>0 && product1.length>0) { + this.setData({ + flag: 'mix' + }) + } app.globalData.postProduct = product; if(app.globalData.list){ app.globalData.product = app.globalData.list[app.globalData.index] - } + } if(this.data.productType == 'post'){ + console.log(this.data.flag); wx.navigateTo({ - url: '/pages/order/postOrder/index?from=cart', + url: '/pages/order/postOrder/index?from=cart&flag='+this.data.flag, }) }else{ wx.navigateTo({