Commit 41c4c5dd2f72d33fbe25a17a99cf6086222aadba
Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into test
Showing
5 changed files
with
151 additions
and
121 deletions
packageA/pages/myGift/myGift.js
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | const app = getApp(); |
3 | 3 | let self = null; |
4 | 4 | var os = app.globalData.setting; |
5 | +var t_pay = require("../../../utils/pay2.js"); | |
5 | 6 | |
6 | 7 | Page({ |
7 | 8 | |
... | ... | @@ -288,34 +289,40 @@ Page({ |
288 | 289 | "store_id": os.stoid, //商家Id |
289 | 290 | "user_id": user.user_id, //用户ID |
290 | 291 | }; |
291 | - var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; | |
292 | - getApp().request.post(url, | |
293 | - { | |
294 | - data:json, | |
295 | - success:function(res) { | |
296 | - if (res.data.code == 0 && res.data.data) { | |
297 | - res = res.data.data; | |
298 | - | |
299 | - getApp().globalData.no_clear=1; | |
300 | - | |
301 | - wx.requestPayment({ | |
302 | - timeStamp: String(res.timeStamp), | |
303 | - nonceStr: res.nonceStr, | |
304 | - package: res.packageValue, | |
305 | - signType: res.signType, | |
306 | - paySign: res.paySign, | |
307 | - success: function(res) { | |
308 | - getApp().my_warnning("支付成功", 1, th); | |
309 | - }, | |
310 | - fail: function(res) { | |
311 | - getApp().my_warnning("取消支付", 0, th); | |
312 | - } | |
313 | - }); | |
314 | - } else { | |
315 | - getApp().my_warnning(res.data.msg, 0, th); | |
316 | - } | |
317 | - } | |
318 | - }) | |
292 | + t_pay.set_pay_url("/api/weshop/libao/libaoFormvip/libaoOrder"); | |
293 | + t_pay.pay(json,function (){ | |
294 | + getApp().my_warnning("支付成功", 1, th); | |
295 | + },function (e){ | |
296 | + getApp().my_warnning(e, 0, th); | |
297 | + }) | |
298 | + // var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; | |
299 | + // getApp().request.post(url, | |
300 | + // { | |
301 | + // data:json, | |
302 | + // success:function(res) { | |
303 | + // if (res.data.code == 0 && res.data.data) { | |
304 | + // res = res.data.data; | |
305 | + // | |
306 | + // getApp().globalData.no_clear=1; | |
307 | + // | |
308 | + // wx.requestPayment({ | |
309 | + // timeStamp: String(res.timeStamp), | |
310 | + // nonceStr: res.nonceStr, | |
311 | + // package: res.packageValue, | |
312 | + // signType: res.signType, | |
313 | + // paySign: res.paySign, | |
314 | + // success: function(res) { | |
315 | + // getApp().my_warnning("支付成功", 1, th); | |
316 | + // }, | |
317 | + // fail: function(res) { | |
318 | + // getApp().my_warnning("取消支付", 0, th); | |
319 | + // } | |
320 | + // }); | |
321 | + // } else { | |
322 | + // getApp().my_warnning(res.data.msg, 0, th); | |
323 | + // } | |
324 | + // } | |
325 | + // }) | |
319 | 326 | }) |
320 | 327 | }, |
321 | 328 | ... | ... |
packageA/pages/myGiftDetails/myGiftDetails.js
... | ... | @@ -3,6 +3,7 @@ const app = getApp(); |
3 | 3 | let self = null; |
4 | 4 | var os = app.globalData.setting; |
5 | 5 | var ut = require("../../../utils/util.js"); |
6 | +var t_pay = require("../../../utils/pay2.js"); | |
6 | 7 | |
7 | 8 | Page({ |
8 | 9 | |
... | ... | @@ -228,37 +229,48 @@ Page({ |
228 | 229 | "store_id": os.stoid, //商家Id |
229 | 230 | "user_id": user.user_id, //用户ID |
230 | 231 | }; |
231 | - var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; | |
232 | - getApp().request.post(url, | |
233 | - { | |
234 | - data:json, | |
235 | - success:function(res) { | |
236 | - if (res.data.code == 0 && res.data.data) { | |
237 | - res = res.data.data; | |
238 | - | |
239 | - getApp().globalData.no_clear=1; | |
240 | - | |
241 | - wx.requestPayment({ | |
242 | - timeStamp: String(res.timeStamp), | |
243 | - nonceStr: res.nonceStr, | |
244 | - package: res.packageValue, | |
245 | - signType: res.signType, | |
246 | - paySign: res.paySign, | |
247 | - success: function(res) { | |
248 | - getApp().my_warnning("支付成功", 1, th); | |
249 | - setTimeout(function (){ | |
250 | - getApp().goto("/packageA/pages/libao_payment/payment?type=2"); | |
251 | - },1000) | |
252 | - }, | |
253 | - fail: function(res) { | |
254 | - getApp().my_warnning("取消支付", 0, th); | |
255 | - } | |
256 | - }); | |
257 | - } else { | |
258 | - getApp().my_warnning(res.data.msg, 0, th); | |
259 | - } | |
260 | - } | |
261 | - }) | |
232 | + | |
233 | + t_pay.set_pay_url("/api/weshop/libao/libaoFormvip/libaoOrder"); | |
234 | + t_pay.pay(json,function (){ | |
235 | + getApp().my_warnning("支付成功", 1, th); | |
236 | + setTimeout(function (){ | |
237 | + getApp().goto("/packageA/pages/libao_payment/payment?type=2"); | |
238 | + },1000) | |
239 | + },function (msg){ | |
240 | + getApp().my_warnning(msg, 0, th); | |
241 | + }) | |
242 | + | |
243 | + // var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; | |
244 | + // getApp().request.post(url, | |
245 | + // { | |
246 | + // data:json, | |
247 | + // success:function(res) { | |
248 | + // if (res.data.code == 0 && res.data.data) { | |
249 | + // res = res.data.data; | |
250 | + // | |
251 | + // getApp().globalData.no_clear=1; | |
252 | + // | |
253 | + // wx.requestPayment({ | |
254 | + // timeStamp: String(res.timeStamp), | |
255 | + // nonceStr: res.nonceStr, | |
256 | + // package: res.packageValue, | |
257 | + // signType: res.signType, | |
258 | + // paySign: res.paySign, | |
259 | + // success: function(res) { | |
260 | + // getApp().my_warnning("支付成功", 1, th); | |
261 | + // setTimeout(function (){ | |
262 | + // getApp().goto("/packageA/pages/libao_payment/payment?type=2"); | |
263 | + // },1000) | |
264 | + // }, | |
265 | + // fail: function(res) { | |
266 | + // getApp().my_warnning("取消支付", 0, th); | |
267 | + // } | |
268 | + // }); | |
269 | + // } else { | |
270 | + // getApp().my_warnning(res.data.msg, 0, th); | |
271 | + // } | |
272 | + // } | |
273 | + // }) | |
262 | 274 | }) |
263 | 275 | }, |
264 | 276 | ... | ... |
packageE/pages/user/monthgiftbag/public/buy_com.js
1 | +//-- const subscribe = require("../../../../../../MdUNIApp_new2/packageD/pages/subscribe/subscribe"); -- | |
2 | +const t_pay = require("../../../../../utils/pay2.js"); | |
1 | 3 | module.exports = { |
2 | 4 | //开启定位 |
3 | 5 | wait_for_store_config: function (th) { |
... | ... | @@ -253,27 +255,37 @@ module.exports = { |
253 | 255 | break; |
254 | 256 | case 2://立即购买 |
255 | 257 | var order_sn = res.data.data.orderSn; |
256 | - res = res.data.data.result; | |
257 | - if (!res) return false; | |
258 | + //res = res.data.data.result; | |
259 | + //if (!res) return false; | |
258 | 260 | var money=that.data.payMoney; |
259 | 261 | var url = "/packageE/pages/user/monthgiftbag/payment/payment?money=" + money + "&order_sn=" + order_sn; |
260 | 262 | getApp().globalData.no_clear=1; |
261 | - wx.requestPayment({ | |
262 | - timeStamp: String(res.timeStamp), | |
263 | - nonceStr: res.nonceStr, | |
264 | - package: res.packageValue, | |
265 | - signType: res.signType, | |
266 | - paySign: res.paySign, | |
267 | - success: function (res) { | |
268 | - th.setData({submit:0}) | |
269 | - getApp().goto(url); | |
270 | - }, | |
271 | - fail: function (res) { | |
272 | - th.setData({submit:0}) | |
273 | - getApp().my_warnning("取消支付", 0, th); | |
274 | - then1.reduce(order_sn,that.data.getStorageID) | |
275 | - } | |
276 | - }); | |
263 | + | |
264 | + t_pay.pay_data(res,function (){ | |
265 | + th.setData({submit:0}) | |
266 | + getApp().goto(url); | |
267 | + },function (){ | |
268 | + th.setData({submit:0}) | |
269 | + getApp().my_warnning("取消支付", 0, th); | |
270 | + then1.reduce(order_sn,that.data.getStorageID) | |
271 | + }) | |
272 | + | |
273 | + // wx.requestPayment({ | |
274 | + // timeStamp: String(res.timeStamp), | |
275 | + // nonceStr: res.nonceStr, | |
276 | + // package: res.packageValue, | |
277 | + // signType: res.signType, | |
278 | + // paySign: res.paySign, | |
279 | + // success: function (res) { | |
280 | + // th.setData({submit:0}) | |
281 | + // getApp().goto(url); | |
282 | + // }, | |
283 | + // fail: function (res) { | |
284 | + // th.setData({submit:0}) | |
285 | + // getApp().my_warnning("取消支付", 0, th); | |
286 | + // then1.reduce(order_sn,that.data.getStorageID) | |
287 | + // } | |
288 | + // }); | |
277 | 289 | break; |
278 | 290 | case 3://立即领取 |
279 | 291 | th.setData({submit:0}) |
... | ... | @@ -295,7 +307,7 @@ module.exports = { |
295 | 307 | }, |
296 | 308 | |
297 | 309 | |
298 | - //每月礼包减少购买数量 | |
310 | + //每月礼包补回减少购买数量 | |
299 | 311 | reduce(order_sn,stoid){ |
300 | 312 | wx.showLoading({ |
301 | 313 | title: '加载中.' | ... | ... |
pages/giftpack/public/buy_com.js
1 | +const t_pay = require("../../../utils/pay2.js"); | |
1 | 2 | module.exports = { |
2 | 3 | //开启定位 |
3 | 4 | wait_for_store_config: function (th) { |
... | ... | @@ -251,54 +252,22 @@ module.exports = { |
251 | 252 | break; |
252 | 253 | case 2://立即购买 |
253 | 254 | var order_sn = res.data.data.orderSn; |
254 | - res = res.data.data.result; | |
255 | - if (!res) return false; | |
256 | 255 | |
257 | 256 | var money=that.data.payMoney; |
258 | 257 | var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn; |
259 | 258 | getApp().globalData.no_clear=1; |
260 | 259 | |
261 | - //--- 如果是富友支付的时候 -- | |
262 | - if(t.data.data.is_fuioupay){ | |
263 | - const plugin = requirePlugin('fuiou-pay') | |
264 | - | |
265 | - var paramsJson={ | |
266 | - reqType:"11",//必填 01-商户模式,11-机构模式 | |
267 | - reqData:t.data.data.reqData,//必填 富友加密参数 | |
268 | - } | |
269 | - console.log(plugin, plugin.fuioupay) | |
270 | - plugin.fuioupay(parseInt(t.data.data.amt),paramsJson,function (res){ | |
271 | - th.setData({submit:0}) | |
272 | - getApp().goto(url); | |
273 | - },function (error){ | |
274 | - console.log("插件支付错误",error); | |
275 | - //支付失败的时候 | |
276 | - //getApp().confirmBox(error.code+error.message); | |
277 | - //fail(error.code+":"+error.message) | |
278 | - //wx_paying=0; | |
279 | - th.setData({submit:0}) | |
280 | - getApp().my_warnning(error.code+":"+error.message, 0, th); | |
281 | - | |
260 | + t_pay.pay_data(res,function (){ | |
261 | + th.setData({submit:0}) | |
262 | + getApp().goto(url); | |
263 | + },function (e){ | |
264 | + th.setData({submit:0}) | |
265 | + wx.showToast({ | |
266 | + title:e, | |
267 | + icon:'none', | |
268 | + duration:2500 | |
282 | 269 | }) |
283 | - }else{ | |
284 | - wx.requestPayment({ | |
285 | - timeStamp: String(res.timeStamp), | |
286 | - nonceStr: res.nonceStr, | |
287 | - package: res.packageValue, | |
288 | - signType: res.signType, | |
289 | - paySign: res.paySign, | |
290 | - success: function (res) { | |
291 | - th.setData({submit:0}) | |
292 | - getApp().goto(url); | |
293 | - }, | |
294 | - fail: function (res) { | |
295 | - th.setData({submit:0}) | |
296 | - getApp().my_warnning("取消支付", 0, th); | |
297 | - } | |
298 | - }); | |
299 | - } | |
300 | - | |
301 | - | |
270 | + }) | |
302 | 271 | |
303 | 272 | break; |
304 | 273 | case 3://立即领取 | ... | ... |
utils/pay2.js
... | ... | @@ -44,7 +44,7 @@ module.exports = { |
44 | 44 | } |
45 | 45 | }else{ |
46 | 46 | wx_paying=0; |
47 | - "function" == typeof fail && fail(); | |
47 | + "function" == typeof fail && fail(t.data.msg); | |
48 | 48 | } |
49 | 49 | return false; |
50 | 50 | }, |
... | ... | @@ -61,6 +61,36 @@ module.exports = { |
61 | 61 | }); |
62 | 62 | }, |
63 | 63 | |
64 | + //-- 这里是专享礼包的调用 -- | |
65 | + pay_data:function (t,succ,fail){ | |
66 | + var ob=t.data.data.result; | |
67 | + if(!ob){ | |
68 | + fail('支付参数错误'); | |
69 | + return false; | |
70 | + } | |
71 | + if(ob.is_fuioupay){ | |
72 | + const plugin = requirePlugin('fuiou-pay') | |
73 | + | |
74 | + var paramsJson={ | |
75 | + reqType:"11",//必填 01-商户模式,11-机构模式 | |
76 | + reqData:ob.reqData,//必填 富友加密参数 | |
77 | + } | |
78 | + console.log(plugin, plugin.fuioupay) | |
79 | + plugin.fuioupay(parseInt(ob.amt),paramsJson,function (res){ | |
80 | + console.log(res); | |
81 | + wx_paying=0; | |
82 | + "function" == typeof succ && succ(); | |
83 | + },function (error){ | |
84 | + console.log("插件支付错误",error); | |
85 | + //支付失败的时候 | |
86 | + //getApp().confirmBox(error.code+error.message); | |
87 | + fail(error.code+":"+error.message) | |
88 | + wx_paying=0; | |
89 | + }) | |
90 | + }else { | |
91 | + this.weixinPay(ob, succ, fail); | |
92 | + } | |
93 | + }, | |
64 | 94 | weixinPay: function(n, succ,fail) { |
65 | 95 | if(!n) return false; |
66 | 96 | ... | ... |