Commit 0904f37f2c7b62a3a165c023d8293771c259acf3
1 parent
da5d0c0f
pos收银支付的优化
Showing
13 changed files
with
85 additions
and
42 deletions
packageC/pages/presell/cart/cart2.js
| ... | ... | @@ -213,7 +213,7 @@ Page({ |
| 213 | 213 | util_pay.set_fir(); |
| 214 | 214 | |
| 215 | 215 | //-- 通联的第三方支付的返回优化 -- |
| 216 | - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ | |
| 216 | + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,'none',function (){ | |
| 217 | 217 | if(!th.data.ok_order_sn) return false; |
| 218 | 218 | getApp().request.promiseGet("/api/weshop/order/page", |
| 219 | 219 | {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ | ... | ... |
packageD/pages/user/deposit/prepaid/msg/msg.js
packageD/pages/user/deposit/prepaid/prepaid.js
| ... | ... | @@ -205,7 +205,7 @@ Page({ |
| 205 | 205 | var store_id = os.stoid; |
| 206 | 206 | t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); |
| 207 | 207 | |
| 208 | - th.data.ok_order_sn=parentSn; | |
| 208 | + e.data.ok_order_sn=parentSn; | |
| 209 | 209 | t_pay.pay({ |
| 210 | 210 | parentSn: parentSn, |
| 211 | 211 | store_id: store_id | ... | ... |
packageD/pages/user/integral/integral.js
| ... | ... | @@ -345,7 +345,7 @@ Page({ |
| 345 | 345 | t_pay.set_fir(); |
| 346 | 346 | |
| 347 | 347 | //-- 通联的第三方支付的返回优化 -- |
| 348 | - ut.is_pay_ok("/packageD/pages/user/deposit/prepaid/msg/msg",null,function (){ | |
| 348 | + ut.is_pay_ok("/packageD/pages/user/integral/msg/msg",'none',function (){ | |
| 349 | 349 | |
| 350 | 350 | console.log('show--11') |
| 351 | 351 | console.log(th.data.ok_order_sn); |
| ... | ... | @@ -359,7 +359,7 @@ Page({ |
| 359 | 359 | //支付支付,返回首页 |
| 360 | 360 | ut.m_toast('支付成功'); |
| 361 | 361 | setTimeout(()=>{ |
| 362 | - getApp().re_to("/packageD/pages/user/deposit/prepaid/msg/msg"); | |
| 362 | + getApp().re_to("/packageD/pages/user/integral/msg/msg"); | |
| 363 | 363 | },1000) |
| 364 | 364 | |
| 365 | 365 | }else{ | ... | ... |
packageD/pages/user/integral/msg/msg.js
packageE/pages/cart/cart2/cart2.js
| ... | ... | @@ -285,7 +285,7 @@ Page({ |
| 285 | 285 | util_pay.set_fir(); |
| 286 | 286 | |
| 287 | 287 | //-- 通联的第三方支付的返回优化 -- |
| 288 | - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ | |
| 288 | + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,"none",function (){ | |
| 289 | 289 | //支付信息会先记录着 |
| 290 | 290 | if(!th.data.ok_order_sn) return false; |
| 291 | 291 | getApp().request.promiseGet("/api/weshop/order/page", | ... | ... |
packageE/pages/cart/cart2_inte/cart2_inte.js
| ... | ... | @@ -225,7 +225,7 @@ Page({ |
| 225 | 225 | util_pay.set_fir(); |
| 226 | 226 | |
| 227 | 227 | //-- 通联的第三方支付的返回优化 -- |
| 228 | - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn,null,function (){ | |
| 228 | + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn,"none",function (){ | |
| 229 | 229 | if(!th.data.ok_order_sn) return false; |
| 230 | 230 | getApp().request.promiseGet("/api/weshop/order/page", |
| 231 | 231 | {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ | ... | ... |
packageE/pages/user/cardinfo/cardinfo.js
| ... | ... | @@ -696,28 +696,39 @@ Page({ |
| 696 | 696 | t_pay.set_fir(); |
| 697 | 697 | |
| 698 | 698 | //-- 通联的第三方支付的返回优化 -- |
| 699 | - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ | |
| 699 | + ut.is_pay_ok("func",'none',function (){ | |
| 700 | + | |
| 701 | + console.log('1111'); | |
| 702 | + console.log(th.data.ok_order_sn); | |
| 703 | + | |
| 700 | 704 | if(!th.data.ok_order_sn) return false; |
| 701 | - getApp().request.promiseGet("/api/weshop/order/page", | |
| 702 | - {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ | |
| 703 | - if(ut.ajax_ok(res)){ | |
| 704 | - var item=res.data.data.pageData[0]; | |
| 705 | + | |
| 706 | + var ck_url="/api/weshop/recharge/get/"+os.stoid+"/"+th.data.ok_order_sn; | |
| 707 | + getApp().request.promiseGet(ck_url,{}).then(res=>{ | |
| 708 | + if(res.data.code==0 && res.data.data){ | |
| 709 | + | |
| 710 | + var item=res.data.data; | |
| 711 | + | |
| 712 | + console.log('222'); | |
| 713 | + console.log(item); | |
| 714 | + | |
| 705 | 715 | if(item.pay_status==1){ |
| 706 | 716 | //支付支付,返回首页 |
| 707 | - ut.m_toast('支付成功'); | |
| 708 | - setTimeout(()=>{ | |
| 709 | - getApp().goto("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn); | |
| 710 | - },1000) | |
| 711 | - | |
| 717 | + th.success(); //支付成功提示 | |
| 712 | 718 | }else{ |
| 713 | 719 | //支付支付,返回首页 |
| 714 | 720 | ut.m_toast('支付失败'); |
| 715 | - setTimeout(()=>{ | |
| 716 | - getApp().goto("/pages/index/index/index"); | |
| 717 | - },1000) | |
| 718 | 721 | } |
| 719 | 722 | } |
| 720 | 723 | }) |
| 724 | + }, | |
| 725 | + //支付成功后的提示 | |
| 726 | + function (){ | |
| 727 | + | |
| 728 | + console.log('2222'); | |
| 729 | + console.log(th.data.ok_order_sn); | |
| 730 | + | |
| 731 | + th.success(); //支付成功提示 | |
| 721 | 732 | }); |
| 722 | 733 | } |
| 723 | 734 | |
| ... | ... | @@ -834,7 +845,11 @@ Page({ |
| 834 | 845 | t_pay.pay(req, th.success, function (e) { |
| 835 | 846 | th.data.paying=0; |
| 836 | 847 | getApp().my_warnning("支付失败", 0, th); |
| 837 | - }); | |
| 848 | + },function (ordno){ | |
| 849 | + console.log('get_order') | |
| 850 | + console.log(ordno) | |
| 851 | + th.data.ok_order_sn=ordno; | |
| 852 | + }); | |
| 838 | 853 | |
| 839 | 854 | }, |
| 840 | 855 | ... | ... |
pages/cart/cart2_pt/cart2_pt.js
| ... | ... | @@ -585,7 +585,7 @@ Page({ |
| 585 | 585 | if(fy) return false; |
| 586 | 586 | util_pay.set_fir(); |
| 587 | 587 | //-- 通联的第三方支付的返回优化 -- |
| 588 | - ut.is_pay_ok("/pages/team/team_success/team_success?ordersn=" + th.data.ok_order_sn,null,function (){ | |
| 588 | + ut.is_pay_ok("/pages/team/team_success/team_success?ordersn=" + th.data.ok_order_sn,"none",function (){ | |
| 589 | 589 | if(!th.data.ok_order_sn) return false; |
| 590 | 590 | getApp().request.promiseGet("/api/weshop/order/page", |
| 591 | 591 | {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ | ... | ... |
pages/user/order_detail/order_detail.js
| ... | ... | @@ -81,7 +81,7 @@ Page({ |
| 81 | 81 | |
| 82 | 82 | //通联第三方 |
| 83 | 83 | //-- 通联的第三方支付的返回优化 -- |
| 84 | - ut.is_pay_ok("back",null,function (){ | |
| 84 | + ut.is_pay_ok("back","none",function (){ | |
| 85 | 85 | if(!th.data.ok_order_sn) return false; |
| 86 | 86 | getApp().request.promiseGet("/api/weshop/order/page", |
| 87 | 87 | {data:{store_id:os.stoid,order_sn:th.data.ok_order_sn}}).then(res=>{ | ... | ... |
pages/user/plus/plus.js
| ... | ... | @@ -144,7 +144,7 @@ Page({ |
| 144 | 144 | ut.fy_back('',0); |
| 145 | 145 | t_pay.set_fir(); |
| 146 | 146 | //-- 通联的第三方支付的返回优化 -- |
| 147 | - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ | |
| 147 | + ut.is_pay_ok("func","func",function (){ | |
| 148 | 148 | if(!th.data.ok_order_sn) return false; |
| 149 | 149 | getApp().request.promiseGet("/api/weshop/order/page", |
| 150 | 150 | {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ |
| ... | ... | @@ -152,21 +152,31 @@ Page({ |
| 152 | 152 | var item=res.data.data.pageData[0]; |
| 153 | 153 | if(item.pay_status==1){ |
| 154 | 154 | //支付支付,返回首页 |
| 155 | - ut.m_toast('支付成功'); | |
| 156 | - setTimeout(()=>{ | |
| 157 | - getApp().goto("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn); | |
| 158 | - },1000) | |
| 155 | + th.success() | |
| 159 | 156 | |
| 160 | 157 | }else{ |
| 161 | - //支付支付,返回首页 | |
| 162 | - ut.m_toast('支付失败'); | |
| 163 | - setTimeout(()=>{ | |
| 164 | - getApp().goto("/pages/index/index/index"); | |
| 165 | - },1000) | |
| 158 | + //支付支付,返回首页 | |
| 159 | + getApp().my_warnning('支付失败', 0, th); | |
| 160 | + th.setData({ | |
| 161 | + is_select:0, | |
| 162 | + focus:true, | |
| 163 | + }) | |
| 166 | 164 | } |
| 167 | 165 | } |
| 168 | 166 | }) |
| 169 | - }); | |
| 167 | + }, //成功的回调 | |
| 168 | + function (){ | |
| 169 | + th.success(); | |
| 170 | + },//失败的回调 | |
| 171 | + function (){ | |
| 172 | + | |
| 173 | + getApp().my_warnning('支付失败', 0, th); | |
| 174 | + th.setData({ | |
| 175 | + is_select:0, | |
| 176 | + focus:true, | |
| 177 | + }) | |
| 178 | + | |
| 179 | + }); | |
| 170 | 180 | } |
| 171 | 181 | |
| 172 | 182 | this.setData({ |
| ... | ... | @@ -540,12 +550,13 @@ Page({ |
| 540 | 550 | t_pay.set_pay_url('/api/weshop/plus/create/plus/order'); |
| 541 | 551 | t_pay.pay(req, th.success, function (msg) { |
| 542 | 552 | if(!msg) msg="支付失败"; |
| 543 | - | |
| 544 | 553 | getApp().my_warnning(msg, 0, th); |
| 545 | 554 | th.setData({ |
| 546 | 555 | is_select:0, |
| 547 | 556 | focus:true, |
| 548 | 557 | }) |
| 558 | + },function (ordno){ | |
| 559 | + th.data.ok_order_sn=ordno; | |
| 549 | 560 | }); |
| 550 | 561 | } |
| 551 | 562 | } else { | ... | ... |
utils/pay2.js
| ... | ... | @@ -10,7 +10,8 @@ module.exports = { |
| 10 | 10 | this.wx_paying=0; |
| 11 | 11 | }, |
| 12 | 12 | //-- createRechargeOrder create/plus/order -- |
| 13 | - pay: function(dd, succ,fail) { | |
| 13 | + // get_order是通联专用,获取订单号 | |
| 14 | + pay: function(dd, succ,fail,get_order) { | |
| 14 | 15 | if(this.wx_paying) return false; |
| 15 | 16 | this.wx_paying=1; |
| 16 | 17 | wx.showLoading(); |
| ... | ... | @@ -57,6 +58,11 @@ module.exports = { |
| 57 | 58 | else if(is_pos_pay){ |
| 58 | 59 | var p_data=t.data.data; |
| 59 | 60 | delete p_data.is_pos_pay; //清理掉,不然签名不通过 |
| 61 | + | |
| 62 | + if(get_order){ | |
| 63 | + get_order(p_data.reqsn); //把单号返回 | |
| 64 | + } | |
| 65 | + | |
| 60 | 66 | wx.openEmbeddedMiniProgram({ |
| 61 | 67 | appId: 'wxef277996acc166c3', |
| 62 | 68 | extraData: p_data, | ... | ... |
utils/util.js
| ... | ... | @@ -884,7 +884,15 @@ module.exports = { |
| 884 | 884 | }) |
| 885 | 885 | }, |
| 886 | 886 | //-- 支付的结果判断是不是完成了,通联支付pos收银的返回 -- |
| 887 | - is_pay_ok(back_url,err_url,func){ | |
| 887 | + /** | |
| 888 | + * | |
| 889 | + * @param back_url 如果是地址,就跳转,如果是back,就返回。如果是func,就是要回调 | |
| 890 | + * @param err_url 如果是地址,就跳转,如果是back,就返回。如果是func,就是要回调,如果是none,就没有反应,提示而已 | |
| 891 | + * @param func 因为是物理键的返回,所以要调用结果,查询结果 | |
| 892 | + * @param success //成功的回调函数, 当back_url是func | |
| 893 | + * @param fail //失败的回调函数, 当err_url是func | |
| 894 | + */ | |
| 895 | + is_pay_ok(back_url,err_url,func,success,fail){ | |
| 888 | 896 | if(!err_url){ |
| 889 | 897 | err_url="/pages/index/index/index"; |
| 890 | 898 | } |
| ... | ... | @@ -901,7 +909,11 @@ module.exports = { |
| 901 | 909 | setTimeout(function () { |
| 902 | 910 | if(back_url=='back') { |
| 903 | 911 | wx.navigateBack(); |
| 904 | - }else{ | |
| 912 | + } | |
| 913 | + else if(back_url=='func'){ | |
| 914 | + success(); | |
| 915 | + } | |
| 916 | + else{ | |
| 905 | 917 | wx.redirectTo({ url: back_url}); |
| 906 | 918 | } |
| 907 | 919 | },2000) |
| ... | ... | @@ -914,6 +926,9 @@ module.exports = { |
| 914 | 926 | if(err_url=='back'){ |
| 915 | 927 | wx.navigateBack(); |
| 916 | 928 | } |
| 929 | + else if(err_url=='func'){ | |
| 930 | + fail(); | |
| 931 | + } | |
| 917 | 932 | else if(err_url!='none'){ |
| 918 | 933 | getApp().goto(err_url); |
| 919 | 934 | } | ... | ... |