Commit a39c79bf3d206a2fa59fa5cf1cf0bf922f49f40b

Authored by yvan.ni
1 parent 1d8444cf

购买的优化

packageA/pages/cart2_ser/cart2_ser.js
@@ -9,6 +9,7 @@ var oo = t.globalData.setting, @@ -9,6 +9,7 @@ var oo = t.globalData.setting,
9 os = oo; 9 os = oo;
10 var regeneratorRuntime = require('../../../utils/runtime.js'); 10 var regeneratorRuntime = require('../../../utils/runtime.js');
11 var util_pay = require("../../../utils/pay.js"); 11 var util_pay = require("../../../utils/pay.js");
  12 +var t_pay = require("../../../utils/pay2.js");
12 13
13 Page({ 14 Page({
14 data: { 15 data: {
@@ -616,23 +617,13 @@ Page({ @@ -616,23 +617,13 @@ Page({
616 isclose: 0 617 isclose: 0
617 }); 618 });
618 619
619 - getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {  
620 - data: {  
621 - parentSn: data.data.order_sn,  
622 - store_id: oo.stoid  
623 - },  
624 - success: function(su) {  
625 -  
626 -  
627 - if(su.data.code==0) {  
628 -  
629 - var n = su.data.data;  
630 - // console.log('su---->', n);  
631 - let order_id = data.data.order_id;  
632 - th.weixinPay(n,  
633 - function () {  
634 - // getApp().showWarning("购买成功");  
635 - wx.showToast({ 620 + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder")
  621 + t_pay.pay(
  622 + {
  623 + parentSn: data.data.order_sn,
  624 + store_id: oo.stoid
  625 + },function (){
  626 + wx.showToast({
636 title: '购买成功', 627 title: '购买成功',
637 icon: 'success', 628 icon: 'success',
638 duration: 2000 629 duration: 2000
@@ -642,27 +633,62 @@ Page({ @@ -642,27 +633,62 @@ Page({
642 url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id, 633 url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id,
643 }) 634 })
644 }, 1000) 635 }, 1000)
645 - },  
646 - function () {  
647 - getApp().showWarning("支付失败");  
648 - setTimeout(function () {  
649 - wx.reLaunch({  
650 - url: "/pages/user/order_list/order_list?index=2&tabindex=1",  
651 - })  
652 - }, 1000)  
653 - })  
654 - }else{  
655 -  
656 - this.data.is_summit_ing = 0;  
657 636
658 - wx.showToast({  
659 - title: su.data.msg,  
660 - icon: 'none',  
661 - duration: 2000  
662 - });  
663 - }  
664 - }  
665 - }) 637 + },function (e){
  638 + wx.showToast({
  639 + title: e,
  640 + icon: 'none',
  641 + duration: 2000
  642 + });
  643 + }
  644 + )
  645 +
  646 + // getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {
  647 + // data: {
  648 + // parentSn: data.data.order_sn,
  649 + // store_id: oo.stoid
  650 + // },
  651 + // success: function(su) {
  652 + //
  653 + // if(su.data.code==0) {
  654 + //
  655 + // var n = su.data.data;
  656 + // // console.log('su---->', n);
  657 + // let order_id = data.data.order_id;
  658 + // th.weixinPay(n,
  659 + // function () {
  660 + // // getApp().showWarning("购买成功");
  661 + // wx.showToast({
  662 + // title: '购买成功',
  663 + // icon: 'success',
  664 + // duration: 2000
  665 + // });
  666 + // setTimeout(function () {
  667 + // wx.reLaunch({
  668 + // url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id,
  669 + // })
  670 + // }, 1000)
  671 + // },
  672 + // function () {
  673 + // getApp().showWarning("支付失败");
  674 + // setTimeout(function () {
  675 + // wx.reLaunch({
  676 + // url: "/pages/user/order_list/order_list?index=2&tabindex=1",
  677 + // })
  678 + // }, 1000)
  679 + // })
  680 + // }else{
  681 + //
  682 + // this.data.is_summit_ing = 0;
  683 + //
  684 + // wx.showToast({
  685 + // title: su.data.msg,
  686 + // icon: 'none',
  687 + // duration: 2000
  688 + // });
  689 + // }
  690 + // }
  691 + // })
666 } 692 }
667 } else { 693 } else {
668 th.data.is_summit_ing = 0; //是否提交中 694 th.data.is_summit_ing = 0; //是否提交中
packageA/pages/chongzhiDetails/chongzhiDetails.js
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 var util = require('../../../utils/util.js'); 2 var util = require('../../../utils/util.js');
3 const app = getApp(),os = app.globalData.setting; 3 const app = getApp(),os = app.globalData.setting;
4 var regeneratorRuntime = require('../../../utils/runtime.js'); 4 var regeneratorRuntime = require('../../../utils/runtime.js');
  5 +var t_pay = require("../../../utils/pay2.js");
5 6
6 Page({ 7 Page({
7 8
@@ -188,24 +189,38 @@ Page({ @@ -188,24 +189,38 @@ Page({
188 var msg = res.data.data; 189 var msg = res.data.data;
189 var parentSn = msg.order_sn; 190 var parentSn = msg.order_sn;
190 var store_id = os.stoid; 191 var store_id = os.stoid;
191 - getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {  
192 - data: {  
193 - parentSn: parentSn,  
194 - store_id: store_id  
195 - },  
196 - success: function (su) {  
197 - console.log("su是什么",su);  
198 - var n=su.data.data;  
199 - console.log("su是什么", su);  
200 -  
201 - e.weixinPay(n,  
202 - function () {  
203 - e.jumpPaymentPage();  
204 - }, function () {  
205 - getApp().showWarning("支付失败");  
206 - })  
207 - }  
208 - }) 192 +
  193 + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder");
  194 + t_pay.pay({
  195 + parentSn: parentSn,
  196 + store_id: store_id
  197 + }, function () {
  198 + e.jumpPaymentPage();
  199 + }, function (e) {
  200 + wx.showToast({
  201 + title: e,
  202 + icon: 'none',
  203 + duration: 2000
  204 + });
  205 + })
  206 + // getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {
  207 + // data: {
  208 + // parentSn: parentSn,
  209 + // store_id: store_id
  210 + // },
  211 + // success: function (su) {
  212 + // console.log("su是什么",su);
  213 + // var n=su.data.data;
  214 + // console.log("su是什么", su);
  215 + //
  216 + // e.weixinPay(n,
  217 + // function () {
  218 + // e.jumpPaymentPage();
  219 + // }, function () {
  220 + // getApp().showWarning("支付失败");
  221 + // })
  222 + // }
  223 + // })
209 }) 224 })
210 }, 225 },
211 //------支付成功页面-------- 226 //------支付成功页面--------
packageA/pages/details_serviceCard/details_serviceCard.js
1 // packageA/pages/details_serviceCard/details_serviceCard.js 1 // packageA/pages/details_serviceCard/details_serviceCard.js
  2 +var t_pay = require("../../../utils/pay2.js");
2 const app = getApp(); 3 const app = getApp();
3 const os = app.globalData.setting; 4 const os = app.globalData.setting;
4 let self = null; 5 let self = null;
@@ -497,32 +498,50 @@ Page({ @@ -497,32 +498,50 @@ Page({
497 let order_sn = this.data.details.order_sn; 498 let order_sn = this.data.details.order_sn;
498 let order_id = this.data.details.order_id; 499 let order_id = this.data.details.order_id;
499 let store_id = app.globalData.setting.stoid; 500 let store_id = app.globalData.setting.stoid;
  501 + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder");
  502 + t_pay.pay({
  503 + parentSn: order_sn,
  504 + store_id: store_id
  505 + }, function () {
  506 + app.showWarning('支付成功');
  507 + setTimeout(function() {
  508 + wx.reLaunch({
  509 + url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id,
  510 + })
  511 + }, 1000)
500 512
501 - app.request.post('/api/weshop/order/pay/createRechargeOrder', {  
502 - data: {  
503 - parentSn: order_sn,  
504 - store_id: store_id,  
505 - },  
506 -  
507 - success: function(res) {  
508 - var n = res.data.data;  
509 - self.weixinPay(n, function() {  
510 - app.showWarning('支付成功');  
511 - // setTimeout(function() {  
512 - // wx.reLaunch({  
513 - // url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id,  
514 - // })  
515 - // }, 1000)  
516 - }, function() {  
517 - app.showWarning('支付失败');  
518 - // setTimeout(function() {  
519 - // wx.reLaunch({  
520 - // url: '/packageA/pages/cardList/cardList',  
521 - // })  
522 - // }, 1000)  
523 - });  
524 - } 513 + }, function (e) {
  514 + wx.showToast({
  515 + title: e,
  516 + icon: 'none',
  517 + duration: 2000
  518 + });
525 }) 519 })
  520 + // app.request.post('/api/weshop/order/pay/createRechargeOrder', {
  521 + // data: {
  522 + // parentSn: order_sn,
  523 + // store_id: store_id,
  524 + // },
  525 + //
  526 + // success: function(res) {
  527 + // var n = res.data.data;
  528 + // self.weixinPay(n, function() {
  529 + // app.showWarning('支付成功');
  530 + // // setTimeout(function() {
  531 + // // wx.reLaunch({
  532 + // // url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id,
  533 + // // })
  534 + // // }, 1000)
  535 + // }, function() {
  536 + // app.showWarning('支付失败');
  537 + // // setTimeout(function() {
  538 + // // wx.reLaunch({
  539 + // // url: '/packageA/pages/cardList/cardList',
  540 + // // })
  541 + // // }, 1000)
  542 + // });
  543 + // }
  544 + // })
526 }, 545 },
527 546
528 547
packageD/pages/user/deposit/prepaid/prepaid.js
@@ -6,6 +6,8 @@ var t = getApp(), @@ -6,6 +6,8 @@ var t = getApp(),
6 ut = i, 6 ut = i,
7 s = require("../../../../../utils/common.js"); 7 s = require("../../../../../utils/common.js");
8 var regeneratorRuntime = require('../../../../../utils/runtime.js'); 8 var regeneratorRuntime = require('../../../../../utils/runtime.js');
  9 +var t_pay = require("../../../../../utils/pay2.js");
  10 +
9 Page({ 11 Page({
10 data: { 12 data: {
11 iurl: o.imghost, 13 iurl: o.imghost,
@@ -150,27 +152,41 @@ Page({ @@ -150,27 +152,41 @@ Page({
150 } 152 }
151 153
152 154
153 - var msg = res.data.data;  
154 - var parentSn = msg.order_sn;  
155 - var store_id = os.stoid;  
156 - getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {  
157 - data: {  
158 - parentSn: parentSn,  
159 - store_id: store_id  
160 - },  
161 - success: function (su) {  
162 - console.log("su是什么",su);  
163 - var n=su.data.data;  
164 - console.log("su是什么", su);  
165 -  
166 - e.weixinPay(n,  
167 - function () {  
168 - e.jumpPaymentPage();  
169 - }, function () {  
170 - getApp().showWarning("支付失败");  
171 - })  
172 - }  
173 - }) 155 + var msg = res.data.data;
  156 + var parentSn = msg.order_sn;
  157 + var store_id = os.stoid;
  158 + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder");
  159 + t_pay.pay({
  160 + parentSn: parentSn,
  161 + store_id: store_id
  162 + }, function () {
  163 + e.jumpPaymentPage();
  164 + }, function (e) {
  165 + wx.showToast({
  166 + title: e,
  167 + icon: 'none',
  168 + duration: 2000
  169 + });
  170 + })
  171 +
  172 + // getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {
  173 + // data: {
  174 + // parentSn: parentSn,
  175 + // store_id: store_id
  176 + // },
  177 + // success: function (su) {
  178 + // console.log("su是什么",su);
  179 + // var n=su.data.data;
  180 + // console.log("su是什么", su);
  181 + //
  182 + // e.weixinPay(n,
  183 + // function () {
  184 + // e.jumpPaymentPage();
  185 + // }, function () {
  186 + // getApp().showWarning("支付失败");
  187 + // })
  188 + // }
  189 + // })
174 }) 190 })
175 }, 191 },
176 //------支付成功页面-------- 192 //------支付成功页面--------
packageD/pages/user/integral/integral.js
@@ -6,6 +6,8 @@ var e = function (e) { @@ -6,6 +6,8 @@ var e = function (e) {
6 }(require("../../../../utils/LoadMore.js")), t = getApp(), a = t.request, o = t.globalData.setting, os = o, 6 }(require("../../../../utils/LoadMore.js")), t = getApp(), a = t.request, o = t.globalData.setting, os = o,
7 i = require("../../../../utils/util.js"), ut = i, b = require("../../../../app.js"), app = b, s = require("../../../../utils/common.js"), n = new e.default(); 7 i = require("../../../../utils/util.js"), ut = i, b = require("../../../../app.js"), app = b, s = require("../../../../utils/common.js"), n = new e.default();
8 var regeneratorRuntime = require('../../../../utils/runtime.js'); 8 var regeneratorRuntime = require('../../../../utils/runtime.js');
  9 +var t_pay = require("../../../../utils/pay2.js");
  10 +
9 Page({ 11 Page({
10 12
11 /** 13 /**
@@ -250,23 +252,37 @@ Page({ @@ -250,23 +252,37 @@ Page({
250 var msg = res.data.data; 252 var msg = res.data.data;
251 var parentSn = msg.order_sn; 253 var parentSn = msg.order_sn;
252 var store_id = os.stoid; 254 var store_id = os.stoid;
  255 +
  256 + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder");
  257 + t_pay.pay({
  258 + parentSn: parentSn,
  259 + store_id: store_id
  260 + }, function () {
  261 + th.jumpPaymentPage();
  262 + }, function (e) {
  263 + wx.showToast({
  264 + title: e,
  265 + icon: 'none',
  266 + duration: 2000
  267 + });
  268 + })
253 269
254 - getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {  
255 - data: {  
256 - parentSn: parentSn,  
257 - store_id: store_id  
258 - },  
259 - success: function (su) {  
260 - var n = su.data.data;  
261 - th.weixinPay(n,  
262 - function () {  
263 - console.log("支付成功页面2333");  
264 - th.jumpPaymentPage();  
265 - }, function () {  
266 - getApp().showWarning("支付失败");  
267 - })  
268 - }  
269 - }) 270 + // getApp().request.post("/api/weshop/order/pay/createRechargeOrder", {
  271 + // data: {
  272 + // parentSn: parentSn,
  273 + // store_id: store_id
  274 + // },
  275 + // success: function (su) {
  276 + // var n = su.data.data;
  277 + // th.weixinPay(n,
  278 + // function () {
  279 + // console.log("支付成功页面2333");
  280 + // th.jumpPaymentPage();
  281 + // }, function () {
  282 + // getApp().showWarning("支付失败");
  283 + // })
  284 + // }
  285 + // })
270 }) 286 })
271 }) 287 })
272 288
pages/giftpack/public/buy_com.js
@@ -253,26 +253,53 @@ module.exports = { @@ -253,26 +253,53 @@ module.exports = {
253 var order_sn = res.data.data.orderSn; 253 var order_sn = res.data.data.orderSn;
254 res = res.data.data.result; 254 res = res.data.data.result;
255 if (!res) return false; 255 if (!res) return false;
  256 +
256 var money=that.data.payMoney; 257 var money=that.data.payMoney;
257 var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn; 258 var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn;
258 -  
259 getApp().globalData.no_clear=1; 259 getApp().globalData.no_clear=1;
260 260
261 - wx.requestPayment({  
262 - timeStamp: String(res.timeStamp),  
263 - nonceStr: res.nonceStr,  
264 - package: res.packageValue,  
265 - signType: res.signType,  
266 - paySign: res.paySign,  
267 - success: function (res) { 261 + //--- 如果是富友支付的时候 --
  262 + if(t.data.data.is_fuioupay){
  263 + const plugin = requirePlugin('fuiou-pay')
  264 +
  265 + var paramsJson={
  266 + reqType:"11",//必填 01-商户模式,11-机构模式
  267 + reqData:t.data.data.reqData,//必填 富友加密参数
  268 + }
  269 + console.log(plugin, plugin.fuioupay)
  270 + plugin.fuioupay(parseInt(t.data.data.amt),paramsJson,function (res){
268 th.setData({submit:0}) 271 th.setData({submit:0})
269 getApp().goto(url); 272 getApp().goto(url);
270 - },  
271 - fail: function (res) { 273 + },function (error){
  274 + console.log("插件支付错误",error);
  275 + //支付失败的时候
  276 + //getApp().confirmBox(error.code+error.message);
  277 + //fail(error.code+":"+error.message)
  278 + //wx_paying=0;
272 th.setData({submit:0}) 279 th.setData({submit:0})
273 - getApp().my_warnning("取消支付", 0, th);  
274 - }  
275 - }); 280 + getApp().my_warnning(error.code+":"+error.message, 0, th);
  281 +
  282 + })
  283 + }else{
  284 + wx.requestPayment({
  285 + timeStamp: String(res.timeStamp),
  286 + nonceStr: res.nonceStr,
  287 + package: res.packageValue,
  288 + signType: res.signType,
  289 + paySign: res.paySign,
  290 + success: function (res) {
  291 + th.setData({submit:0})
  292 + getApp().goto(url);
  293 + },
  294 + fail: function (res) {
  295 + th.setData({submit:0})
  296 + getApp().my_warnning("取消支付", 0, th);
  297 + }
  298 + });
  299 + }
  300 +
  301 +
  302 +
276 break; 303 break;
277 case 3://立即领取 304 case 3://立即领取
278 th.setData({submit:0}) 305 th.setData({submit:0})
pages/user/order_list/order_list.js
@@ -15,6 +15,7 @@ var t = function (t) { @@ -15,6 +15,7 @@ var t = function (t) {
15 var regeneratorRuntime = require('../../../utils/runtime.js'); 15 var regeneratorRuntime = require('../../../utils/runtime.js');
16 var ut = require('../../../utils/util.js'); 16 var ut = require('../../../utils/util.js');
17 var t = require("../../../utils/pay.js"); 17 var t = require("../../../utils/pay.js");
  18 +var t_pay = require("../../../utils/pay2.js");
18 19
19 Page({ 20 Page({
20 data: { 21 data: {
@@ -2591,29 +2592,47 @@ Page({ @@ -2591,29 +2592,47 @@ Page({
2591 2592
2592 2593
2593 if (flag) { 2594 if (flag) {
2594 - await app.request.promisePost('/api/weshop/order/pay/createRechargeOrder', {  
2595 - data: {  
2596 - parentSn: order_sn,  
2597 - store_id: store_id,  
2598 - },  
2599 - }).then(res => {  
2600 - // success: function(res) {  
2601 - var n = res.data.data;  
2602 - self.weixinPay(n, function () {  
2603 - app.showWarning('支付成功');  
2604 -  
2605 - }, function () {  
2606 - app.showWarning('支付失败');  
2607 - // setTimeout(function() {  
2608 - // wx.reLaunch({  
2609 - // url: '/packageA/pages/cardList/cardList',  
2610 - // })  
2611 - // }, 1000) 2595 +
  2596 + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder");
  2597 + t_pay.pay({
  2598 + parentSn: order_sn,
  2599 + store_id: store_id
  2600 + }, function () {
  2601 + wx.showToast({
  2602 + title: '支付成功',
  2603 + icon:'success',
  2604 + duration: 2000
2612 }); 2605 });
2613 - // }  
2614 - });  
2615 - }; 2606 + }, function (e) {
  2607 + wx.showToast({
  2608 + title: e,
  2609 + icon: 'none',
  2610 + duration: 2000
  2611 + });
  2612 + })
2616 2613
  2614 + // await app.request.promisePost('/api/weshop/order/pay/createRechargeOrder', {
  2615 + // data: {
  2616 + // parentSn: order_sn,
  2617 + // store_id: store_id,
  2618 + // },
  2619 + // }).then(res => {
  2620 + // // success: function(res) {
  2621 + // var n = res.data.data;
  2622 + // self.weixinPay(n, function () {
  2623 + // app.showWarning('支付成功');
  2624 + //
  2625 + // }, function () {
  2626 + // app.showWarning('支付失败');
  2627 + // // setTimeout(function() {
  2628 + // // wx.reLaunch({
  2629 + // // url: '/packageA/pages/cardList/cardList',
  2630 + // // })
  2631 + // // }, 1000)
  2632 + // });
  2633 + // // }
  2634 + // });
  2635 + };
2617 2636
2618 }, 2637 },
2619 2638
utils/pay2.js
@@ -2,16 +2,13 @@ var t = getApp(), n = t.request,wx_paying=0; @@ -2,16 +2,13 @@ var t = getApp(), n = t.request,wx_paying=0;
2 2
3 module.exports = { 3 module.exports = {
4 url: "/api/weshop/plus/create/plus/order", 4 url: "/api/weshop/plus/create/plus/order",
  5 + set_pay_url:function (url){
  6 + this.url=url;//让链接地址进行赋值
  7 + },
  8 + //-- createRechargeOrder create/plus/order --
5 pay: function(dd, succ,fail) { 9 pay: function(dd, succ,fail) {
6 -  
7 if(wx_paying) return false; 10 if(wx_paying) return false;
8 wx_paying=1; 11 wx_paying=1;
9 -  
10 - if(getApp().globalData.scene)  
11 - dd.scene=getApp().globalData.scene;  
12 -  
13 - console.log(dd,'支付场景');  
14 -  
15 wx.showLoading(); 12 wx.showLoading();
16 var i = this; 13 var i = this;
17 n.post(this.url, { 14 n.post(this.url, {
@@ -22,9 +19,31 @@ module.exports = { @@ -22,9 +19,31 @@ module.exports = {
22 if(t.data.data=="升级成功"){ 19 if(t.data.data=="升级成功"){
23 "function" == typeof succ && succ(1); 20 "function" == typeof succ && succ(1);
24 }else{ 21 }else{
25 - i.weixinPay(t.data.data, succ,fail); 22 + if(t.data.data.is_fuioupay){
  23 + const plugin = requirePlugin('fuiou-pay')
  24 +
  25 + var paramsJson={
  26 + reqType:"11",//必填 01-商户模式,11-机构模式
  27 + reqData:t.data.data.reqData,//必填 富友加密参数
  28 + }
  29 + console.log(plugin, plugin.fuioupay)
  30 + plugin.fuioupay(parseInt(t.data.data.amt),paramsJson,function (res){
  31 + console.log(res);
  32 + wx_paying=0;
  33 + "function" == typeof succ && succ();
  34 + },function (error){
  35 + console.log("插件支付错误",error);
  36 + //支付失败的时候
  37 + //getApp().confirmBox(error.code+error.message);
  38 + fail(error.code+":"+error.message)
  39 + wx_paying=0;
  40 + })
  41 + }else {
  42 + i.weixinPay(t.data.data, succ, fail);
  43 + }
26 } 44 }
27 }else{ 45 }else{
  46 + wx_paying=0;
28 "function" == typeof fail && fail(); 47 "function" == typeof fail && fail();
29 } 48 }
30 return false; 49 return false;
@@ -41,6 +60,7 @@ module.exports = { @@ -41,6 +60,7 @@ module.exports = {
41 } 60 }
42 }); 61 });
43 }, 62 },
  63 +
44 weixinPay: function(n, succ,fail) { 64 weixinPay: function(n, succ,fail) {
45 if(!n) return false; 65 if(!n) return false;
46 66
@@ -58,7 +78,14 @@ module.exports = { @@ -58,7 +78,14 @@ module.exports = {
58 }, 78 },
59 fail: function(n) { 79 fail: function(n) {
60 wx_paying=0; 80 wx_paying=0;
61 - "function" == typeof fail && fail(); 81 + var msg='';
  82 + switch (n.errMsg){
  83 + case "requestPayment:fail": msg="支付失败";break;
  84 + case "requestPayment:fail cancel": msg="您已取消支付";break;
  85 + default: msg="支付失败:" + n.errMsg.substr("requestPayment:fail ".length);
  86 + }
  87 + console.log(n);
  88 + "function" == typeof fail && fail(msg);
62 } 89 }
63 }); 90 });
64 } 91 }