From 0904f37f2c7b62a3a165c023d8293771c259acf3 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Sat, 15 Jul 2023 09:02:07 +0800 Subject: [PATCH] pos收银支付的优化 --- packageC/pages/presell/cart/cart2.js | 2 +- packageD/pages/user/deposit/prepaid/msg/msg.js | 5 +---- packageD/pages/user/deposit/prepaid/prepaid.js | 2 +- packageD/pages/user/integral/integral.js | 4 ++-- packageD/pages/user/integral/msg/msg.js | 1 - packageE/pages/cart/cart2/cart2.js | 2 +- packageE/pages/cart/cart2_inte/cart2_inte.js | 2 +- packageE/pages/user/cardinfo/cardinfo.js | 43 +++++++++++++++++++++++++++++-------------- pages/cart/cart2_pt/cart2_pt.js | 2 +- pages/user/order_detail/order_detail.js | 2 +- pages/user/plus/plus.js | 35 +++++++++++++++++++++++------------ utils/pay2.js | 8 +++++++- utils/util.js | 19 +++++++++++++++++-- 13 files changed, 85 insertions(+), 42 deletions(-) diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js index e740583..e58d467 100644 --- a/packageC/pages/presell/cart/cart2.js +++ b/packageC/pages/presell/cart/cart2.js @@ -213,7 +213,7 @@ Page({ util_pay.set_fir(); //-- 通联的第三方支付的返回优化 -- - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,'none',function (){ if(!th.data.ok_order_sn) return false; getApp().request.promiseGet("/api/weshop/order/page", {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ diff --git a/packageD/pages/user/deposit/prepaid/msg/msg.js b/packageD/pages/user/deposit/prepaid/msg/msg.js index 99706f5..96a717e 100644 --- a/packageD/pages/user/deposit/prepaid/msg/msg.js +++ b/packageD/pages/user/deposit/prepaid/msg/msg.js @@ -68,10 +68,7 @@ Page({ }) }, homepage:function(){ - - wx.navigateTo({ - url: "../../../../index/index/index", - }) + getApp().goto('/pages/index/index/index'); }, /** diff --git a/packageD/pages/user/deposit/prepaid/prepaid.js b/packageD/pages/user/deposit/prepaid/prepaid.js index 4a63595..52db824 100644 --- a/packageD/pages/user/deposit/prepaid/prepaid.js +++ b/packageD/pages/user/deposit/prepaid/prepaid.js @@ -205,7 +205,7 @@ Page({ var store_id = os.stoid; t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); - th.data.ok_order_sn=parentSn; + e.data.ok_order_sn=parentSn; t_pay.pay({ parentSn: parentSn, store_id: store_id diff --git a/packageD/pages/user/integral/integral.js b/packageD/pages/user/integral/integral.js index 7a2c2b6..0b9762e 100644 --- a/packageD/pages/user/integral/integral.js +++ b/packageD/pages/user/integral/integral.js @@ -345,7 +345,7 @@ Page({ t_pay.set_fir(); //-- 通联的第三方支付的返回优化 -- - ut.is_pay_ok("/packageD/pages/user/deposit/prepaid/msg/msg",null,function (){ + ut.is_pay_ok("/packageD/pages/user/integral/msg/msg",'none',function (){ console.log('show--11') console.log(th.data.ok_order_sn); @@ -359,7 +359,7 @@ Page({ //支付支付,返回首页 ut.m_toast('支付成功'); setTimeout(()=>{ - getApp().re_to("/packageD/pages/user/deposit/prepaid/msg/msg"); + getApp().re_to("/packageD/pages/user/integral/msg/msg"); },1000) }else{ diff --git a/packageD/pages/user/integral/msg/msg.js b/packageD/pages/user/integral/msg/msg.js index 9482b8e..10fb86f 100644 --- a/packageD/pages/user/integral/msg/msg.js +++ b/packageD/pages/user/integral/msg/msg.js @@ -68,7 +68,6 @@ Page({ }) }, homepage:function(){ - getApp().goto('/pages/index/index/index'); }, diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index 4be2a1b..4003ac4 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -285,7 +285,7 @@ Page({ util_pay.set_fir(); //-- 通联的第三方支付的返回优化 -- - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,"none",function (){ //支付信息会先记录着 if(!th.data.ok_order_sn) return false; getApp().request.promiseGet("/api/weshop/order/page", diff --git a/packageE/pages/cart/cart2_inte/cart2_inte.js b/packageE/pages/cart/cart2_inte/cart2_inte.js index be3fa36..7c7c27d 100644 --- a/packageE/pages/cart/cart2_inte/cart2_inte.js +++ b/packageE/pages/cart/cart2_inte/cart2_inte.js @@ -225,7 +225,7 @@ Page({ util_pay.set_fir(); //-- 通联的第三方支付的返回优化 -- - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn,null,function (){ + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn,"none",function (){ if(!th.data.ok_order_sn) return false; getApp().request.promiseGet("/api/weshop/order/page", {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ diff --git a/packageE/pages/user/cardinfo/cardinfo.js b/packageE/pages/user/cardinfo/cardinfo.js index a3a4b7c..eadbdd8 100644 --- a/packageE/pages/user/cardinfo/cardinfo.js +++ b/packageE/pages/user/cardinfo/cardinfo.js @@ -696,28 +696,39 @@ Page({ t_pay.set_fir(); //-- 通联的第三方支付的返回优化 -- - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ + ut.is_pay_ok("func",'none',function (){ + + console.log('1111'); + console.log(th.data.ok_order_sn); + if(!th.data.ok_order_sn) return false; - getApp().request.promiseGet("/api/weshop/order/page", - {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ - if(ut.ajax_ok(res)){ - var item=res.data.data.pageData[0]; + + var ck_url="/api/weshop/recharge/get/"+os.stoid+"/"+th.data.ok_order_sn; + getApp().request.promiseGet(ck_url,{}).then(res=>{ + if(res.data.code==0 && res.data.data){ + + var item=res.data.data; + + console.log('222'); + console.log(item); + if(item.pay_status==1){ //支付支付,返回首页 - ut.m_toast('支付成功'); - setTimeout(()=>{ - getApp().goto("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn); - },1000) - + th.success(); //支付成功提示 }else{ //支付支付,返回首页 ut.m_toast('支付失败'); - setTimeout(()=>{ - getApp().goto("/pages/index/index/index"); - },1000) } } }) + }, + //支付成功后的提示 + function (){ + + console.log('2222'); + console.log(th.data.ok_order_sn); + + th.success(); //支付成功提示 }); } @@ -834,7 +845,11 @@ Page({ t_pay.pay(req, th.success, function (e) { th.data.paying=0; getApp().my_warnning("支付失败", 0, th); - }); + },function (ordno){ + console.log('get_order') + console.log(ordno) + th.data.ok_order_sn=ordno; + }); }, diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index 521b8eb..c665e70 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -585,7 +585,7 @@ Page({ if(fy) return false; util_pay.set_fir(); //-- 通联的第三方支付的返回优化 -- - ut.is_pay_ok("/pages/team/team_success/team_success?ordersn=" + th.data.ok_order_sn,null,function (){ + ut.is_pay_ok("/pages/team/team_success/team_success?ordersn=" + th.data.ok_order_sn,"none",function (){ if(!th.data.ok_order_sn) return false; getApp().request.promiseGet("/api/weshop/order/page", {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ diff --git a/pages/user/order_detail/order_detail.js b/pages/user/order_detail/order_detail.js index a6142b1..0e6044a 100644 --- a/pages/user/order_detail/order_detail.js +++ b/pages/user/order_detail/order_detail.js @@ -81,7 +81,7 @@ Page({ //通联第三方 //-- 通联的第三方支付的返回优化 -- - ut.is_pay_ok("back",null,function (){ + ut.is_pay_ok("back","none",function (){ if(!th.data.ok_order_sn) return false; getApp().request.promiseGet("/api/weshop/order/page", {data:{store_id:os.stoid,order_sn:th.data.ok_order_sn}}).then(res=>{ diff --git a/pages/user/plus/plus.js b/pages/user/plus/plus.js index 902d087..581319d 100644 --- a/pages/user/plus/plus.js +++ b/pages/user/plus/plus.js @@ -144,7 +144,7 @@ Page({ ut.fy_back('',0); t_pay.set_fir(); //-- 通联的第三方支付的返回优化 -- - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ + ut.is_pay_ok("func","func",function (){ if(!th.data.ok_order_sn) return false; getApp().request.promiseGet("/api/weshop/order/page", {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ @@ -152,21 +152,31 @@ Page({ var item=res.data.data.pageData[0]; if(item.pay_status==1){ //支付支付,返回首页 - ut.m_toast('支付成功'); - setTimeout(()=>{ - getApp().goto("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn); - },1000) + th.success() }else{ - //支付支付,返回首页 - ut.m_toast('支付失败'); - setTimeout(()=>{ - getApp().goto("/pages/index/index/index"); - },1000) + //支付支付,返回首页 + getApp().my_warnning('支付失败', 0, th); + th.setData({ + is_select:0, + focus:true, + }) } } }) - }); + }, //成功的回调 + function (){ + th.success(); + },//失败的回调 + function (){ + + getApp().my_warnning('支付失败', 0, th); + th.setData({ + is_select:0, + focus:true, + }) + + }); } this.setData({ @@ -540,12 +550,13 @@ Page({ t_pay.set_pay_url('/api/weshop/plus/create/plus/order'); t_pay.pay(req, th.success, function (msg) { if(!msg) msg="支付失败"; - getApp().my_warnning(msg, 0, th); th.setData({ is_select:0, focus:true, }) + },function (ordno){ + th.data.ok_order_sn=ordno; }); } } else { diff --git a/utils/pay2.js b/utils/pay2.js index 4ca5573..8956b24 100644 --- a/utils/pay2.js +++ b/utils/pay2.js @@ -10,7 +10,8 @@ module.exports = { this.wx_paying=0; }, //-- createRechargeOrder create/plus/order -- - pay: function(dd, succ,fail) { + // get_order是通联专用,获取订单号 + pay: function(dd, succ,fail,get_order) { if(this.wx_paying) return false; this.wx_paying=1; wx.showLoading(); @@ -57,6 +58,11 @@ module.exports = { else if(is_pos_pay){ var p_data=t.data.data; delete p_data.is_pos_pay; //清理掉,不然签名不通过 + + if(get_order){ + get_order(p_data.reqsn); //把单号返回 + } + wx.openEmbeddedMiniProgram({ appId: 'wxef277996acc166c3', extraData: p_data, diff --git a/utils/util.js b/utils/util.js index bf4e5cc..aed1d41 100644 --- a/utils/util.js +++ b/utils/util.js @@ -884,7 +884,15 @@ module.exports = { }) }, //-- 支付的结果判断是不是完成了,通联支付pos收银的返回 -- - is_pay_ok(back_url,err_url,func){ + /** + * + * @param back_url 如果是地址,就跳转,如果是back,就返回。如果是func,就是要回调 + * @param err_url 如果是地址,就跳转,如果是back,就返回。如果是func,就是要回调,如果是none,就没有反应,提示而已 + * @param func 因为是物理键的返回,所以要调用结果,查询结果 + * @param success //成功的回调函数, 当back_url是func + * @param fail //失败的回调函数, 当err_url是func + */ + is_pay_ok(back_url,err_url,func,success,fail){ if(!err_url){ err_url="/pages/index/index/index"; } @@ -901,7 +909,11 @@ module.exports = { setTimeout(function () { if(back_url=='back') { wx.navigateBack(); - }else{ + } + else if(back_url=='func'){ + success(); + } + else{ wx.redirectTo({ url: back_url}); } },2000) @@ -914,6 +926,9 @@ module.exports = { if(err_url=='back'){ wx.navigateBack(); } + else if(err_url=='func'){ + fail(); + } else if(err_url!='none'){ getApp().goto(err_url); } -- libgit2 0.21.4