var t = getApp(), n = t.request; module.exports = { url: "/api/weshop/order/pay/createOrder", rechange: function(t, e, a) { var i = this; n.post(this.url, { data: { account: t }, success: function(t) { i.weixinPay(t.data.result, e, a); }, fail: function() { "function" == typeof a && a(); }, failStatus: function() { "function" == typeof a && a(); } }); }, pay: function(t, e, a,sto,type) { var i = this; var dd = { parent_sn: t, store_id: sto, type: 2, }; if (type == 1) dd.type = 1; n.post(this.url, { data: dd, success: function(t) { if(t.data.code==0){ i.weixinPay(t.data.data, e, a); }else{ getApp().confirmBox(t.data.msg); setTimeout(function(){ wx.redirectTo({ url: "/pages/user/order_list/order_list", }); },1000) } return false; }, fail: function() { "function" == typeof a && a(); }, failStatus: function() { "function" == typeof a && a(); } }); }, weixinPay: function(n, e, a) { if(!n) return false; //有的话用最新的支付方式 if(n.orderInfo) { wx.requestOrderPayment({ timeStamp: String(n.timeStamp), nonceStr: n.nonceStr, package: n.packageValue, signType: n.signType, paySign: n.paySign, orderInfo: n.orderInfo, // 需要新增的 订单 信息 success (n) { t.showSuccess("支付成功!", e); }, fail (n) { if(!n.errMsg ) { getApp().showWarning("支付失败"); "function" == typeof fail && fail(); return false; } console.log(n), "requestOrderPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestOrderPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : t.confirmBox("支付失败:" + n.errMsg.substr("requestOrderPayment:fail ".length)), "function" == typeof a && a(); } }) }else{ wx.requestPayment({ timeStamp: String(n.timeStamp), nonceStr: n.nonceStr, package: n.packageValue, signType: n.signType, paySign: n.paySign, success: function (n) { console.log(n), t.showSuccess("支付成功!", e); }, fail: function (n) { console.log(n), "requestPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : t.confirmBox("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)), "function" == typeof a && a(); } }); } } };