Commit 36ee21ddd8c653bb8bbd79e749d4b0f39dcd8911
1 parent
ad39a8f0
pos收银支付的优化
Showing
4 changed files
with
123 additions
and
11 deletions
packageE/pages/cart/cart2/cart2.js
@@ -196,6 +196,8 @@ Page({ | @@ -196,6 +196,8 @@ Page({ | ||
196 | 196 | ||
197 | onLoad: function (t) { | 197 | onLoad: function (t) { |
198 | 198 | ||
199 | + this.data.fir_in=1; | ||
200 | + | ||
199 | wx.setNavigationBarTitle({ title: "填写订单", }) | 201 | wx.setNavigationBarTitle({ title: "填写订单", }) |
200 | var th = this; | 202 | var th = this; |
201 | this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); | 203 | this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); |
@@ -271,15 +273,46 @@ Page({ | @@ -271,15 +273,46 @@ Page({ | ||
271 | //----------子页返回父页触发---------- | 273 | //----------子页返回父页触发---------- |
272 | onShow: function () { | 274 | onShow: function () { |
273 | 275 | ||
274 | - //富友支付取消支付强行回去 | ||
275 | - var fy=ut.fy_back("/pages/user/order_list/order_list",1); | ||
276 | - if(fy) return false; | ||
277 | - | ||
278 | - util_pay.set_fir(); | ||
279 | 276 | ||
280 | var th = this; | 277 | var th = this; |
281 | - th.data.g_cart_q_time = null; | 278 | + //判断是不是第一次进入 |
279 | + if(this.data.fir_in){ | ||
280 | + this.data.fir_in=0; | ||
281 | + }else{ | ||
282 | + //富友支付取消支付强行回去 | ||
283 | + var fy=ut.fy_back("/pages/user/order_list/order_list",1); | ||
284 | + if(fy) return false; | ||
285 | + util_pay.set_fir(); | ||
286 | + | ||
287 | + //-- 通联的第三方支付的返回优化 -- | ||
288 | + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ | ||
289 | + //支付信息会先记录着 | ||
290 | + if(!th.data.ok_order_sn) return false; | ||
291 | + getApp().request.promiseGet("/api/weshop/order/page", | ||
292 | + {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ | ||
293 | + if(ut.ajax_ok(res)){ | ||
294 | + var item=res.data.data.pageData[0]; | ||
295 | + if(item.pay_status==1){ | ||
296 | + //支付支付,返回首页 | ||
297 | + ut.m_toast('支付成功'); | ||
298 | + setTimeout(()=>{ | ||
299 | + getApp().goto("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn); | ||
300 | + },1000) | ||
282 | 301 | ||
302 | + }else{ | ||
303 | + //支付支付,返回首页 | ||
304 | + ut.m_toast('支付失败'); | ||
305 | + setTimeout(()=>{ | ||
306 | + getApp().goto("/pages/index/index/index"); | ||
307 | + },1000) | ||
308 | + } | ||
309 | + } | ||
310 | + }) | ||
311 | + }); | ||
312 | + } | ||
313 | + | ||
314 | + | ||
315 | + th.data.g_cart_q_time = null; | ||
283 | if (th.data.isclose == 0) { | 316 | if (th.data.isclose == 0) { |
284 | wx.navigateTo({ | 317 | wx.navigateTo({ |
285 | url: "/pages/index/index/index" | 318 | url: "/pages/index/index/index" |
@@ -5183,8 +5216,7 @@ Page({ | @@ -5183,8 +5216,7 @@ Page({ | ||
5183 | // order_sn: data.data, | 5216 | // order_sn: data.data, |
5184 | //}, 1); | 5217 | //}, 1); |
5185 | 5218 | ||
5186 | - | ||
5187 | - | 5219 | + th.data.ok_order_sn=data.data; |
5188 | util_pay.pay(data.data, async function () { | 5220 | util_pay.pay(data.data, async function () { |
5189 | //app.my_warnning("支付成功",1,th); | 5221 | //app.my_warnning("支付成功",1,th); |
5190 | //setTimeout(function () { | 5222 | //setTimeout(function () { |
utils/pay.js
@@ -49,6 +49,9 @@ module.exports = { | @@ -49,6 +49,9 @@ module.exports = { | ||
49 | wx.hideLoading(); | 49 | wx.hideLoading(); |
50 | if(t.data.code==0){ | 50 | if(t.data.code==0){ |
51 | 51 | ||
52 | + | ||
53 | + var is_pos_pay=t.data.data.is_pos_pay; | ||
54 | + //-- 富有的插件支付 -- | ||
52 | if(t.data.data.is_fuioupay){ | 55 | if(t.data.data.is_fuioupay){ |
53 | const plugin = requirePlugin('fuiou-pay') | 56 | const plugin = requirePlugin('fuiou-pay') |
54 | getApp().globalData.no_clear=1; | 57 | getApp().globalData.no_clear=1; |
@@ -84,12 +87,26 @@ module.exports = { | @@ -84,12 +87,26 @@ module.exports = { | ||
84 | },1000) | 87 | },1000) |
85 | 88 | ||
86 | }) | 89 | }) |
90 | + } | ||
91 | + //-- 通联的支付插件 -- | ||
92 | + else if(is_pos_pay){ | ||
93 | + | ||
94 | + var p_data=t.data.data; | ||
95 | + delete p_data.is_pos_pay; //清理掉,不然签名不通过 | ||
96 | + wx.openEmbeddedMiniProgram({ | ||
97 | + appId: 'wxef277996acc166c3', | ||
98 | + extraData: p_data, | ||
99 | + fail(){ | ||
100 | + //-- 取消不支付 -- | ||
101 | + i.wx_paying=0; | ||
102 | + "function" == typeof a && a(); | ||
103 | + } | ||
104 | + }) | ||
105 | + | ||
87 | }else{ | 106 | }else{ |
88 | i.weixinPay(t.data.data, e, a); | 107 | i.weixinPay(t.data.data, e, a); |
89 | } | 108 | } |
90 | 109 | ||
91 | - | ||
92 | - | ||
93 | }else{ | 110 | }else{ |
94 | i.wx_paying=0; | 111 | i.wx_paying=0; |
95 | getApp().confirmBox(t.data.msg); | 112 | getApp().confirmBox(t.data.msg); |
utils/pay2.js
@@ -24,6 +24,7 @@ module.exports = { | @@ -24,6 +24,7 @@ module.exports = { | ||
24 | "function" == typeof succ && succ(1); | 24 | "function" == typeof succ && succ(1); |
25 | }else{ | 25 | }else{ |
26 | 26 | ||
27 | + var is_pos_pay=t.data.data.is_pos_pay; | ||
27 | if(t.data.data.is_fuioupay){ | 28 | if(t.data.data.is_fuioupay){ |
28 | const plugin = requirePlugin('fuiou-pay') | 29 | const plugin = requirePlugin('fuiou-pay') |
29 | getApp().globalData.no_clear=1; | 30 | getApp().globalData.no_clear=1; |
@@ -51,6 +52,20 @@ module.exports = { | @@ -51,6 +52,20 @@ module.exports = { | ||
51 | fail(msg) | 52 | fail(msg) |
52 | i.wx_paying=0; | 53 | i.wx_paying=0; |
53 | }) | 54 | }) |
55 | + } | ||
56 | + //-- 通联的支付插件 -- | ||
57 | + else if(is_pos_pay){ | ||
58 | + var p_data=t.data.data; | ||
59 | + delete p_data.is_pos_pay; //清理掉,不然签名不通过 | ||
60 | + wx.openEmbeddedMiniProgram({ | ||
61 | + appId: 'wxef277996acc166c3', | ||
62 | + extraData: p_data, | ||
63 | + fail(){ | ||
64 | + //-- 取消不支付 -- | ||
65 | + i.wx_paying=0; | ||
66 | + "function" == typeof a && a(); | ||
67 | + } | ||
68 | + }) | ||
54 | }else { | 69 | }else { |
55 | i.weixinPay(t.data.data, succ, fail); | 70 | i.weixinPay(t.data.data, succ, fail); |
56 | } | 71 | } |
utils/util.js
@@ -799,7 +799,7 @@ module.exports = { | @@ -799,7 +799,7 @@ module.exports = { | ||
799 | return false | 799 | return false |
800 | }, | 800 | }, |
801 | 801 | ||
802 | - //优惠促销的数据的格式话 | 802 | + //-- 优惠促销的数据的格式话 -- |
803 | format_yh_act(fir_act){ | 803 | format_yh_act(fir_act){ |
804 | var more_arr = []; | 804 | var more_arr = []; |
805 | if(fir_act){ | 805 | if(fir_act){ |
@@ -875,6 +875,54 @@ module.exports = { | @@ -875,6 +875,54 @@ module.exports = { | ||
875 | return more_arr | 875 | return more_arr |
876 | }, | 876 | }, |
877 | 877 | ||
878 | + m_toast(txt){ | ||
879 | + wx.showToast({ | ||
880 | + title: txt, | ||
881 | + icon: 'none', | ||
882 | + duration: 2500 | ||
883 | + }) | ||
884 | + }, | ||
885 | + //-- 支付的结果判断是不是完成了,通联支付pos收银的返回 -- | ||
886 | + is_pay_ok(back_url,err_url,func){ | ||
887 | + if(!err_url){ | ||
888 | + err_url="/pages/index/index/index"; | ||
889 | + } | ||
890 | + let options = wx.getEnterOptionsSync(); | ||
891 | + if (options.scene == '1038' && options.referrerInfo.appId=='wxef277996acc166c3') { | ||
892 | + let extraData = options.referrerInfo.extraData; | ||
893 | + if (!extraData) { | ||
894 | + if(func) func(); | ||
895 | + } else { | ||
896 | + // "支付成功"; | ||
897 | + if (extraData.code == 'success') { | ||
898 | + this.m_toast("支付成功") | ||
899 | + //支付失败 | ||
900 | + setTimeout(function () { | ||
901 | + wx.redirectTo({ url: back_url}); | ||
902 | + },2000) | ||
903 | + } | ||
904 | + // "支付已取消"; | ||
905 | + else if (extraData.code == 'cancel') { | ||
906 | + this.m_toast("取消支付") | ||
907 | + //支付失败 | ||
908 | + setTimeout(function () { | ||
909 | + getApp().goto(err_url); | ||
910 | + },2000) | ||
911 | + } | ||
912 | + // "支付失败:" + extraData.errmsg; | ||
913 | + else { | ||
914 | + this.m_toast("支付失败:" + extraData.errmsg) | ||
915 | + //支付失败 | ||
916 | + setTimeout(function () { | ||
917 | + getApp().goto(err_url); | ||
918 | + },2000) | ||
919 | + } | ||
920 | + | ||
921 | + } | ||
922 | + | ||
923 | + } | ||
924 | + }, | ||
925 | + | ||
878 | unserialize: unserialize, | 926 | unserialize: unserialize, |
879 | _throttle:_throttle, | 927 | _throttle:_throttle, |
880 | unserialize_o: unserialize_o, | 928 | unserialize_o: unserialize_o, |