...
|
...
|
@@ -9,10 +9,12 @@ import orderService from '../orderService' |
|
|
import {getImgUrl} from '../../../utils';
|
|
|
import router from '../../../router/index.js'
|
|
|
import { prePay } from '../../order/wxpay.js'
|
|
|
import Yas from '../../../utils/yas';
|
|
|
import Yas from '../../../utils/yas'
|
|
|
|
|
|
let yas;
|
|
|
|
|
|
const ACTIVITY_TYPE = 18; // 砍价
|
|
|
|
|
|
const api = new orderService();
|
|
|
Page({
|
|
|
|
...
|
...
|
@@ -26,23 +28,36 @@ Page({ |
|
|
unCheckImage: '../../../assets/images/unselect@2x.png',
|
|
|
isStore: 0,
|
|
|
storeId: 0,
|
|
|
skup: '',
|
|
|
coupons: [],
|
|
|
selectCouponCode: '',
|
|
|
selectCouponAmount: '',
|
|
|
selectingCoupon: false
|
|
|
selectingCoupon: false,
|
|
|
user_activity_id: '' // 有值代表砍价
|
|
|
},
|
|
|
onLoad: async function (option) {
|
|
|
yas = new Yas(this);
|
|
|
yas.pageOpenReport();
|
|
|
|
|
|
this.setData({
|
|
|
isStore: Number(option.is_store) || 0,
|
|
|
storeId: option.store_id || 0,
|
|
|
skup: option.skup || '',
|
|
|
product_id: option.product_id || '',
|
|
|
hasAddress: false
|
|
|
hasAddress: false,
|
|
|
user_activity_id: option.user_activity_id || ''
|
|
|
})
|
|
|
await this.fetchData(option.is_store);
|
|
|
if (!option.is_store) {
|
|
|
},
|
|
|
|
|
|
async onShow() {
|
|
|
let userInfo = wx.getStorageSync('userInfo');
|
|
|
if (!(userInfo && userInfo.uid && userInfo.session_key)) {
|
|
|
router.go('nativeLogin');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
await this.fetchData(this.data.isStore);
|
|
|
if (!this.data.isStore) {
|
|
|
await this.fetchAddress()
|
|
|
}
|
|
|
},
|
...
|
...
|
@@ -72,10 +87,19 @@ Page({ |
|
|
coupon_code: code
|
|
|
}, () => wx.hideLoading());
|
|
|
} else {
|
|
|
info = await api.orderCompute({
|
|
|
const params = {
|
|
|
skup: this.data.skup,
|
|
|
coupon_code: code
|
|
|
}, () => wx.hideLoading());
|
|
|
};
|
|
|
|
|
|
if (this.data.user_activity_id) {
|
|
|
Object.assign(params, {
|
|
|
user_activity_id: this.data.user_activity_id,
|
|
|
activity_type: ACTIVITY_TYPE
|
|
|
});
|
|
|
}
|
|
|
|
|
|
info = await api.orderCompute(params, () => wx.hideLoading());
|
|
|
}
|
|
|
} catch(e) {}
|
|
|
|
...
|
...
|
@@ -99,6 +123,14 @@ Page({ |
|
|
skup: this.data.skup,
|
|
|
store_id: this.data.storeId
|
|
|
}
|
|
|
|
|
|
if (this.data.user_activity_id) {
|
|
|
Object.assign(params, {
|
|
|
user_activity_id: this.data.user_activity_id,
|
|
|
activity_type: ACTIVITY_TYPE
|
|
|
})
|
|
|
}
|
|
|
|
|
|
let data;
|
|
|
if (isStore) {
|
|
|
data = await api.createOfflinePayment(params, () => wx.hideLoading())
|
...
|
...
|
@@ -110,7 +142,17 @@ Page({ |
|
|
})
|
|
|
data.promotionFormulaList.splice(index,1)
|
|
|
} else {
|
|
|
data = await api.createPaymentInfo(params, () => wx.hideLoading())
|
|
|
try {
|
|
|
data = await api.createPaymentInfo(params, () => wx.hideLoading())
|
|
|
} catch (e) {
|
|
|
console.log(e)
|
|
|
wx.showModal({
|
|
|
title: '失败',
|
|
|
content: e.message,
|
|
|
showCancel: false,
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
api.orderSelectCoupon(this.data.skup, () => wx.hideLoading()).then(data => {
|
...
|
...
|
@@ -191,11 +233,19 @@ Page({ |
|
|
let skup = this.data.skup
|
|
|
let channelNo = '';
|
|
|
let couponCode = this.data.selectCouponCode || '';
|
|
|
let extra = null;
|
|
|
|
|
|
if (this.data.user_activity_id) {
|
|
|
extra = {
|
|
|
user_activity_id: this.data.user_activity_id,
|
|
|
activity_type: ACTIVITY_TYPE
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// wx.showLoading({
|
|
|
// title: '',
|
|
|
// })
|
|
|
data = await api.buyerSubmit(skup, channelNo, addressId, couponCode, () => wx.hideLoading());
|
|
|
data = await api.buyerSubmit({skup, channelNo, addressId, couponCode, extra}, () => wx.hideLoading());
|
|
|
}
|
|
|
if (data && data.orderCode) {
|
|
|
let skup = this.data.skup
|
...
|
...
|
|