diff --git a/pages/order/WineSceneOrder/index.js b/pages/order/WineSceneOrder/index.js index d218f29..b486f69 100644 --- a/pages/order/WineSceneOrder/index.js +++ b/pages/order/WineSceneOrder/index.js @@ -42,7 +42,10 @@ Page({ showDate:false, showDate2:false, showYhq:null, - couponFlag:false + couponFlag:false, + + smoothlyTotal: 0, + maxCouponObject: null }, /** @@ -77,7 +80,8 @@ Page({ } this.setData({singlePrice: this.data.product.sku.price}) - this.showAllPrice() + // this.showAllPrice() + this.totalPrice(this.data.singlePrice) console.log(this.data); console.log(this.data.product.product.ZTPoint) @@ -86,7 +90,18 @@ Page({ }, - + // 子组件发生改变时更新价格 + handleUpdateTotalPrice(e) { + this.setData({ + smoothlyTotal: e.detail.total + }); + // 重新计算总价 + this.totalPrice(this.data.singlePrice) + }, + // 调用子组件清除优惠券方法 + callOtherCompMethod: function(e) { + this.couponCom.setNullCoupon() + }, showBookingInfo: function (e) { this.setData({ bookingInfo: this.data.product.sku.sku_model, @@ -230,15 +245,21 @@ Page({ this.totalPrice(this.data.singlePrice) }, totalPrice(price) { - let allPrice + let allPrice = this.data.singlePrice * this.data.productNum + let prices = 0 + console.log(this.data.smoothlyTotal,111111) + // 顺手购价格 + allPrice += this.data.smoothlyTotal || 0; + prices = allPrice + if (this.data.coupon) { if (this.data.coupon.activity.discount_type == 'pricebreak') { - allPrice = this.data.singlePrice * this.data.productNum - this.data.coupon.activity.money + allPrice = allPrice - this.data.coupon.activity.money } else { - allPrice =(this.data.singlePrice * this.data.productNum * this.data.coupon.activity.fold)/ 10 + allPrice =(allPrice * this.data.coupon.activity.fold)/ 10 } } else { - allPrice = this.data.singlePrice * this.data.productNum + allPrice = allPrice } // allPrice = price * this.data.productNum - (this.data.coupon?this.data.coupon.activity.money:0) @@ -254,10 +275,40 @@ Page({ }) } console.log('singlePrice',this.data.singlePrice); + + const smoothlyComp = this.selectComponent("#smoothlyOrderComp"); + const skuIds = [] + skuIds.push(this.data.product.sku.id) + if(smoothlyComp) { + // 检查是否有选中的顺手购商品 + const hasSkuIds = smoothlyComp.hasSelectedGoods(); + if(hasSkuIds) { + skuIds.push(...smoothlyComp.emitSkuIds()) + } + } + this.setData({ + maxCouponObject: { + price: prices, + skuIds: skuIds.toString() + } + }) }, order:function() { + const smoothlyComp = this.selectComponent("#smoothlyOrderComp"); + if(smoothlyComp) { + // 检查是否有选中的顺手购商品 + const hasSelected = smoothlyComp.hasSelectedGoods(); + if(hasSelected && !smoothlyComp.data.address) { + wx.showToast({ + title: '请选择收货地址', + icon: 'none' + }) + return; + } + } + let linkmanList = this.data.linkmanList, productNum = this.data.productNum, date = this.data.date, time = this.data.time, remark = this.data.remark, product = this.data.product; let linkmanIds = []; @@ -282,6 +333,12 @@ Page({ team_id: app.globalData.team_id, } + + // 顺手购下单参数 + if(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length) { + data.product_list.push(...smoothlyComp.emitOrder()) + } + if (app.globalData.from) { data.system_name = app.globalData.from; } @@ -383,7 +440,8 @@ Page({ this.setData({ coupon:e.detail }) - this.showAllPrice() + // this.showAllPrice() + this.totalPrice(this.data.singlePrice) }, /** diff --git a/pages/order/WineSceneOrder/index.json b/pages/order/WineSceneOrder/index.json index 6e93399..42dca0a 100644 --- a/pages/order/WineSceneOrder/index.json +++ b/pages/order/WineSceneOrder/index.json @@ -3,6 +3,7 @@ "title":"/pages/component/TitleHeader", "contact":"../components/contact/index", "coupon":"../components/coupon/index", - "notice":"/pages/component/notice/notice" + "notice":"/pages/component/notice/notice", + "smoothly-order": "/pages/order/components/smoothlyOrder/index" } } \ No newline at end of file diff --git a/pages/order/WineSceneOrder/index.wxml b/pages/order/WineSceneOrder/index.wxml index e2f5348..7be6e64 100644 --- a/pages/order/WineSceneOrder/index.wxml +++ b/pages/order/WineSceneOrder/index.wxml @@ -38,9 +38,16 @@ + money="{{singlePrice * productNum}}" sku="{{product.sku.id}}" couponFlag="{{couponFlag}}" maxCouponObject="{{maxCouponObject}}"> - + + 合计: diff --git a/pages/order/WineSceneOrder/index.wxss b/pages/order/WineSceneOrder/index.wxss index 3e49fea..91703eb 100644 --- a/pages/order/WineSceneOrder/index.wxss +++ b/pages/order/WineSceneOrder/index.wxss @@ -1,6 +1,7 @@ /* pages/.wxss */ page { background: #f6f6f6; + padding-bottom: 150rpx; } .group-order { diff --git a/pages/order/components/address/index.js b/pages/order/components/address/index.js index b105bf0..6f7e6cd 100644 --- a/pages/order/components/address/index.js +++ b/pages/order/components/address/index.js @@ -11,7 +11,10 @@ Component({ addGlobalClass: true }, properties: { - + showSelect: { + type: Boolean, + value: true + }, }, /** diff --git a/pages/order/components/address/index.wxml b/pages/order/components/address/index.wxml index ad0299e..9609703 100644 --- a/pages/order/components/address/index.wxml +++ b/pages/order/components/address/index.wxml @@ -1,4 +1,4 @@ - + 收货地址 选择 diff --git a/pages/order/components/coupon/index.js b/pages/order/components/coupon/index.js index 883a94b..7b6cf8a 100644 --- a/pages/order/components/coupon/index.js +++ b/pages/order/components/coupon/index.js @@ -2,93 +2,112 @@ import commonApi from "../../../../utils/https/common" let app = getApp() Component({ - /** - * 组件的属性列表 - */ - properties: { - money:{ - type:String, - value:"0" - }, - sku:{ - type:String, - value:"" - }, - couponFlag:{ - type:Boolean, - value:false, - observer(nv, ov) { - console.log(nv,ov) - if (nv) { - app.globalData.couponInfo = null - this.setData({ - coupon:null - }) - } - } - } - }, + /** + * 组件的属性列表 + */ + properties: { + money: { + type: String, + value: "0" + }, + sku: { + type: String, + value: "" + }, + couponFlag: { + type: Boolean, + value: false, + observer(nv, ov) { + console.log(nv, ov) + if (nv) { + app.globalData.couponInfo = null + this.setData({ + coupon: null + }) + } + } + }, + maxCouponObject: { + type: Object, + value: null, + observer(nv, ov) { + console.log(111, nv, ov) + this.getMaxPrice() + } + } + }, - /** - * 组件的初始数据 - */ - data: { - coupon:null - }, - pageLifetimes: { - show: function() { - this.getMaxCoupon() - } - }, - lifetimes:{ - attached(){ - }, - }, - /** - * 组件的方法列表 - */ - methods: { - setNullCoupon:function(){ - app.globalData.couponInfo = null - this.setData({ - coupon:null - }) - }, - getMaxCoupon(){ - // console.log(app.globalData.couponInfo); - console.log(this.data.coupon); - if (app.globalData.couponInfo===false) { - this.setData({ - coupon:null - }) - this.triggerEvent('getNewCoupon',null); - }else{ - commonApi.user_post('coupon/use_max_coupon_list',{ - money:this.data.money, - sku_ids:this.data.sku - }).then(res=>{ - if (app.globalData.couponInfo&&app.globalData.couponInfo.hasOwnProperty('SubCoupon')) { - this.setData({ - coupon:app.globalData.couponInfo - }) - this.triggerEvent('getNewCoupon',app.globalData.couponInfo); - console.log("我用的原来的数据"); - }else{ - console.log("我用的新的数据"); - console.log('123123132',res.data); - if ( Object.keys(res.data).length!=0) { - app.globalData.couponInfo = res.data - this.setData({ - coupon:res.data - }) - console.log(this.data.coupon); - this.triggerEvent('getNewCoupon',res.data); - } - } - }) - } + /** + * 组件的初始数据 + */ + data: { + coupon: null, + maxCouponPrice: 0 + }, + pageLifetimes: { + show: function() { + this.getMaxCoupon() + } + }, + lifetimes: { + attached() {}, + }, + /** + * 组件的方法列表 + */ + methods: { + setNullCoupon: function() { + console.log(44154) + app.globalData.couponInfo = null + this.setData({ + coupon: null + }) + }, + getMaxCoupon() { + // console.log(app.globalData.couponInfo); + console.log(this.data.coupon); + if (app.globalData.couponInfo === false) { + this.setData({ + coupon: null + }) + this.triggerEvent('getNewCoupon', null); + } else { + commonApi.user_post('coupon/use_max_coupon_list', { + money: this.data.money, + sku_ids: this.data.sku + }).then(res => { + if (app.globalData.couponInfo && app.globalData.couponInfo.hasOwnProperty( + 'SubCoupon')) { + this.setData({ + coupon: app.globalData.couponInfo + }) + this.triggerEvent('getNewCoupon', app.globalData.couponInfo); + console.log("我用的原来的数据"); + } else { + console.log("我用的新的数据"); + console.log('123123132', res.data); + if (Object.keys(res.data).length != 0) { + app.globalData.couponInfo = res.data + this.setData({ + coupon: res.data + }) + console.log(this.data.coupon); + this.triggerEvent('getNewCoupon', res.data); + } + } + }) + } + }, + getMaxPrice() { + commonApi.user_post('coupon/use_max_coupon_list', { + money: this.data.maxCouponObject.price, + sku_ids: this.data.maxCouponObject.skuIds + }).then(res => { + this.setData({ + maxCouponPrice: res.data.activity.money + }) + }) + } + }, - } - }, - -}) +}) \ No newline at end of file diff --git a/pages/order/components/coupon/index.wxml b/pages/order/components/coupon/index.wxml index d93a9e6..c4cf7d2 100644 --- a/pages/order/components/coupon/index.wxml +++ b/pages/order/components/coupon/index.wxml @@ -2,14 +2,18 @@ 优惠券 + + ¥{{maxCouponPrice / 100}}优惠券可用 + - -{{coupon.activity.money/100}} + -¥{{coupon.activity.money/100}} {{coupon.activity.fold}}折 - 请选择 + + > diff --git a/pages/order/components/coupon/index.wxss b/pages/order/components/coupon/index.wxss index 0a1745c..15d6205 100644 --- a/pages/order/components/coupon/index.wxss +++ b/pages/order/components/coupon/index.wxss @@ -8,17 +8,27 @@ height: 113rpx; margin: 0 20rpx; font-size: 31rpx; - color: #000; + color: #E30000; font-weight: 500; display: flex; align-items: center; } .coupon-btn { - width: 138rpx; + width: 50rpx; line-height: 56rpx; - border: 1px solid #333333; + /* border: 1px solid #333333; */ border-radius: 29rpx; text-align: center; font-size: 28rpx; - color: #000; + color: #333333; +} +.coupon-left { + line-height: 40rpx; + background: #FFDEDE; + border-radius: 13rpx; + padding: 0 18rpx; + font-weight: 500; + font-size: 24rpx; + color: #E30000; + margin-right: 20rpx; } \ No newline at end of file diff --git a/pages/order/components/smoothlyOrder/index.js b/pages/order/components/smoothlyOrder/index.js new file mode 100644 index 0000000..34310b5 --- /dev/null +++ b/pages/order/components/smoothlyOrder/index.js @@ -0,0 +1,291 @@ +import commonApi from "../../../../utils/https/common" +let app = getApp() +Component({ + properties: { + productId: { + type: [String, Number], + value: '' + }, + postId: { + type: [String, Number], + value: '' + }, + type: { + type: String, + value: '' + } + }, + data: { + addressList: [], + addressIndex: -1, + address: null, + smoothlyList: [], + sommthlyIndex: 0, + showAddressPopup: false, + showItem: null, + showSkuPopup: false + }, + lifetimes: { + attached() { + this.setData({ + sommthlyIndex: 0 + }) + this.getList() + } + }, + observers: { + 'type': function(newVal, oldVal) { + // 当从邮寄切换到自提时 + if (oldVal === 'post' && newVal !== 'post') { + // 重置所有商品邮费 + const smoothlyList = this.data.smoothlyList.map(item => ({ + ...item, + postMoney: 0 + })) + this.setData({ + smoothlyList, + addressIndex: -1 + }) + // 重新计算总价 + this.calculateTotalPrice() + } else if (newVal === 'post') { + // 切换到邮寄时重新计算邮费 + this.showPostMoney() + } + }, + 'postId': function(newVal, oldVal) { + // 只有当当前是邮寄类型时,才重新计算邮费 + if (this.data.type === 'post' && newVal !== oldVal) { + this.showPostMoney() + } + } + }, + onload() { + this.couponCom = this.selectAllComponents("#coupon")[0]; + }, + methods: { + // 是否有选中商品 + hasSelectedGoods() { + return this.data.smoothlyList.some(item => (item.buyNum || 0) > 0); + }, + // 规格id + emitSkuIds() { + let skuIds = [] + this.data.smoothlyList.forEach(item => { + if (item.buyNum > 0) { + skuIds.push(item.sku_id) + } + }); + return skuIds; + }, + // 下单参数 + emitOrder() { + let orderList = [] + this.data.smoothlyList.forEach(item => { + if (item.buyNum > 0) { + orderList.push({ + type: item.type, + product_id: item.id, + sku_id: item.sku_id, + post: this.data.type == 'post' ? this.data.postId : (this.data.address ? + this.data + .address.id : ''), + product_num: item.buyNum, + use_type: 0, + is_batch_shipment: 0, + }) + } + }) + return orderList + }, + switchSmoothlyList() { + const { + smoothlyList, + sommthlyIndex + } = this.data + // 重置当前商品数量 + smoothlyList[sommthlyIndex].buyNum = 0 + + // 更新索引 + const newIndex = sommthlyIndex < smoothlyList.length - 1 ? sommthlyIndex + 1 : 0 + this.setData({ + smoothlyList, + sommthlyIndex: newIndex + }) + + this.showPostMoney().then(() => { + this.calculateTotalPrice() + }) + }, + setNullCoupons() { + if (app.globalData.couponInfo != null) { + wx.showToast({ + title: '订单价格发生变化,请重新选择优惠券', + icon: 'none' + }) + + this.triggerEvent('callOtherComp', { + methodName: 'setNullCoupon', // 要调用的子组件B的方法名 + }); + } + }, + setAddress(e) { + console.log(e.detail); + this.setData({ + address: e.detail + }) + this.showPostMoney().then(() => { + this.calculateTotalPrice() + }) + }, + showAddress() { + const childComp = this.selectComponent('#addressComp'); + if (!childComp) { + wx.showToast({ + title: '组件未加载完成', + icon: 'none' + }); + return; + } + childComp.showLinkman() + }, + showImg(img) { + if (!img) { + return img + } + if (img.indexOf('https://') != -1 || img.indexOf('http://') != -1) { + return img; + } else { + // return "https://test.api.cloud.sz-trip.com"+img + return "https://static.ticket.sz-trip.com" + img; + } + }, + getList() { + commonApi.user_post('product/get_convenient_purchase', { + page: 1, + limit: 100, + product_id: this.data.productId + }).then(res => { + if (res.data) { + const smoothlyList = res.data.map(i => ({ + ...i, + headimg: this.showImg(i.headimg), + buyNum: 0, + postMoney: 0 + })); + this.setData({ + smoothlyList + }); + } + }) + }, + showPostMoney() { + const { + type, + postId, + addressList, + addressIndex, + smoothlyList + } = this.data + + if (type == 'post') { + if (!postId) return Promise.resolve() + } else { + if (!this.data.address) return Promise.resolve() + } + + const promises = smoothlyList.map(item => { + if (item.buyNum > 0) { + return commonApi.user_post("order/get_post_price", { + sku_id: item.sku_id, + num: item.buyNum, + consignee_id: type == 'post' ? postId : (this.data.address ? this.data + .address.id : '') + }).then(res => { + if (res) { + // 更新对应商品的邮费 + const newList = [...smoothlyList] + const idx = newList.findIndex(i => i.sku_id === item.sku_id) + if (idx > -1) { + newList[idx].postMoney = res.data.price + this.setData({ + smoothlyList: newList + }) + } + } + }) + } + return Promise.resolve() + }) + + return Promise.all(promises) + }, + decreaseSkuNum(e) { + const item = e.currentTarget.dataset.item + const { + smoothlyList + } = this.data + + if (item.buyNum > 0) { + // 找到对应商品并更新数量 + const newList = smoothlyList.map(i => { + if (i.sku_id === item.sku_id) { + return { + ...i, + buyNum: i.buyNum - 1 + } + } + return i + }) + + this.setData({ + smoothlyList: newList + }) + this.setNullCoupons() + this.showPostMoney().then(() => { + this.calculateTotalPrice() + }) + } + }, + + increaseSkuNum(e) { + const item = e.currentTarget.dataset.item + const { + smoothlyList + } = this.data + + // 找到对应商品并更新数量 + const newList = smoothlyList.map(i => { + if (i.sku_id === item.sku_id) { + return { + ...i, + buyNum: i.buyNum + 1 + } + } + return i + }) + + this.setData({ + smoothlyList: newList + }) + + this.showPostMoney().then(() => { + this.calculateTotalPrice() + }) + }, + // 计算总价 + calculateTotalPrice() { + let total = 0; + this.data.smoothlyList.forEach(item => { + if (item.buyNum > 0) { + const itemPrice = parseFloat(item.price) * item.buyNum; + total += itemPrice + item.postMoney; + } + }); + this.triggerEvent('updateTotalPrice', { + total + }); + return total; + }, + } +}) \ No newline at end of file diff --git a/pages/order/components/smoothlyOrder/index.json b/pages/order/components/smoothlyOrder/index.json new file mode 100644 index 0000000..0111e85 --- /dev/null +++ b/pages/order/components/smoothlyOrder/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "address":"../../components/address/index" + } +} \ No newline at end of file diff --git a/pages/order/components/smoothlyOrder/index.wxml b/pages/order/components/smoothlyOrder/index.wxml new file mode 100644 index 0000000..6df6936 --- /dev/null +++ b/pages/order/components/smoothlyOrder/index.wxml @@ -0,0 +1,78 @@ + + + + 顺手带一件 + + + 换一换 + + + + + + + + + 收货地址 点击填写收货地址 + + + + + + + 收货地址 + + + {{address.name}}{{address.tel}} + + + {{address.address}} + + + + + + + + + + + + {{item.title}} + + + {{item.sku_name}} + + {{item.price / 100}}(另需运费¥{{item.postMoney / 100}}) + + + + {{item.buyNum}} + + + + + + + + + +
+ + +
\ No newline at end of file diff --git a/pages/order/components/smoothlyOrder/index.wxss b/pages/order/components/smoothlyOrder/index.wxss new file mode 100644 index 0000000..4860b23 --- /dev/null +++ b/pages/order/components/smoothlyOrder/index.wxss @@ -0,0 +1,201 @@ +.flex-between { + display: flex; + justify-content: space-between; + align-items: center; +} + +.container { + width: 750rpx; +} + +.box { + width: 700rpx; + background: #FFFFFF; + border-radius: 9.33rpx; + padding: 0 21.33rpx 46.67rpx; + margin: 0 auto; + box-sizing: border-box; +} + +.top-title { + height: 110rpx; + font-weight: bold; + font-size: 30.67rpx; + color: #000000; + display: flex; + justify-content: space-between; + align-items: center; +} + +.refresh-btn { + font-weight: bold; + font-size: 28rpx; + color: #0B898E; + display: flex; + align-items: center; +} + +.refresh-btn image { + width: 32rpx; + margin-right: 13.33rpx; +} + +.address-box { + width: 655.33rpx; + height: 80rpx; + background: rgba(11, 137, 142, .06); + border-radius: 13.33rpx; + padding: 0 21.33rpx; + font-weight: 500; + font-size: 26.67rpx; + color: #0B898E; + display: flex; + justify-content: space-between; + align-items: center; + box-sizing: border-box; +} + +.address-box .location { + width: 42.67rpx; + margin-right: 26.67rpx; +} + +.address-box .rightIcon { + width: 20rpx; +} + +.address-boxs { + width: 655.33rpx; + height: 133.33rpx; + background: #F7F7F7; + border-radius: 13.33rpx; + padding: 13.33rpx 21.33rpx; + display: flex; + justify-content: space-between; + align-items: center; + box-sizing: border-box; +} + +.address-boxs .location { + width: 42.67rpx; + margin-right: 26.67rpx; +} + +.address-boxs .content { + display: flex; + align-items: center; + margin-right: 33.33rpx; +} + +.address-boxs .content .left { + font-weight: 500; + font-size: 26.67rpx; + color: #000000; +} + +.address-boxs .content .right { + width: 333.33rpx; + margin-left: 16.67rpx; +} + +.address-boxs .content .right .top { + font-weight: 400; + font-size: 30.67rpx; + color: #000000; +} + +.address-boxs .content .right .top text { + font-weight: 500; + font-size: 24rpx; + color: #666666; + margin-left: 33.33rpx; +} + +.address-boxs .content .right .bottom { + margin-top: 6.67rpx + font-weight: 500; + font-size: 24rpx; + color: #666666; +} + +.address-boxs .rightIcon { + width: 33.33rpx; +} + +.product-item { + height: 153.33rpx; + display: flex; + width: 100%; + margin-top: 40rpx; +} + +.product-item .product-img { + width: 153.33rpx; + height: 153.33rpx; + border-radius: 13.33rpx; + margin-right: 20rpx; +} + +.product-item .product-content { + flex: 1; + height: 153.33rpx; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.product-item .product-content .title-boxs { + display: flex; + justify-content: space-between; + align-items: center; +} + +.product-item .product-content .title-boxs .title { + width: 445.33rpx; + font-weight: 500; + font-size: 28rpx; + color: #000000; +} + +.product-item .product-content .title-boxs image { + width: 20rpx; +} + +.product-item .product-content .subtitle { + font-weight: 500; + font-size: 24rpx; + color: #999999; +} + +.product-item .product-content .price { + font-weight: 500; + font-size: 33.33rpx; + color: #E30000; +} + +.product-item .product-content .price::before { + content: '¥'; + font-size: 24rpx; +} + +.product-item .product-content .price text { + font-weight: 500; + font-size: 24rpx; + color: #E30000; + margin-left: 6.67rpx; +} + +.product-item .product-content .product-btn { + width: 160rpx; + font-weight: bold; + font-size: 28rpx; + color: #111111; + display: flex; + justify-content: space-between; + align-items: center; +} + +.product-item .product-content .product-btn image { + width: 46.67rpx; + flex-shrink: 0; +} \ No newline at end of file diff --git a/pages/order/food/index.js b/pages/order/food/index.js index 1a3cf66..d22db10 100644 --- a/pages/order/food/index.js +++ b/pages/order/food/index.js @@ -16,6 +16,8 @@ Page({ showNoticeFlag:false, coupon:null, price: 0, + smoothlyTotal: 0, + maxCouponObject: null }, /** @@ -37,6 +39,18 @@ Page({ console.log(app.globalData.product) this.showAllPrice() }, + // 子组件发生改变时更新价格 + handleUpdateTotalPrice(e) { + this.setData({ + smoothlyTotal: e.detail.total + }); + // 重新计算总价 + this.showAllPrice(); + }, + // 调用子组件清除优惠券方法 + callOtherCompMethod: function(e) { + this.couponCom.setNullCoupon() + }, showNotice:function(){ this.setData({ showNoticeFlag:true @@ -58,22 +72,44 @@ Page({ showAllPrice () { console.log('couponInfo',app.globalData.couponInfo); - let price + let price = this.data.product.sku.price * this.data.productNum + let allPrice = 0 + + // 顺手购价格 + price += this.data.smoothlyTotal || 0; + allPrice = price + if (this.data.coupon) { if (this.data.coupon.activity.discount_type == 'pricebreak') { - price = this.data.product.sku.price * this.data.productNum - this.data.coupon.activity.money + price = price - this.data.coupon.activity.money } else { - price =(this.data.product.sku.price * this.data.productNum * this.data.coupon.activity.fold)/ 10 + price =(price * this.data.coupon.activity.fold)/ 10 } } else { - price = this.data.product.sku.price * this.data.productNum + price = price } if (price >0) { this.setData({ price:price/100}) }else { this.setData({ price:0 }) } - + + const smoothlyComp = this.selectComponent("#smoothlyOrderComp"); + const skuIds = [] + skuIds.push(this.data.product.sku.id) + if(smoothlyComp) { + // 检查是否有选中的顺手购商品 + const hasSkuIds = smoothlyComp.hasSelectedGoods(); + if(hasSkuIds) { + skuIds.push(...smoothlyComp.emitSkuIds()) + } + } + this.setData({ + maxCouponObject: { + price: allPrice, + skuIds: skuIds.toString() + } + }) }, /** @@ -116,6 +152,20 @@ Page({ }) }, order:function(){ + const smoothlyComp = this.selectComponent("#smoothlyOrderComp"); + console.log(smoothlyComp,smoothlyComp.emitOrder()) + if(smoothlyComp) { + // 检查是否有选中的顺手购商品 + const hasSelected = smoothlyComp.hasSelectedGoods(); + if(hasSelected && !smoothlyComp.data.address) { + wx.showToast({ + title: '请选择收货地址', + icon: 'none' + }) + return; + } + } + // if(!this.data.user){ // wx.showToast({ // title: '请输入联系人', @@ -143,6 +193,12 @@ Page({ source:"WECHATXCX", coupon_id:this.data.coupon?this.data.coupon.id:null }; + + // 顺手购下单参数 + if(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length) { + product_list.push(...smoothlyComp.emitOrder()) + } + if(app.globalData.from){ data.system_name = app.globalData.from; } diff --git a/pages/order/food/index.json b/pages/order/food/index.json index fe0a5a2..84c6148 100644 --- a/pages/order/food/index.json +++ b/pages/order/food/index.json @@ -2,6 +2,7 @@ "usingComponents": { "title":"/pages/component/TitleHeader", "notice":"/pages/component/notice/notice", - "coupon":"/pages/order/components/coupon/index" + "coupon":"/pages/order/components/coupon/index", + "smoothly-order": "/pages/order/components/smoothlyOrder/index" } } \ No newline at end of file diff --git a/pages/order/food/index.wxml b/pages/order/food/index.wxml index 4f4c5c3..814418d 100644 --- a/pages/order/food/index.wxml +++ b/pages/order/food/index.wxml @@ -28,7 +28,17 @@
- + + + + + diff --git a/pages/order/showOrderNew/index.js b/pages/order/showOrderNew/index.js index 99eff0f..2552622 100644 --- a/pages/order/showOrderNew/index.js +++ b/pages/order/showOrderNew/index.js @@ -46,6 +46,8 @@ Page({ showDate2:false, showYhq:null, couponFlag:false, + smoothlyTotal: 0, + maxCouponObject: null }, /** @@ -115,6 +117,18 @@ Page({ // showDate: true, // }) // }, + // 子组件发生改变时更新价格 + handleUpdateTotalPrice(e) { + this.setData({ + smoothlyTotal: e.detail.total + }); + // 重新计算总价 + this.totalPrice(this.data.singlePrice) + }, + // 调用子组件清除优惠券方法 + callOtherCompMethod: function(e) { + this.couponCom.setNullCoupon() + }, hideDate: function () { this.setData({ showDate: false @@ -281,15 +295,20 @@ Page({ this.totalPrice(this.data.singlePrice) }, totalPrice(price) { - let allPrice + let allPrice = this.data.singlePrice * this.data.productNum + let prices = 0 + console.log(this.data.smoothlyTotal,111111) + // 顺手购价格 + allPrice += this.data.smoothlyTotal || 0; + prices = allPrice if (this.data.coupon) { if (this.data.coupon.activity.discount_type == 'pricebreak') { - allPrice = this.data.singlePrice * this.data.productNum - this.data.coupon.activity.money + allPrice = allPrice - this.data.coupon.activity.money } else { - allPrice =(this.data.singlePrice * this.data.productNum * this.data.coupon.activity.fold)/ 10 + allPrice =(allPrice * this.data.coupon.activity.fold)/ 10 } } else { - allPrice = this.data.singlePrice * this.data.productNum + allPrice = allPrice } // allPrice = price * this.data.productNum - (this.data.coupon?this.data.coupon.activity.money:0) @@ -305,6 +324,23 @@ Page({ }) } console.log('singlePrice',this.data.singlePrice); + + const smoothlyComp = this.selectComponent("#smoothlyOrderComp"); + const skuIds = [] + skuIds.push(this.data.product.sku.id) + if(smoothlyComp) { + // 检查是否有选中的顺手购商品 + const hasSkuIds = smoothlyComp.hasSelectedGoods(); + if(hasSkuIds) { + skuIds.push(...smoothlyComp.emitSkuIds()) + } + } + this.setData({ + maxCouponObject: { + price: prices, + skuIds: skuIds.toString() + } + }) }, changeDate: function (e) { console.log('打印',e); @@ -372,6 +408,19 @@ Page({ this.hideDate() }, order:function() { + const smoothlyComp = this.selectComponent("#smoothlyOrderComp"); + if(smoothlyComp) { + // 检查是否有选中的顺手购商品 + const hasSelected = smoothlyComp.hasSelectedGoods(); + if(hasSelected && !smoothlyComp.data.address) { + wx.showToast({ + title: '请选择收货地址', + icon: 'none' + }) + return; + } + } + let linkmanList = this.data.linkmanList, productNum = this.data.productNum, date = this.data.date, time = this.data.time, remark = this.data.remark, product = this.data.product; let linkmanIds = []; if (linkmanList.length==0 && this.data.is_authentication == 1) { @@ -432,6 +481,12 @@ Page({ team_id: app.globalData.team_id, linkmanList:this.data.is_authentication == 1?this.data.linkmanList:[] } + + // 顺手购下单参数 + if(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length) { + data.product_list.push(...smoothlyComp.emitOrder()) + } + if (app.globalData.from) { data.system_name = app.globalData.from; } @@ -609,7 +664,8 @@ Page({ coupon:e.detail }) - this.showAllPrice() + // this.showAllPrice() + this.totalPrice(this.data.singlePrice) }, /** diff --git a/pages/order/showOrderNew/index.json b/pages/order/showOrderNew/index.json index 19927e7..54c1962 100644 --- a/pages/order/showOrderNew/index.json +++ b/pages/order/showOrderNew/index.json @@ -4,6 +4,7 @@ "contact":"../components/contact/index", "coupon":"../components/coupon/index", "notice":"/pages/component/notice/notice", - "date":"/pages/order/components/date" + "date":"/pages/order/components/date", + "smoothly-order": "/pages/order/components/smoothlyOrder/index" } } \ No newline at end of file diff --git a/pages/order/showOrderNew/index.wxml b/pages/order/showOrderNew/index.wxml index 380b633..9d0a16c 100644 --- a/pages/order/showOrderNew/index.wxml +++ b/pages/order/showOrderNew/index.wxml @@ -46,7 +46,16 @@ --> + money="{{singlePrice * productNum}}" sku="{{product.sku.id}}" couponFlag="{{couponFlag}}" maxCouponObject="{{maxCouponObject}}"> + + + diff --git a/pages/order/showOrderNew/index.wxss b/pages/order/showOrderNew/index.wxss index 3780f39..478a9a6 100644 --- a/pages/order/showOrderNew/index.wxss +++ b/pages/order/showOrderNew/index.wxss @@ -1,6 +1,7 @@ /* pages/.wxss */ page { background: #f6f6f6; + padding-bottom: 150rpx; } .group-order { diff --git a/project.private.config.json b/project.private.config.json index e6ba547..b8dc83d 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -6,12 +6,33 @@ "condition": { "miniprogram": { "list": [ + { + "name": "pages/info/showInfo/index", + "pathName": "pages/info/showInfo/index", + "query": "id=465394", + "scene": null, + "launchMode": "default" + }, + { + "name": "pages/info/postProductInfo/index", + "pathName": "pages/info/postProductInfo/index", + "query": "id=460201&ZTPoint=%E7%94%84%E9%80%89%E6%99%AF%E9%85%92%E5%A5%97%E9%A4%90", + "launchMode": "default", + "scene": null + }, + { + "name": "subPackages/foodNew/index", + "pathName": "subPackages/foodNew/index", + "query": "id=914667", + "launchMode": "default", + "scene": null + }, { "name": "pages/info/roadInfo/index", "pathName": "pages/info/roadInfo/index", "query": "id=457033", - "scene": null, - "launchMode": "default" + "launchMode": "default", + "scene": null }, { "name": "pages/info/roadInfo/index", @@ -109,5 +130,5 @@ }, "projectname": "%E8%8B%8F%E5%B7%9E%E6%96%87%E6%97%85", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", - "libVersion": "3.9.3" + "libVersion": "3.7.12" } \ No newline at end of file