Commit 5637d9a50332a8731f3c841601ede64ef40ac7e6
1 parent
d3e96f6d
支付的优化
Showing
8 changed files
with
161 additions
and
58 deletions
packageA/pages/cart2_ser/cart2_ser.js
| ... | ... | @@ -3,7 +3,7 @@ var t = getApp(), |
| 3 | 3 | a = t.request, |
| 4 | 4 | e = require("../../../utils/common.js"), |
| 5 | 5 | s = require("../../../utils/util.js"), |
| 6 | - o = require("../../../utils/md5.js"), | |
| 6 | + ut=s, o = require("../../../utils/md5.js"), | |
| 7 | 7 | to = getApp(); |
| 8 | 8 | var oo = t.globalData.setting, |
| 9 | 9 | os = oo; |
| ... | ... | @@ -49,6 +49,10 @@ Page({ |
| 49 | 49 | is_cart: 0, //是不是购物车进来的购买 |
| 50 | 50 | }, |
| 51 | 51 | onLoad: function(t) { |
| 52 | + | |
| 53 | + //定义第一次进入 | |
| 54 | + this.data.fir_in=1; | |
| 55 | + | |
| 52 | 56 | wx.setNavigationBarTitle({ |
| 53 | 57 | title: "填写订单", |
| 54 | 58 | }); |
| ... | ... | @@ -274,11 +278,47 @@ Page({ |
| 274 | 278 | |
| 275 | 279 | //----------子页返回父页触发---------- |
| 276 | 280 | onShow: function() { |
| 277 | - var fy=s.fy_back("/pages/user/order_list/order_list?index=2&tabindex=1",1); | |
| 278 | - if(fy) return false; | |
| 279 | 281 | |
| 280 | - t_pay.set_fir(); | |
| 281 | 282 | var th = this; |
| 283 | + | |
| 284 | + //判断是不是第一次进入 | |
| 285 | + if(this.data.fir_in){ | |
| 286 | + this.data.fir_in=0; | |
| 287 | + }else{ | |
| 288 | + var fy=s.fy_back("/pages/user/order_list/order_list?index=2&tabindex=1",1); | |
| 289 | + if(fy) return false; | |
| 290 | + t_pay.set_fir(); | |
| 291 | + | |
| 292 | + var back_url="/pages/payment/pay_success/pay_success?card=1&order_id=" + th.data.order_id; | |
| 293 | + //-- 通联的第三方支付的返回优化 -- | |
| 294 | + ut.is_pay_ok(back_url,"/pages/user/order_list/order_list?index=2&tabindex=1",function (){ | |
| 295 | + | |
| 296 | + if(!th.data.order_id) return false; | |
| 297 | + getApp().request.promiseGet("/api/weshop/recharge/user/page", | |
| 298 | + {data:{store_id:os.stoid,order_id:th.data.order_id,user_id:getApp().globalData.user_id }}).then(res=>{ | |
| 299 | + if(ut.ajax_ok(res)){ | |
| 300 | + var item=res.data.data.pageData[0]; | |
| 301 | + if(item.pay_status==1){ | |
| 302 | + //支付支付,返回首页 | |
| 303 | + ut.m_toast('支付成功'); | |
| 304 | + setTimeout(()=>{ | |
| 305 | + getApp().re_to(back_url); | |
| 306 | + },1000) | |
| 307 | + | |
| 308 | + }else{ | |
| 309 | + //支付支付,返回首页 | |
| 310 | + ut.m_toast('支付失败'); | |
| 311 | + setTimeout(()=>{ | |
| 312 | + getApp().re_to("/pages/user/order_list/order_list?index=2&tabindex=1"); | |
| 313 | + },1000) | |
| 314 | + } | |
| 315 | + } | |
| 316 | + }) | |
| 317 | + }); | |
| 318 | + | |
| 319 | + } | |
| 320 | + | |
| 321 | + | |
| 282 | 322 | if (th.data.isclose == 0) { |
| 283 | 323 | wx.navigateTo({ |
| 284 | 324 | url: "/pages/index/index/index" | ... | ... |
packageA/pages/myGift/myGift.js
| ... | ... | @@ -108,7 +108,7 @@ Page({ |
| 108 | 108 | t_pay.set_fir(); |
| 109 | 109 | |
| 110 | 110 | //-- 通联的第三方支付的返回优化 -- |
| 111 | - ut.is_pay_ok("none","none",function (){ | |
| 111 | + util.is_pay_ok("none","none",function (){ | |
| 112 | 112 | if(!th.data.ok_order_sn) return false; |
| 113 | 113 | getApp().request.promiseGet("/api/weshop/order/page", |
| 114 | 114 | {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ |
| ... | ... | @@ -116,10 +116,10 @@ Page({ |
| 116 | 116 | var item=res.data.data.pageData[0]; |
| 117 | 117 | if(item.pay_status==1){ |
| 118 | 118 | //支付支付,返回首页 |
| 119 | - ut.m_toast('支付成功'); | |
| 119 | + util.m_toast('支付成功'); | |
| 120 | 120 | }else{ |
| 121 | 121 | //支付支付,返回首页 |
| 122 | - ut.m_toast('支付失败'); | |
| 122 | + util.m_toast('支付失败'); | |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | }) |
| ... | ... | @@ -342,14 +342,7 @@ Page({ |
| 342 | 342 | },function (e){ |
| 343 | 343 | th.data.is_summit_ing=0; |
| 344 | 344 | getApp().my_warnning(e, 0, th); |
| 345 | - },function (ordno){ | |
| 346 | - if(ordno.indexOf('_')){ | |
| 347 | - var str_arr=ordno.split('_'); | |
| 348 | - ordno=str_arr[0]; | |
| 349 | - } | |
| 350 | - th.data.ok_order_sn=ordno; | |
| 351 | - | |
| 352 | - }) | |
| 345 | + },th) | |
| 353 | 346 | // var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; |
| 354 | 347 | // getApp().request.post(url, |
| 355 | 348 | // { | ... | ... |
packageA/pages/serviceCard_pd/cart/cart.js
| 1 | 1 | var t = getApp(), app = t, a = t.request, e = require("../../../../utils/common.js"), |
| 2 | - s = require("../../../../utils/util.js"), o = require("../../../../utils/md5.js"), to = getApp(); | |
| 2 | + s = require("../../../../utils/util.js"),ut=s, o = require("../../../../utils/md5.js"), to = getApp(); | |
| 3 | 3 | var oo = t.globalData.setting, os = oo; |
| 4 | 4 | var regeneratorRuntime = require('../../../../utils/runtime.js'); |
| 5 | 5 | var util_pay = require("../../../../utils/pay.js"); |
| ... | ... | @@ -71,7 +71,8 @@ Page({ |
| 71 | 71 | }, |
| 72 | 72 | onLoad: function (t) { |
| 73 | 73 | console.log("onLoad_pt_cart"); |
| 74 | - | |
| 74 | + //定义第一次进入 | |
| 75 | + this.data.fir_in=1; | |
| 75 | 76 | |
| 76 | 77 | var th = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); |
| 77 | 78 | var appD = getApp().get_b_now(); |
| ... | ... | @@ -245,12 +246,45 @@ Page({ |
| 245 | 246 | //----------子页返回父页触发---------- |
| 246 | 247 | onShow: function () { |
| 247 | 248 | |
| 248 | - s.fy_back('',0); | |
| 249 | + var th = this; | |
| 250 | + //判断是不是第一次进入 | |
| 251 | + if(this.data.fir_in){ | |
| 252 | + this.data.fir_in=0; | |
| 253 | + }else{ | |
| 254 | + s.fy_back('',0); | |
| 255 | + t_pay.set_fir(); | |
| 256 | + util_pay.set_fir(); | |
| 257 | + | |
| 258 | + var back_url="/packageA/pages/serviceCard_pd/team_success/team_success?ordersn=" + th.data.order_sn; | |
| 259 | + | |
| 260 | + //-- 通联的第三方支付的返回优化 -- | |
| 261 | + ut.is_pay_ok(back_url,"/pages/user/order_list/order_list?index=2&tabindex=1",function (){ | |
| 262 | + if(!th.data.order_id) return false; | |
| 263 | + getApp().request.promiseGet("/api/weshop/rechargeServicelist/page",{ | |
| 264 | + data: { store_id: os.stoid, order_id: th.data.order_id} | |
| 265 | + }).then(res=>{ | |
| 266 | + if(ut.ajax_ok(res)){ | |
| 267 | + var item=res.data.data.pageData[0]; | |
| 268 | + if(item.pt_status==1 || item.pt_status==2){ | |
| 269 | + //支付支付,返回首页 | |
| 270 | + ut.m_toast('支付成功'); | |
| 271 | + setTimeout(()=>{ | |
| 272 | + getApp().re_to(back_url); | |
| 273 | + },1000) | |
| 274 | + | |
| 275 | + }else{ | |
| 276 | + //支付支付,返回首页 | |
| 277 | + ut.m_toast('支付失败'); | |
| 278 | + setTimeout(()=>{ | |
| 279 | + getApp().re_to("/pages/user/order_list/order_list?index=2&tabindex=1"); | |
| 280 | + },1000) | |
| 281 | + } | |
| 282 | + } | |
| 283 | + }) | |
| 284 | + }); | |
| 285 | + } | |
| 249 | 286 | |
| 250 | - t_pay.set_fir(); | |
| 251 | - util_pay.set_fir(); | |
| 252 | 287 | |
| 253 | - var th = this; | |
| 254 | 288 | if (th.data.isclose == 0) { |
| 255 | 289 | wx.navigateTo({ |
| 256 | 290 | url: "/pages/index/index/index" | ... | ... |
packageA/pages/serviceCard_pd/cart_wk/cart_wk.js
| ... | ... | @@ -59,6 +59,8 @@ Page({ |
| 59 | 59 | * 生命周期函数--监听页面加载 |
| 60 | 60 | */ |
| 61 | 61 | onLoad: function (options) { |
| 62 | + //定义第一次进入 | |
| 63 | + this.data.fir_in=1; | |
| 62 | 64 | |
| 63 | 65 | //清空is_pick_up |
| 64 | 66 | getApp().request.put("/api/weshop/useraddress/updatePickUp", { |
| ... | ... | @@ -94,11 +96,49 @@ Page({ |
| 94 | 96 | */ |
| 95 | 97 | onShow: function () { |
| 96 | 98 | |
| 97 | - ut.fy_back('',0); | |
| 98 | 99 | this.data.paying=0; |
| 99 | - util_pay.set_fir(); | |
| 100 | - getApp().check_can_share(); | |
| 100 | + | |
| 101 | 101 | var th = this; |
| 102 | + //判断是不是第一次进入 | |
| 103 | + if(this.data.fir_in){ | |
| 104 | + this.data.fir_in=0; | |
| 105 | + }else{ | |
| 106 | + ut.fy_back('',0); | |
| 107 | + util_pay.set_fir(); | |
| 108 | + | |
| 109 | + | |
| 110 | + var back_url="/pages/payment/pay_success/pay_success?order_id=" + th.data.order.order_id + "&type=1&card=1"; | |
| 111 | + //-- 通联的第三方支付的返回优化 -- | |
| 112 | + ut.is_pay_ok(back_url,"/pages/user/order_list/order_list?index=2&tabindex=1",function (){ | |
| 113 | + if(!th.data.wk_pyed) return false; | |
| 114 | + getApp().request.promiseGet("/api/weshop/rechargeServicelist/page",{ | |
| 115 | + data: { store_id: os.stoid, order_id: th.data.order.order_id} | |
| 116 | + }).then(res=>{ | |
| 117 | + if(ut.ajax_ok(res)){ | |
| 118 | + var item=res.data.data.pageData[0]; | |
| 119 | + if(item.pt_status==4 || item.pt_status==5){ | |
| 120 | + //支付支付,返回首页 | |
| 121 | + ut.m_toast('支付成功'); | |
| 122 | + setTimeout(()=>{ | |
| 123 | + getApp().re_to(back_url); | |
| 124 | + },1000) | |
| 125 | + | |
| 126 | + }else{ | |
| 127 | + //支付支付,返回首页 | |
| 128 | + ut.m_toast('支付失败'); | |
| 129 | + setTimeout(()=>{ | |
| 130 | + getApp().re_to("/pages/user/order_list/order_list?index=2&tabindex=1"); | |
| 131 | + },1000) | |
| 132 | + } | |
| 133 | + } | |
| 134 | + }) | |
| 135 | + }); | |
| 136 | + | |
| 137 | + } | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + getApp().check_can_share(); | |
| 102 | 142 | if (th.data.isclose == 0) { |
| 103 | 143 | wx.navigateTo({ |
| 104 | 144 | url: "/pages/index/index/index" |
| ... | ... | @@ -606,6 +646,7 @@ Page({ |
| 606 | 646 | return false; |
| 607 | 647 | } |
| 608 | 648 | |
| 649 | + th.data.wk_pyed=1; | |
| 609 | 650 | util_pay.pay_data(t,function (){ |
| 610 | 651 | var allmoney = th.data.allpice; |
| 611 | 652 | th.jumpPaymentPage(th.data.order.order_id, allmoney); | ... | ... |
packageE/pages/user/cardinfo/cardinfo.js
| ... | ... | @@ -845,14 +845,7 @@ Page({ |
| 845 | 845 | t_pay.pay(req, th.success, function (e) { |
| 846 | 846 | th.data.paying=0; |
| 847 | 847 | getApp().my_warnning("支付失败", 0, th); |
| 848 | - },function (ordno){ | |
| 849 | - if(ordno.indexOf('_')){ | |
| 850 | - var str_arr=ordno.split('_'); | |
| 851 | - ordno=str_arr[0]; | |
| 852 | - } | |
| 853 | - | |
| 854 | - th.data.ok_order_sn=ordno; | |
| 855 | - }); | |
| 848 | + },th); | |
| 856 | 849 | |
| 857 | 850 | }, |
| 858 | 851 | |
| ... | ... | @@ -923,7 +916,7 @@ Page({ |
| 923 | 916 | t_pay.pay(req, th.success, function () { |
| 924 | 917 | th.data.paying=0; |
| 925 | 918 | getApp().my_warnning("支付失败", 0, th); |
| 926 | - }); | |
| 919 | + },th); | |
| 927 | 920 | }, |
| 928 | 921 | //显示弹出框 |
| 929 | 922 | show_change:function () { this.setData({is_show_change_pop:1}); }, | ... | ... |
pages/giftpack/buygiftpack/giftpackbuy.js
| ... | ... | @@ -165,7 +165,7 @@ Page({ |
| 165 | 165 | if(!th.data.ok_order_sn) return false; |
| 166 | 166 | getApp().request.promiseGet("/api/weshop/marketing/my/giftbag/detail/get", |
| 167 | 167 | {data:{storeId:os.stoid,orderSn:th.data.ok_order_sn,userId:getApp().globalData.user_id}}).then(res=>{ |
| 168 | - | |
| 168 | + | |
| 169 | 169 | th.data.ok_order_sn=null; |
| 170 | 170 | |
| 171 | 171 | if(res.data.code==0 && res.data.data){ | ... | ... |
pages/user/plus/plus.js
| ... | ... | @@ -140,16 +140,18 @@ Page({ |
| 140 | 140 | if(this.data.fir_in){ |
| 141 | 141 | this.data.fir_in=0; |
| 142 | 142 | }else{ |
| 143 | - //富友插件支付 | |
| 144 | - ut.fy_back('',0); | |
| 145 | - t_pay.set_fir(); | |
| 146 | - //-- 通联的第三方支付的返回优化 -- | |
| 147 | - ut.is_pay_ok("func","func",function (){ | |
| 143 | + //富友插件支付 | |
| 144 | + ut.fy_back('',0); | |
| 145 | + t_pay.set_fir(); | |
| 146 | + //-- 通联的第三方支付的返回优化 -- | |
| 147 | + ut.is_pay_ok("func","func",function (){ | |
| 148 | + | |
| 148 | 149 | if(!th.data.ok_order_sn) return false; |
| 149 | - getApp().request.promiseGet("/api/weshop/order/page", | |
| 150 | - {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ | |
| 151 | - if(ut.ajax_ok(res)){ | |
| 152 | - var item=res.data.data.pageData[0]; | |
| 150 | + var ck_url="/api/weshop/recharge/get/"+os.stoid+"/"+th.data.ok_order_sn; | |
| 151 | + getApp().request.promiseGet(ck_url,{}).then(res=>{ | |
| 152 | + | |
| 153 | + if(res.data.code==0 && res.data.data){ | |
| 154 | + var item=res.data.data; | |
| 153 | 155 | if(item.pay_status==1){ |
| 154 | 156 | //支付支付,返回首页 |
| 155 | 157 | th.success() |
| ... | ... | @@ -162,7 +164,7 @@ Page({ |
| 162 | 164 | focus:true, |
| 163 | 165 | }) |
| 164 | 166 | } |
| 165 | - } | |
| 167 | + } | |
| 166 | 168 | }) |
| 167 | 169 | }, //成功的回调 |
| 168 | 170 | function (){ |
| ... | ... | @@ -240,9 +242,9 @@ Page({ |
| 240 | 242 | var userInfo = e.data.data; |
| 241 | 243 | if (userInfo['card_field'] && !getApp().globalData.is_card_back) { |
| 242 | 244 | var u_url = "/packageE/pages/user/cardinfo/cardinfo"; |
| 243 | - wx.reLaunch({ | |
| 244 | - url: u_url | |
| 245 | - }) | |
| 245 | + // wx.reLaunch({ | |
| 246 | + // url: u_url | |
| 247 | + // }) | |
| 246 | 248 | } |
| 247 | 249 | }, |
| 248 | 250 | }); |
| ... | ... | @@ -520,7 +522,7 @@ Page({ |
| 520 | 522 | is_select:0, |
| 521 | 523 | focus:true, |
| 522 | 524 | }) |
| 523 | - }); | |
| 525 | + },th); | |
| 524 | 526 | } |
| 525 | 527 | }, |
| 526 | 528 | //返回会员页面 |
| ... | ... | @@ -555,13 +557,7 @@ Page({ |
| 555 | 557 | is_select:0, |
| 556 | 558 | focus:true, |
| 557 | 559 | }) |
| 558 | - },function (ordno){ | |
| 559 | - if(ordno.indexOf('_')){ | |
| 560 | - var str_arr=ordno.split('_'); | |
| 561 | - ordno=str_arr[0]; | |
| 562 | - } | |
| 563 | - th.data.ok_order_sn=ordno; | |
| 564 | - }); | |
| 560 | + },th); | |
| 565 | 561 | } |
| 566 | 562 | } else { |
| 567 | 563 | getApp().my_warnning(res.data.msg, 0, th); | ... | ... |
utils/pay2.js
| ... | ... | @@ -11,7 +11,7 @@ module.exports = { |
| 11 | 11 | }, |
| 12 | 12 | //-- createRechargeOrder create/plus/order -- |
| 13 | 13 | // get_order是通联专用,获取订单号 |
| 14 | - pay: function(dd, succ,fail,get_order) { | |
| 14 | + pay: function(dd, succ,fail,th) { | |
| 15 | 15 | if(this.wx_paying) return false; |
| 16 | 16 | this.wx_paying=1; |
| 17 | 17 | wx.showLoading(); |
| ... | ... | @@ -59,8 +59,14 @@ module.exports = { |
| 59 | 59 | var p_data=t.data.data; |
| 60 | 60 | delete p_data.is_pos_pay; //清理掉,不然签名不通过 |
| 61 | 61 | |
| 62 | - if(get_order){ | |
| 63 | - get_order(p_data.reqsn); //把单号返回 | |
| 62 | + if(th){ | |
| 63 | + | |
| 64 | + var ordno=p_data.reqsn; | |
| 65 | + if(ordno.indexOf('_')){ | |
| 66 | + var str_arr=ordno.split('_'); | |
| 67 | + ordno=str_arr[0]; | |
| 68 | + } | |
| 69 | + th.data.ok_order_sn=ordno; | |
| 64 | 70 | } |
| 65 | 71 | |
| 66 | 72 | wx.openEmbeddedMiniProgram({ | ... | ... |