|
|
@ -16,7 +16,10 @@ Page({ |
|
|
sku_id: '', |
|
|
sku_id: '', |
|
|
kjId: null, |
|
|
kjId: null, |
|
|
gp_id: null, |
|
|
gp_id: null, |
|
|
prizeId:null |
|
|
prizeId: null, |
|
|
|
|
|
select_allowance: false, |
|
|
|
|
|
allowance_data: null, |
|
|
|
|
|
allowance_price: 0, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -47,7 +50,6 @@ Page({ |
|
|
if (!this.data.kjId && !this.data.gp_id) { |
|
|
if (!this.data.kjId && !this.data.gp_id) { |
|
|
this.couponCom = this.selectAllComponents("#coupon")[0]; |
|
|
this.couponCom = this.selectAllComponents("#coupon")[0]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
inputRemark: function (e) { |
|
|
inputRemark: function (e) { |
|
|
let index = e.currentTarget.dataset.index, product = this.data.product; |
|
|
let index = e.currentTarget.dataset.index, product = this.data.product; |
|
|
@ -89,6 +91,10 @@ Page({ |
|
|
let product = this.data.product, price = 0; |
|
|
let product = this.data.product, price = 0; |
|
|
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) { |
|
|
|
|
|
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) { |
|
|
if (this.data.coupon && this.data.showPrice != price) { |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
@ -135,6 +141,7 @@ 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 (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; |
|
|
} |
|
|
} |
|
|
@ -214,6 +221,16 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 选择补贴 |
|
|
|
|
|
*/ |
|
|
|
|
|
selectAllowance: function () { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
select_allowance: !this.data.select_allowance |
|
|
|
|
|
}) |
|
|
|
|
|
this.changePrice() |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
*/ |
|
|
*/ |
|
|
@ -228,6 +245,39 @@ Page({ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
coupon: app.globalData.couponInfo |
|
|
coupon: app.globalData.couponInfo |
|
|
}) |
|
|
}) |
|
|
|
|
|
// 获取补贴
|
|
|
|
|
|
if (this.data.product.length == 1) { |
|
|
|
|
|
commonApi.user_post("product/getProductAllowancePrice", { |
|
|
|
|
|
product_code: this.data.product[0].product.product_code |
|
|
|
|
|
}).then(resTwo => { |
|
|
|
|
|
console.log(resTwo) |
|
|
|
|
|
if (resTwo && resTwo.code == 1) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
allowance_data: resTwo.data |
|
|
|
|
|
}) |
|
|
|
|
|
let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price) |
|
|
|
|
|
let sInfo = this.data.product[0].sku |
|
|
|
|
|
console.log(9999, this.data.allowance_data.discount_rate / 100 * sInfo.price) |
|
|
|
|
|
console.log(9999, spread_price) |
|
|
|
|
|
if (spread_price > 0) { |
|
|
|
|
|
if (spread_price < this.data.allowance_data.discount_rate / 100 * sInfo.price) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
allowance_price: spread_price |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
allowance_price: this.data.allowance_data.discount_rate / 100 * sInfo.price |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
this.changePrice() |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
allowance_price: 0 |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|