...
|
...
|
@@ -2,24 +2,22 @@ import ensureModel from '../../../models/cart/ensure'; |
|
|
import addressModel from '../../../models/home/address';
|
|
|
import wechatAddressUtil from '../../../utils/wechat-address';
|
|
|
import { wechatPay } from '../../../utils/wechat-pay';
|
|
|
import Yas from '../../../common/yas';
|
|
|
|
|
|
const SKU_TYPE = 'O';
|
|
|
|
|
|
// 支付类型
|
|
|
const PAYMENT = {
|
|
|
const PAYMENT = { // 支付类型
|
|
|
ID: 15,
|
|
|
TYPE: 1,
|
|
|
};
|
|
|
|
|
|
// 结算订单类型
|
|
|
const ORDER_TYPE = {
|
|
|
const ORDER_TYPE = { // 结算订单类型
|
|
|
BUYNOW: 'buynow'
|
|
|
};
|
|
|
|
|
|
const app = getApp();
|
|
|
const router = global.router;
|
|
|
const yas = new Yas(app);
|
|
|
|
|
|
function formatPaymentData(data) {
|
|
|
function formatPaymentData(data, yasInfo) {
|
|
|
data = data || {};
|
|
|
|
|
|
let info = {
|
...
|
...
|
@@ -31,11 +29,17 @@ function formatPaymentData(data) { |
|
|
paymentAmount: data.shopping_cart_data.last_order_amount
|
|
|
};
|
|
|
|
|
|
yasInfo = yasInfo || {};
|
|
|
|
|
|
info.goodsList.map(value => {
|
|
|
if (value.goods_type === 'gift' || value.goods_type === 'price_gift') {
|
|
|
value.sales_price = value.last_price;
|
|
|
}
|
|
|
|
|
|
yasInfo.skns && yasInfo.skns.push(value.product_skn);
|
|
|
yasInfo.skus && yasInfo.skus.push(value.product_sku);
|
|
|
yasInfo.pids && yasInfo.pids.push(value.product_id);
|
|
|
|
|
|
return value;
|
|
|
});
|
|
|
|
...
|
...
|
@@ -98,6 +102,11 @@ Page({ |
|
|
},
|
|
|
onLoad(options) {
|
|
|
this.orderData = options;
|
|
|
this.yasInfo = {
|
|
|
skns: [],
|
|
|
skus: [],
|
|
|
pids: []
|
|
|
};
|
|
|
this.loadEnsurePayment({productSku: this.orderData.productSku});
|
|
|
},
|
|
|
loadEnsurePayment(options, reload) {
|
...
|
...
|
@@ -120,7 +129,7 @@ Page({ |
|
|
return;
|
|
|
}
|
|
|
|
|
|
let data = formatPaymentData(res.data);
|
|
|
let data = formatPaymentData(res.data, this.yasInfo);
|
|
|
|
|
|
Object.assign(this.orderData, {
|
|
|
productSku: options.productSku,
|
...
|
...
|
@@ -128,7 +137,7 @@ Page({ |
|
|
deliveryWayId: data.deliveryWayId,
|
|
|
deliveryTimeId: data.deliveryTimeId
|
|
|
});
|
|
|
|
|
|
console.log(this.yasInfo);
|
|
|
this.setData(data);
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -331,6 +340,15 @@ Page({ |
|
|
this.orderSubmiting = false;
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
// yas上报
|
|
|
yas.report('YB_SC_ORD', {
|
|
|
ORD_NUM: res.data.order_code,
|
|
|
PRD_SKN: this.yasInfo.skns.join(','),
|
|
|
RPD_SKU: this.yasInfo.skus.join(','),
|
|
|
PRD_ID: this.yasInfo.pids.join(','),
|
|
|
ORDER_TYPE: 102 // 101购物车下单,102立即购买下单
|
|
|
});
|
|
|
|
|
|
wechatPay(res.data);
|
|
|
} else {
|
|
|
wx.showModal({
|
...
|
...
|
|