Authored by yyq

report

... ... @@ -340,16 +340,19 @@ Page({
this.orderSubmiting = false;
if (res.code === 200) {
let data = res.data;
// yas上报
yas.report('YB_SC_ORD', {
ORD_NUM: res.data.order_code,
ORD_NUM: 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);
data.needJump = true;
wechatPay(data);
} else {
wx.showModal({
content: res.message,
... ...
import payModel from '../models/pay/pay';
import Yas from '../common/yas';
const PAYMENT_CODE = '45';
let app = getApp();
let router = global.router;
const yas = new Yas(app);
function showErrorTip(text) {
wx.showModal({
content: text,
... ... @@ -13,7 +16,7 @@ function showErrorTip(text) {
});
}
function redirectOrdersPage(confirm) {
function redirectOrdersPage(confirm, jump) {
if (confirm) {
wx.showModal({
content: confirm,
... ... @@ -21,32 +24,45 @@ function redirectOrdersPage(confirm) {
confirmText: '确定',
confirmColor: '#000',
complete: function(res) {
router.go('orderList');
jump && router.go('orderList', {type: 2}, 'redirectTo');
}
});
} else {
router.go('orderList');
jump && router.go('orderList', {type: 2}, 'redirectTo');
}
}
function reportPayStatus(success) {
yas.report('YB_SC_PAY_RES', {
ORD_NUM: orderCode,
ORDER_AMOUNT: orderAmount,
PAY_TYPE: 1,
PAY_RES: success ? 1 : 0
});
}
function wechatPay(order, callback) {
order = order || {};
let orderCode = order.order_code,
orderAmount = order.order_amount;
if (!orderCode || !orderAmount) {
// TODO logger
//
reportPayStatus();
return showErrorTip('支付失败,请求参数不完整.');
}
let wechatSession = app.getWechatThirdSession();
if (!wechatSession) {
// TODO logger
//
reportPayStatus();
return showErrorTip('支付失败,用户session未获取到.');
}
const needJump = order.needJump;
wx.showToast({
title: '加载中',
icon: 'loading',
... ... @@ -61,7 +77,7 @@ function wechatPay(order, callback) {
wx.hideToast();
if (res.code !== 200) {
return redirectOrdersPage(`${data.code}:${data.message}`);
return redirectOrdersPage(`${data.code}:${data.message}`, needJump);
}
let data = res.data;
... ... @@ -73,9 +89,7 @@ function wechatPay(order, callback) {
signType: data.signType,
paySign: data.paySign,
success: function(res) {
// TODO logger
//
let prepareID = data.package
let prepareID = data.package;
if (prepareID && prepareID.length > 10) {
prepareID = prepareID.slice(10);
... ... @@ -91,6 +105,8 @@ function wechatPay(order, callback) {
});
}
reportPayStatus(true);
// 支付成功二次确认
payModel.paySuccessConfirm({
order_code: orderCode,
... ... @@ -105,14 +121,16 @@ function wechatPay(order, callback) {
fail: function(res) {
let message = '';
reportPayStatus();
if (res.errMsg !== 'requestPayment:fail cancel') {
message = res.errMsg;
}
redirectOrdersPage(message);
redirectOrdersPage(message, needJump);
}
})
}).catch(e => {
return redirectOrdersPage('获取订单信息失败');
return redirectOrdersPage('获取订单信息失败', needJump);
});
}
... ...