...
|
...
|
@@ -33,6 +33,7 @@ Page({ |
|
|
selectCouponCode: '',
|
|
|
selectCouponAmount: '',
|
|
|
selectingCoupon: false,
|
|
|
promotionid: '',
|
|
|
user_activity_id: '' // 有值代表砍价
|
|
|
},
|
|
|
onLoad: async function (option) {
|
...
|
...
|
@@ -56,10 +57,14 @@ Page({ |
|
|
return;
|
|
|
}
|
|
|
|
|
|
//选中优惠卷后,切到后台,再切回前台页面,不在请求数据
|
|
|
if (!this.data.selectCouponCode) {
|
|
|
await this.fetchData(this.data.isStore);
|
|
|
if (!this.data.isStore) {
|
|
|
if (!this.data.isStore && !this.data.hasAddress) {
|
|
|
await this.fetchAddress()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
showSelectCoupon: function () {
|
...
|
...
|
@@ -69,27 +74,53 @@ Page({ |
|
|
},
|
|
|
|
|
|
async confirmSelectCoupon({detail}) {
|
|
|
|
|
|
let code = detail.code;
|
|
|
let codeType = detail.codeType;
|
|
|
let amount = detail.amount || '';
|
|
|
let couponsList = this.data.couponList;
|
|
|
if (couponsList){
|
|
|
couponsList.forEach((item, index) => {
|
|
|
if (code === item.coupon_code) {
|
|
|
item.isChosen = true;
|
|
|
item.selected = 'Y'
|
|
|
}
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
couponsList,
|
|
|
selectCouponAmount: amount,
|
|
|
selectCouponCode: code,
|
|
|
selectingCoupon: false
|
|
|
selectingCoupon: false,
|
|
|
selectingCouponType: codeType
|
|
|
});
|
|
|
|
|
|
// 区分线上线下
|
|
|
let info;
|
|
|
//如果选择了非运费券,促销不选择
|
|
|
let promotion_id = '';
|
|
|
if (this.data && this.data.promotionTips && this.data.promotionTips.promotionIds) {
|
|
|
promotion_id = this.data.promotionTips.promotionIds;
|
|
|
}
|
|
|
//判断优惠劵的类型
|
|
|
if (code && codeType !== 110){
|
|
|
promotion_id = '';
|
|
|
}
|
|
|
try {
|
|
|
if (this.data.isStore) {
|
|
|
info = await api.orderOfflineCompute({
|
|
|
skup: this.data.skup,
|
|
|
coupon_code: code
|
|
|
coupon_code: code,
|
|
|
promotionId: promotion_id,
|
|
|
app_version: '1'
|
|
|
}, () => wx.hideLoading());
|
|
|
} else {
|
|
|
const params = {
|
|
|
skup: this.data.skup,
|
|
|
coupon_code: code
|
|
|
coupon_code: code,
|
|
|
promotionid: promotion_id
|
|
|
};
|
|
|
|
|
|
if (this.data.user_activity_id) {
|
...
|
...
|
@@ -121,7 +152,8 @@ Page({ |
|
|
});
|
|
|
let params = {
|
|
|
skup: this.data.skup,
|
|
|
store_id: this.data.storeId
|
|
|
store_id: this.data.storeId,
|
|
|
api_version: '1'
|
|
|
}
|
|
|
|
|
|
if (this.data.user_activity_id) {
|
...
|
...
|
@@ -155,10 +187,23 @@ Page({ |
|
|
}
|
|
|
}
|
|
|
|
|
|
api.orderSelectCoupon(this.data.skup, () => wx.hideLoading()).then(data => {
|
|
|
let coupons = data || [];
|
|
|
this.setData(coupons)
|
|
|
// await api.orderSelectCoupon(this.data.skup, () => wx.hideLoading()).then(data => {
|
|
|
// this.setData(coupons)
|
|
|
// });
|
|
|
let that = this;
|
|
|
if (data && data.couponList && data.couponList.length > 0){
|
|
|
let coupons = [];
|
|
|
data.couponList.forEach((item, index) => {
|
|
|
let selected = item.selected;
|
|
|
if (selected === 'Y'){
|
|
|
item.isChosen = true;
|
|
|
data.selectCouponAmount = item.coupon_value_str;
|
|
|
data.selectCouponCode = item.coupon_code;
|
|
|
}else {
|
|
|
item.isChosen = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (data.good && data.good.goodImg) {
|
|
|
data.good.goodImg = getImgUrl(data.good.goodImg, 270, 270)
|
...
|
...
|
@@ -202,18 +247,26 @@ Page({ |
|
|
},
|
|
|
|
|
|
async submit() {
|
|
|
|
|
|
if (!this.data.agreeProtocol) return;
|
|
|
let data;
|
|
|
try {
|
|
|
let promotionId = '';
|
|
|
if (this.data && this.data.promotionTips && this.data.promotionTips.promotionIds){
|
|
|
promotionId = this.data.promotionTips.promotionIds;
|
|
|
}
|
|
|
|
|
|
if (this.data.selectingCouponType && this.data.selectingCouponType !== 110) {
|
|
|
promotionId = '';
|
|
|
}
|
|
|
if (this.data.isStore) {
|
|
|
this.check = this.selectComponent("#check");
|
|
|
let checkRes = await this.check.init();
|
|
|
if (!checkRes.result) return;
|
|
|
let param = checkRes.data;
|
|
|
param.skup = this.data.skup
|
|
|
param.skup = this.data.skup;
|
|
|
param.api_version = '1';
|
|
|
param.coupon_code = this.data.selectCouponCode || '';
|
|
|
|
|
|
param.promotionId = promotionId;
|
|
|
// wx.showLoading({
|
|
|
// title: '',
|
|
|
// })
|
...
|
...
|
@@ -235,6 +288,7 @@ Page({ |
|
|
let couponCode = this.data.selectCouponCode || '';
|
|
|
let extra = null;
|
|
|
|
|
|
|
|
|
if (this.data.user_activity_id) {
|
|
|
extra = {
|
|
|
user_activity_id: this.data.user_activity_id,
|
...
|
...
|
@@ -245,7 +299,7 @@ Page({ |
|
|
// wx.showLoading({
|
|
|
// title: '',
|
|
|
// })
|
|
|
data = await api.buyerSubmit({skup, channelNo, addressId, couponCode, extra}, () => wx.hideLoading());
|
|
|
data = await api.buyerSubmit({ skup, channelNo, addressId, couponCode, promotionId, extra}, () => wx.hideLoading());
|
|
|
}
|
|
|
if (data && data.orderCode) {
|
|
|
let skup = this.data.skup
|
...
|
...
|
|