Commit 8d0c5060bf1bdf87c8e3492e15f6ad56f5c6b84d

Authored by yvan.ni
1 parent 21dae003

取消支付的优化

Showing 2 changed files with 23 additions and 4 deletions
utils/pay.js
@@ -47,6 +47,7 @@ module.exports = { @@ -47,6 +47,7 @@ module.exports = {
47 47
48 if(t.data.data.is_fuioupay){ 48 if(t.data.data.is_fuioupay){
49 const plugin = requirePlugin('fuiou-pay') 49 const plugin = requirePlugin('fuiou-pay')
  50 + getApp().globalData.no_clear=1;
50 51
51 var paramsJson={ 52 var paramsJson={
52 reqType:"11",//必填 01-商户模式,11-机构模式 53 reqType:"11",//必填 01-商户模式,11-机构模式
@@ -61,7 +62,13 @@ module.exports = { @@ -61,7 +62,13 @@ module.exports = {
61 },function (error){ 62 },function (error){
62 console.log("插件支付错误",error); 63 console.log("插件支付错误",error);
63 //支付失败的时候 64 //支付失败的时候
64 - getApp().confirmBox(error.code+error.message); 65 +
  66 + var msg='取消支付';
  67 + if(error.code){
  68 + msg=error.code+":"+error.message;
  69 + }
  70 + getApp().confirmBox(msg);
  71 +
65 setTimeout(function(){ 72 setTimeout(function(){
66 wx.redirectTo({ 73 wx.redirectTo({
67 url: "/pages/user/order_list/order_list", 74 url: "/pages/user/order_list/order_list",
utils/pay2.js
@@ -19,8 +19,10 @@ module.exports = { @@ -19,8 +19,10 @@ module.exports = {
19 if(t.data.data=="升级成功"){ 19 if(t.data.data=="升级成功"){
20 "function" == typeof succ && succ(1); 20 "function" == typeof succ && succ(1);
21 }else{ 21 }else{
  22 +
22 if(t.data.data.is_fuioupay){ 23 if(t.data.data.is_fuioupay){
23 const plugin = requirePlugin('fuiou-pay') 24 const plugin = requirePlugin('fuiou-pay')
  25 + getApp().globalData.no_clear=1;
24 26
25 var paramsJson={ 27 var paramsJson={
26 reqType:"11",//必填 01-商户模式,11-机构模式 28 reqType:"11",//必填 01-商户模式,11-机构模式
@@ -35,7 +37,11 @@ module.exports = { @@ -35,7 +37,11 @@ module.exports = {
35 console.log("插件支付错误",error); 37 console.log("插件支付错误",error);
36 //支付失败的时候 38 //支付失败的时候
37 //getApp().confirmBox(error.code+error.message); 39 //getApp().confirmBox(error.code+error.message);
38 - fail(error.code+":"+error.message) 40 + var msg='取消支付';
  41 + if(error.code){
  42 + msg=error.code+":"+error.message;
  43 + }
  44 + fail(msg)
39 wx_paying=0; 45 wx_paying=0;
40 }) 46 })
41 }else { 47 }else {
@@ -75,17 +81,23 @@ module.exports = { @@ -75,17 +81,23 @@ module.exports = {
75 reqType:"11",//必填 01-商户模式,11-机构模式 81 reqType:"11",//必填 01-商户模式,11-机构模式
76 reqData:ob.reqData,//必填 富友加密参数 82 reqData:ob.reqData,//必填 富友加密参数
77 } 83 }
  84 + getApp().globalData.no_clear=1;
78 console.log(plugin, plugin.fuioupay) 85 console.log(plugin, plugin.fuioupay)
79 plugin.fuioupay(parseInt(ob.amt),paramsJson,function (res){ 86 plugin.fuioupay(parseInt(ob.amt),paramsJson,function (res){
80 console.log(res); 87 console.log(res);
81 wx_paying=0; 88 wx_paying=0;
82 "function" == typeof succ && succ(); 89 "function" == typeof succ && succ();
83 },function (error){ 90 },function (error){
  91 + wx_paying=0;
84 console.log("插件支付错误",error); 92 console.log("插件支付错误",error);
85 //支付失败的时候 93 //支付失败的时候
86 //getApp().confirmBox(error.code+error.message); 94 //getApp().confirmBox(error.code+error.message);
87 - fail(error.code+":"+error.message)  
88 - wx_paying=0; 95 + var msg='取消支付';
  96 + if(error && error.code){
  97 + msg=error.code+":"+error.message;
  98 + }
  99 + fail(msg)
  100 +
89 }) 101 })
90 }else { 102 }else {
91 this.weixinPay(ob, succ, fail); 103 this.weixinPay(ob, succ, fail);