|
|
@ -29,12 +29,16 @@ Page({ |
|
|
showYhq:null, |
|
|
showYhq:null, |
|
|
|
|
|
|
|
|
pickupIndex: null, |
|
|
pickupIndex: null, |
|
|
|
|
|
|
|
|
|
|
|
smoothlyTotal: 0, |
|
|
|
|
|
maxCouponObject: null |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面加载 |
|
|
* 生命周期函数--监听页面加载 |
|
|
*/ |
|
|
*/ |
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
|
|
|
console.log(this.data.product) |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
from: options.from, |
|
|
from: options.from, |
|
|
kjId: app.globalData.kjId, |
|
|
kjId: app.globalData.kjId, |
|
|
@ -45,8 +49,21 @@ Page({ |
|
|
showYhq:app.globalData.listName?false:true |
|
|
showYhq:app.globalData.listName?false:true |
|
|
}) |
|
|
}) |
|
|
this.handleProduct() |
|
|
this.handleProduct() |
|
|
|
|
|
console.log(this.data.product) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 子组件发生改变时更新价格
|
|
|
|
|
|
handleUpdateTotalPrice(e) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
smoothlyTotal: e.detail.total |
|
|
|
|
|
}); |
|
|
|
|
|
// 重新计算总价
|
|
|
|
|
|
this.changePrice(); |
|
|
|
|
|
}, |
|
|
|
|
|
// 调用子组件清除优惠券方法
|
|
|
|
|
|
callOtherCompMethod: function(e) { |
|
|
|
|
|
this.couponCom.setNullCoupon() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
handleProduct () { |
|
|
handleProduct () { |
|
|
app.globalData.postProduct.forEach((item,index) => { |
|
|
app.globalData.postProduct.forEach((item,index) => { |
|
|
item.keyIndex = index |
|
|
item.keyIndex = index |
|
|
@ -218,7 +235,12 @@ Page({ |
|
|
this.changePrice() |
|
|
this.changePrice() |
|
|
}, |
|
|
}, |
|
|
changePrice: function () { |
|
|
changePrice: function () { |
|
|
let product = this.data.product, price = 0; |
|
|
let product = this.data.product, price = 0, allPrice = 0; |
|
|
|
|
|
|
|
|
|
|
|
// 顺手购价格
|
|
|
|
|
|
price += this.data.smoothlyTotal || 0; |
|
|
|
|
|
allPrice = price |
|
|
|
|
|
|
|
|
product.map(item => { |
|
|
product.map(item => { |
|
|
price = price + item.sku.price * item.productNum; |
|
|
price = price + item.sku.price * item.productNum; |
|
|
if (this.data.allowance_data && this.data.select_allowance && this.data.allowance_price) { |
|
|
if (this.data.allowance_data && this.data.select_allowance && this.data.allowance_price) { |
|
|
@ -242,8 +264,38 @@ Page({ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
showPrice: app.globalData.kjId ? 0 : price |
|
|
showPrice: app.globalData.kjId ? 0 : price |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const smoothlyComp = this.selectComponent("#smoothlyOrderComp"); |
|
|
|
|
|
const skuIds = [] |
|
|
|
|
|
skuIds.push(this.data.sku_id) |
|
|
|
|
|
if(smoothlyComp) { |
|
|
|
|
|
// 检查是否有选中的顺手购商品
|
|
|
|
|
|
const hasSkuIds = smoothlyComp.hasSelectedGoods(); |
|
|
|
|
|
if(hasSkuIds) { |
|
|
|
|
|
skuIds.push(...smoothlyComp.emitSkuIds()) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
maxCouponObject: { |
|
|
|
|
|
price: allPrice, |
|
|
|
|
|
skuIds: skuIds.toString() |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
order: function () { |
|
|
order: function () { |
|
|
|
|
|
// 顺手带一件是否选择收货地址
|
|
|
|
|
|
const smoothlyComp = this.selectComponent("#smoothlyOrderComp"); |
|
|
|
|
|
if(smoothlyComp && this.data.product[0].user_select_type == 1) { |
|
|
|
|
|
// 检查是否有选中的顺手购商品
|
|
|
|
|
|
const hasSelected = smoothlyComp.hasSelectedGoods(); |
|
|
|
|
|
if(hasSelected && !smoothlyComp.data.address) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: '请选择收货地址', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for(let info of this.data.product) { |
|
|
for(let info of this.data.product) { |
|
|
if (info.user_select_type == 0) { |
|
|
if (info.user_select_type == 0) { |
|
|
@ -327,6 +379,12 @@ Page({ |
|
|
gp_id: app.globalData.gp_id, |
|
|
gp_id: app.globalData.gp_id, |
|
|
team_id: app.globalData.team_id |
|
|
team_id: app.globalData.team_id |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 顺手购下单参数
|
|
|
|
|
|
if(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length) { |
|
|
|
|
|
product_list.push(...smoothlyComp.emitOrder()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (this.data.select_allowance) data.is_allowance = 1 |
|
|
if (this.data.select_allowance) data.is_allowance = 1 |
|
|
if (app.globalData.from) { |
|
|
if (app.globalData.from) { |
|
|
data.system_name = app.globalData.from; |
|
|
data.system_name = app.globalData.from; |
|
|
@ -348,10 +406,11 @@ Page({ |
|
|
data.channel = ZTPointProduct.product.ZTPoint |
|
|
data.channel = ZTPointProduct.product.ZTPoint |
|
|
} |
|
|
} |
|
|
console.log(app.globalData.list,this.data.flag) |
|
|
console.log(app.globalData.list,this.data.flag) |
|
|
|
|
|
|
|
|
if(!app.globalData.list || app.globalData.list.length == 0){ |
|
|
if(!app.globalData.list || app.globalData.list.length == 0){ |
|
|
// 判断混合下单
|
|
|
// 判断混合下单
|
|
|
let use_type = product_list[0].use_type |
|
|
let use_type = product_list[0].use_type |
|
|
if (product_list.some(x=>x.use_type!=use_type)) { |
|
|
if (product_list.some(x=>x.use_type!=use_type) && !(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length)) { |
|
|
app.globalData.productPrice = (this.data.showPrice + this.data.postFee - (this.data.coupon?this.data.coupon.activity.money:0))/100; |
|
|
app.globalData.productPrice = (this.data.showPrice + this.data.postFee - (this.data.coupon?this.data.coupon.activity.money:0))/100; |
|
|
app.globalData.createDate = data |
|
|
app.globalData.createDate = data |
|
|
wx.redirectTo({ |
|
|
wx.redirectTo({ |
|
|
|