Commit ff1702f8bca48ccb6f392e937b069b7a5c5a869a
1 parent
637800cd
支付的优化
Showing
4 changed files
with
162 additions
and
9 deletions
packageC/pages/presell/cart/cart.js
@@ -147,6 +147,9 @@ Page({ | @@ -147,6 +147,9 @@ Page({ | ||
147 | }, | 147 | }, |
148 | onLoad: function (t) { | 148 | onLoad: function (t) { |
149 | 149 | ||
150 | + //定义第一次进入 | ||
151 | + this.data.fir_in=1; | ||
152 | + | ||
150 | if (t.order_id) this.data.order_id = t.order_id; | 153 | if (t.order_id) this.data.order_id = t.order_id; |
151 | if (t.order_sn) this.data.order_sn = t.order_sn; | 154 | if (t.order_sn) this.data.order_sn = t.order_sn; |
152 | 155 | ||
@@ -190,17 +193,65 @@ Page({ | @@ -190,17 +193,65 @@ Page({ | ||
190 | is_no_by: {}, | 193 | is_no_by: {}, |
191 | is_by: {} | 194 | is_by: {} |
192 | }) | 195 | }) |
196 | + this.data.fir_in=0; | ||
193 | }, | 197 | }, |
194 | 198 | ||
195 | //----------子页返回父页触发---------- | 199 | //----------子页返回父页触发---------- |
196 | onShow: function () { | 200 | onShow: function () { |
201 | + | ||
197 | this.data.paying=0; | 202 | this.data.paying=0; |
198 | 203 | ||
199 | - var fy= ut.fy_back("/pages/user/order_list/order_list",1); | ||
200 | - if(fy) return false; | 204 | + console.log('onshow-2222'); |
201 | 205 | ||
202 | - util_pay.set_fir(); | ||
203 | var th = this; | 206 | var th = this; |
207 | + //判断是不是第一次进入 | ||
208 | + if(this.data.fir_in){ | ||
209 | + this.data.fir_in=0; | ||
210 | + }else{ | ||
211 | + | ||
212 | + console.log('onshow-3333'); | ||
213 | + //-- 富友支付的 -- | ||
214 | + var fy= ut.fy_back("/pages/user/order_list/order_list",1); | ||
215 | + if(fy) return false; | ||
216 | + util_pay.set_fir(); | ||
217 | + | ||
218 | + //-- 通联的第三方支付的返回优化 -- | ||
219 | + ut.is_pay_ok("back","back",function (){ | ||
220 | + | ||
221 | + console.log('onshow-444'); | ||
222 | + console.log(th.data.ok_order_sn); | ||
223 | + | ||
224 | + if(!th.data.ok_order_sn) return false; | ||
225 | + getApp().request.promiseGet("/api/weshop/order/page", | ||
226 | + {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ | ||
227 | + if(ut.ajax_ok(res)){ | ||
228 | + | ||
229 | + console.log('onshow-444'); | ||
230 | + console.log(res); | ||
231 | + | ||
232 | + var item=res.data.data.pageData[0]; | ||
233 | + if(item.pay_status==1){ | ||
234 | + //支付支付,返回首页 | ||
235 | + ut.m_toast('支付成功'); | ||
236 | + setTimeout(()=>{ | ||
237 | + wx.navigateBack(); | ||
238 | + },1000) | ||
239 | + | ||
240 | + }else{ | ||
241 | + //支付支付,返回首页 | ||
242 | + ut.m_toast('支付失败'); | ||
243 | + setTimeout(()=>{ | ||
244 | + wx.navigateBack(); | ||
245 | + },1000) | ||
246 | + } | ||
247 | + } | ||
248 | + }) | ||
249 | + }); | ||
250 | + | ||
251 | + } | ||
252 | + | ||
253 | + | ||
254 | + | ||
204 | th.setData({ show_submit: 0 }); //让提交先掩藏 | 255 | th.setData({ show_submit: 0 }); //让提交先掩藏 |
205 | th.data.g_cart_q_time = null; | 256 | th.data.g_cart_q_time = null; |
206 | if (th.data.isclose == 0) { | 257 | if (th.data.isclose == 0) { |
@@ -2519,6 +2570,9 @@ Page({ | @@ -2519,6 +2570,9 @@ Page({ | ||
2519 | return false; | 2570 | return false; |
2520 | } | 2571 | } |
2521 | 2572 | ||
2573 | + //-- 订单OK -- | ||
2574 | + th.data.ok_order_sn=th.data.order.order_sn; | ||
2575 | + | ||
2522 | util_pay.pay_data(t,function (){ | 2576 | util_pay.pay_data(t,function (){ |
2523 | //---用余额支付--- | 2577 | //---用余额支付--- |
2524 | getApp().my_warnning("支付成功", 1, th); | 2578 | getApp().my_warnning("支付成功", 1, th); |
@@ -2981,6 +3035,8 @@ Page({ | @@ -2981,6 +3035,8 @@ Page({ | ||
2981 | type: 1 //正常单 | 3035 | type: 1 //正常单 |
2982 | }, 1);--*/ | 3036 | }, 1);--*/ |
2983 | 3037 | ||
3038 | + | ||
3039 | + th.data.ok_order_sn=this.data.order.order_sn; | ||
2984 | util_pay.pay(this.data.order.order_sn, function () { | 3040 | util_pay.pay(this.data.order.order_sn, function () { |
2985 | wx.showToast({ title: '支付成功' }) | 3041 | wx.showToast({ title: '支付成功' }) |
2986 | wx.navigateBack(); | 3042 | wx.navigateBack(); |
packageC/pages/presell/cart/cart2_pre.js
@@ -78,6 +78,9 @@ Page({ | @@ -78,6 +78,9 @@ Page({ | ||
78 | }) | 78 | }) |
79 | }, | 79 | }, |
80 | onLoad: function (t) { | 80 | onLoad: function (t) { |
81 | + //定义第一次进入 | ||
82 | + this.data.fir_in=1; | ||
83 | + | ||
81 | wx.setNavigationBarTitle({ | 84 | wx.setNavigationBarTitle({ |
82 | title: "填写订单", | 85 | title: "填写订单", |
83 | }); | 86 | }); |
@@ -280,9 +283,42 @@ Page({ | @@ -280,9 +283,42 @@ Page({ | ||
280 | 283 | ||
281 | var fy=ut.fy_back("/pages/user/order_list/order_list",1); | 284 | var fy=ut.fy_back("/pages/user/order_list/order_list",1); |
282 | if(fy) return false; | 285 | if(fy) return false; |
283 | - | ||
284 | util_pay.set_fir(); | 286 | util_pay.set_fir(); |
285 | var th = this; | 287 | var th = this; |
288 | + //判断是不是第一次进入 | ||
289 | + if(this.data.fir_in){ | ||
290 | + this.data.fir_in=0; | ||
291 | + }else{ | ||
292 | + | ||
293 | + //-- 支付完成后的跳转的时间 -- | ||
294 | + var ok_url = "/packageC/pages/presell/cart/cart?order_sn=" +this.data.ok_order_sn; | ||
295 | + var err_url="/pages/user/order_list/order_list"; | ||
296 | + //-- 通联的第三方支付的返回优化 -- | ||
297 | + ut.is_pay_ok(ok_url,err_url,function (){ | ||
298 | + if(!th.data.ok_order_sn) return false; | ||
299 | + getApp().request.promiseGet("/api/weshop/order/page", | ||
300 | + {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ | ||
301 | + if(ut.ajax_ok(res)){ | ||
302 | + var item=res.data.data.pageData[0]; | ||
303 | + if(item.pay_time){ | ||
304 | + //支付支付,返回首页 | ||
305 | + ut.m_toast('支付成功'); | ||
306 | + setTimeout(()=>{ | ||
307 | + getApp().goto(ok_url); | ||
308 | + },1000) | ||
309 | + | ||
310 | + }else{ | ||
311 | + //支付支付,返回首页 | ||
312 | + ut.m_toast('支付失败'); | ||
313 | + setTimeout(()=>{ | ||
314 | + getApp().goto(err_url); | ||
315 | + },1000) | ||
316 | + } | ||
317 | + } | ||
318 | + }) | ||
319 | + }); | ||
320 | + } | ||
321 | + | ||
286 | if (th.data.isclose == 0) { | 322 | if (th.data.isclose == 0) { |
287 | wx.navigateTo({ | 323 | wx.navigateTo({ |
288 | url: "/pages/index/index/index" | 324 | url: "/pages/index/index/index" |
@@ -918,6 +954,8 @@ Page({ | @@ -918,6 +954,8 @@ Page({ | ||
918 | //要进行判断,如果是用微信支付,就要跳转到支付界面 | 954 | //要进行判断,如果是用微信支付,就要跳转到支付界面 |
919 | if (order_amount && parseFloat(order_amount) > 0) { | 955 | if (order_amount && parseFloat(order_amount) > 0) { |
920 | th.setData({ isclose: 0 }); | 956 | th.setData({ isclose: 0 }); |
957 | + | ||
958 | + th.data.ok_order_sn=data.data; | ||
921 | util_pay.pay(data.data, function () { | 959 | util_pay.pay(data.data, function () { |
922 | var url = "/packageC/pages/presell/cart/cart?order_sn=" + data.data; | 960 | var url = "/packageC/pages/presell/cart/cart?order_sn=" + data.data; |
923 | setTimeout(function () { | 961 | setTimeout(function () { |
pages/cart/cart_wk/cart_wk.js
@@ -60,6 +60,9 @@ Page({ | @@ -60,6 +60,9 @@ Page({ | ||
60 | */ | 60 | */ |
61 | onLoad: function (options) { | 61 | onLoad: function (options) { |
62 | 62 | ||
63 | + //定义第一次进入 | ||
64 | + this.data.fir_in=1; | ||
65 | + | ||
63 | //清空is_pick_up | 66 | //清空is_pick_up |
64 | getApp().request.put("/api/weshop/useraddress/updatePickUp", { | 67 | getApp().request.put("/api/weshop/useraddress/updatePickUp", { |
65 | data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, | 68 | data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, |
@@ -94,11 +97,47 @@ Page({ | @@ -94,11 +97,47 @@ Page({ | ||
94 | */ | 97 | */ |
95 | onShow: function () { | 98 | onShow: function () { |
96 | 99 | ||
97 | - ut.fy_back('',0); | ||
98 | - this.data.paying=0; | ||
99 | - util_pay.set_fir(); | ||
100 | - getApp().check_can_share(); | ||
101 | var th = this; | 100 | var th = this; |
101 | + //判断是不是第一次进入 | ||
102 | + if(this.data.fir_in){ | ||
103 | + this.data.fir_in=0; | ||
104 | + }else{ | ||
105 | + //-- 富友插件的优化 -- | ||
106 | + ut.fy_back('',0); | ||
107 | + this.data.paying=0; | ||
108 | + util_pay.set_fir(); | ||
109 | + | ||
110 | + //-- 通联的第三方支付的返回优化 -- | ||
111 | + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=1&order_sn=" + this.data.ok_order_sn,'back',function (){ | ||
112 | + if(!th.data.ok_order_sn) return false; | ||
113 | + getApp().request.promiseGet("/api/weshop/order/page", | ||
114 | + {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ | ||
115 | + | ||
116 | + if(ut.ajax_ok(res)){ | ||
117 | + var item=res.data.data.pageData[0]; | ||
118 | + //已经支付尾款,或者所有的会员都已经支付尾款 | ||
119 | + if(item.pt_status==4 || item.pt_status==5){ | ||
120 | + //支付支付,返回首页 | ||
121 | + ut.m_toast('支付成功'); | ||
122 | + setTimeout(()=>{ | ||
123 | + getApp().goto("/pages/payment/pay_success/pay_success?type=1&order_sn=" + th.data.ok_order_sn); | ||
124 | + },1000) | ||
125 | + | ||
126 | + }else{ | ||
127 | + //支付支付,返回首页 | ||
128 | + ut.m_toast('支付失败'); | ||
129 | + setTimeout(()=>{ | ||
130 | + getApp().goto("/pages/index/index/index"); | ||
131 | + },1000) | ||
132 | + } | ||
133 | + } | ||
134 | + }) | ||
135 | + }); | ||
136 | + | ||
137 | + } | ||
138 | + | ||
139 | + getApp().check_can_share(); | ||
140 | + | ||
102 | if (th.data.isclose == 0) { | 141 | if (th.data.isclose == 0) { |
103 | wx.navigateTo({ | 142 | wx.navigateTo({ |
104 | url: "/pages/index/index/index" | 143 | url: "/pages/index/index/index" |
@@ -652,6 +691,8 @@ Page({ | @@ -652,6 +691,8 @@ Page({ | ||
652 | return false; | 691 | return false; |
653 | } | 692 | } |
654 | 693 | ||
694 | + //-- 把订单号记录起来 -- | ||
695 | + th.data.ok_order_sn=th.data.order.order_sn; | ||
655 | util_pay.pay_data(t,function (){ | 696 | util_pay.pay_data(t,function (){ |
656 | var allmoney = th.data.allpice; | 697 | var allmoney = th.data.allpice; |
657 | th.jumpPaymentPage(th.data.order.order_sn, allmoney); | 698 | th.jumpPaymentPage(th.data.order.order_sn, allmoney); |
utils/pay.js
@@ -142,6 +142,7 @@ module.exports = { | @@ -142,6 +142,7 @@ module.exports = { | ||
142 | fail('支付参数错误'); | 142 | fail('支付参数错误'); |
143 | return false; | 143 | return false; |
144 | } | 144 | } |
145 | + //富友插件的优化 | ||
145 | if(ob.is_fuioupay){ | 146 | if(ob.is_fuioupay){ |
146 | const plugin = requirePlugin('fuiou-pay') | 147 | const plugin = requirePlugin('fuiou-pay') |
147 | 148 | ||
@@ -167,7 +168,24 @@ module.exports = { | @@ -167,7 +168,24 @@ module.exports = { | ||
167 | fail(msg) | 168 | fail(msg) |
168 | 169 | ||
169 | }) | 170 | }) |
170 | - }else { | 171 | + } |
172 | + //-- 通联的支付插件 -- | ||
173 | + else if(ob.is_pos_pay){ | ||
174 | + | ||
175 | + var p_data=t.data.data; | ||
176 | + delete p_data.is_pos_pay; //清理掉,不然签名不通过 | ||
177 | + wx.openEmbeddedMiniProgram({ | ||
178 | + appId: 'wxef277996acc166c3', | ||
179 | + extraData: p_data, | ||
180 | + fail(){ | ||
181 | + //-- 取消不支付 -- | ||
182 | + i.wx_paying=0; | ||
183 | + "function" == typeof a && a(); | ||
184 | + } | ||
185 | + }) | ||
186 | + | ||
187 | + } | ||
188 | + else { | ||
171 | this.weixinPay(ob, succ, fail); | 189 | this.weixinPay(ob, succ, fail); |
172 | } | 190 | } |
173 | }, | 191 | }, |