diff --git a/packageA/pages/cart2_ser/cart2_ser.js b/packageA/pages/cart2_ser/cart2_ser.js index 86e3ee0..ffe3518 100644 --- a/packageA/pages/cart2_ser/cart2_ser.js +++ b/packageA/pages/cart2_ser/cart2_ser.js @@ -9,6 +9,7 @@ var oo = t.globalData.setting, os = oo; var regeneratorRuntime = require('../../../utils/runtime.js'); var util_pay = require("../../../utils/pay.js"); +var t_pay = require("../../../utils/pay2.js"); Page({ data: { @@ -616,23 +617,13 @@ Page({ isclose: 0 }); - getApp().request.post("/api/weshop/order/pay/createRechargeOrder", { - data: { - parentSn: data.data.order_sn, - store_id: oo.stoid - }, - success: function(su) { - - - if(su.data.code==0) { - - var n = su.data.data; - // console.log('su---->', n); - let order_id = data.data.order_id; - th.weixinPay(n, - function () { - // getApp().showWarning("购买成功"); - wx.showToast({ + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder") + t_pay.pay( + { + parentSn: data.data.order_sn, + store_id: oo.stoid + },function (){ + wx.showToast({ title: '购买成功', icon: 'success', duration: 2000 @@ -642,27 +633,62 @@ Page({ url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id, }) }, 1000) - }, - function () { - getApp().showWarning("支付失败"); - setTimeout(function () { - wx.reLaunch({ - url: "/pages/user/order_list/order_list?index=2&tabindex=1", - }) - }, 1000) - }) - }else{ - - this.data.is_summit_ing = 0; - wx.showToast({ - title: su.data.msg, - icon: 'none', - duration: 2000 - }); - } - } - }) + },function (e){ + wx.showToast({ + title: e, + icon: 'none', + duration: 2000 + }); + } + ) + + // getApp().request.post("/api/weshop/order/pay/createRechargeOrder", { + // data: { + // parentSn: data.data.order_sn, + // store_id: oo.stoid + // }, + // success: function(su) { + // + // if(su.data.code==0) { + // + // var n = su.data.data; + // // console.log('su---->', n); + // let order_id = data.data.order_id; + // th.weixinPay(n, + // function () { + // // getApp().showWarning("购买成功"); + // wx.showToast({ + // title: '购买成功', + // icon: 'success', + // duration: 2000 + // }); + // setTimeout(function () { + // wx.reLaunch({ + // url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id, + // }) + // }, 1000) + // }, + // function () { + // getApp().showWarning("支付失败"); + // setTimeout(function () { + // wx.reLaunch({ + // url: "/pages/user/order_list/order_list?index=2&tabindex=1", + // }) + // }, 1000) + // }) + // }else{ + // + // this.data.is_summit_ing = 0; + // + // wx.showToast({ + // title: su.data.msg, + // icon: 'none', + // duration: 2000 + // }); + // } + // } + // }) } } else { th.data.is_summit_ing = 0; //是否提交中 diff --git a/packageA/pages/chongzhiDetails/chongzhiDetails.js b/packageA/pages/chongzhiDetails/chongzhiDetails.js index d1703b3..4b46354 100644 --- a/packageA/pages/chongzhiDetails/chongzhiDetails.js +++ b/packageA/pages/chongzhiDetails/chongzhiDetails.js @@ -2,6 +2,7 @@ var util = require('../../../utils/util.js'); const app = getApp(),os = app.globalData.setting; var regeneratorRuntime = require('../../../utils/runtime.js'); +var t_pay = require("../../../utils/pay2.js"); Page({ @@ -188,24 +189,38 @@ Page({ var msg = res.data.data; var parentSn = msg.order_sn; var store_id = os.stoid; - getApp().request.post("/api/weshop/order/pay/createRechargeOrder", { - data: { - parentSn: parentSn, - store_id: store_id - }, - success: function (su) { - console.log("su是什么",su); - var n=su.data.data; - console.log("su是什么", su); - - e.weixinPay(n, - function () { - e.jumpPaymentPage(); - }, function () { - getApp().showWarning("支付失败"); - }) - } - }) + + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); + t_pay.pay({ + parentSn: parentSn, + store_id: store_id + }, function () { + e.jumpPaymentPage(); + }, function (e) { + wx.showToast({ + title: e, + icon: 'none', + duration: 2000 + }); + }) + // getApp().request.post("/api/weshop/order/pay/createRechargeOrder", { + // data: { + // parentSn: parentSn, + // store_id: store_id + // }, + // success: function (su) { + // console.log("su是什么",su); + // var n=su.data.data; + // console.log("su是什么", su); + // + // e.weixinPay(n, + // function () { + // e.jumpPaymentPage(); + // }, function () { + // getApp().showWarning("支付失败"); + // }) + // } + // }) }) }, //------支付成功页面-------- diff --git a/packageA/pages/details_serviceCard/details_serviceCard.js b/packageA/pages/details_serviceCard/details_serviceCard.js index 04c47ae..307d6e1 100644 --- a/packageA/pages/details_serviceCard/details_serviceCard.js +++ b/packageA/pages/details_serviceCard/details_serviceCard.js @@ -1,4 +1,5 @@ // packageA/pages/details_serviceCard/details_serviceCard.js +var t_pay = require("../../../utils/pay2.js"); const app = getApp(); const os = app.globalData.setting; let self = null; @@ -497,32 +498,50 @@ Page({ let order_sn = this.data.details.order_sn; let order_id = this.data.details.order_id; let store_id = app.globalData.setting.stoid; + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); + t_pay.pay({ + parentSn: order_sn, + store_id: store_id + }, function () { + app.showWarning('支付成功'); + setTimeout(function() { + wx.reLaunch({ + url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id, + }) + }, 1000) - app.request.post('/api/weshop/order/pay/createRechargeOrder', { - data: { - parentSn: order_sn, - store_id: store_id, - }, - - success: function(res) { - var n = res.data.data; - self.weixinPay(n, function() { - app.showWarning('支付成功'); - // setTimeout(function() { - // wx.reLaunch({ - // url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id, - // }) - // }, 1000) - }, function() { - app.showWarning('支付失败'); - // setTimeout(function() { - // wx.reLaunch({ - // url: '/packageA/pages/cardList/cardList', - // }) - // }, 1000) - }); - } + }, function (e) { + wx.showToast({ + title: e, + icon: 'none', + duration: 2000 + }); }) + // app.request.post('/api/weshop/order/pay/createRechargeOrder', { + // data: { + // parentSn: order_sn, + // store_id: store_id, + // }, + // + // success: function(res) { + // var n = res.data.data; + // self.weixinPay(n, function() { + // app.showWarning('支付成功'); + // // setTimeout(function() { + // // wx.reLaunch({ + // // url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + order_id, + // // }) + // // }, 1000) + // }, function() { + // app.showWarning('支付失败'); + // // setTimeout(function() { + // // wx.reLaunch({ + // // url: '/packageA/pages/cardList/cardList', + // // }) + // // }, 1000) + // }); + // } + // }) }, diff --git a/packageD/pages/user/deposit/prepaid/prepaid.js b/packageD/pages/user/deposit/prepaid/prepaid.js index 24b8c98..782fc5c 100644 --- a/packageD/pages/user/deposit/prepaid/prepaid.js +++ b/packageD/pages/user/deposit/prepaid/prepaid.js @@ -6,6 +6,8 @@ var t = getApp(), ut = i, s = require("../../../../../utils/common.js"); var regeneratorRuntime = require('../../../../../utils/runtime.js'); +var t_pay = require("../../../../../utils/pay2.js"); + Page({ data: { iurl: o.imghost, @@ -150,27 +152,41 @@ Page({ } - var msg = res.data.data; - var parentSn = msg.order_sn; - var store_id = os.stoid; - getApp().request.post("/api/weshop/order/pay/createRechargeOrder", { - data: { - parentSn: parentSn, - store_id: store_id - }, - success: function (su) { - console.log("su是什么",su); - var n=su.data.data; - console.log("su是什么", su); - - e.weixinPay(n, - function () { - e.jumpPaymentPage(); - }, function () { - getApp().showWarning("支付失败"); - }) - } - }) + var msg = res.data.data; + var parentSn = msg.order_sn; + var store_id = os.stoid; + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); + t_pay.pay({ + parentSn: parentSn, + store_id: store_id + }, function () { + e.jumpPaymentPage(); + }, function (e) { + wx.showToast({ + title: e, + icon: 'none', + duration: 2000 + }); + }) + + // getApp().request.post("/api/weshop/order/pay/createRechargeOrder", { + // data: { + // parentSn: parentSn, + // store_id: store_id + // }, + // success: function (su) { + // console.log("su是什么",su); + // var n=su.data.data; + // console.log("su是什么", su); + // + // e.weixinPay(n, + // function () { + // e.jumpPaymentPage(); + // }, function () { + // getApp().showWarning("支付失败"); + // }) + // } + // }) }) }, //------支付成功页面-------- diff --git a/packageD/pages/user/integral/integral.js b/packageD/pages/user/integral/integral.js index b4c5134..63d8fae 100644 --- a/packageD/pages/user/integral/integral.js +++ b/packageD/pages/user/integral/integral.js @@ -6,6 +6,8 @@ var e = function (e) { }(require("../../../../utils/LoadMore.js")), t = getApp(), a = t.request, o = t.globalData.setting, os = o, i = require("../../../../utils/util.js"), ut = i, b = require("../../../../app.js"), app = b, s = require("../../../../utils/common.js"), n = new e.default(); var regeneratorRuntime = require('../../../../utils/runtime.js'); +var t_pay = require("../../../../utils/pay2.js"); + Page({ /** @@ -250,23 +252,37 @@ Page({ var msg = res.data.data; var parentSn = msg.order_sn; var store_id = os.stoid; + + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); + t_pay.pay({ + parentSn: parentSn, + store_id: store_id + }, function () { + th.jumpPaymentPage(); + }, function (e) { + wx.showToast({ + title: e, + icon: 'none', + duration: 2000 + }); + }) - getApp().request.post("/api/weshop/order/pay/createRechargeOrder", { - data: { - parentSn: parentSn, - store_id: store_id - }, - success: function (su) { - var n = su.data.data; - th.weixinPay(n, - function () { - console.log("支付成功页面2333"); - th.jumpPaymentPage(); - }, function () { - getApp().showWarning("支付失败"); - }) - } - }) + // getApp().request.post("/api/weshop/order/pay/createRechargeOrder", { + // data: { + // parentSn: parentSn, + // store_id: store_id + // }, + // success: function (su) { + // var n = su.data.data; + // th.weixinPay(n, + // function () { + // console.log("支付成功页面2333"); + // th.jumpPaymentPage(); + // }, function () { + // getApp().showWarning("支付失败"); + // }) + // } + // }) }) }) diff --git a/pages/giftpack/public/buy_com.js b/pages/giftpack/public/buy_com.js index c8511cc..810c50f 100644 --- a/pages/giftpack/public/buy_com.js +++ b/pages/giftpack/public/buy_com.js @@ -253,26 +253,53 @@ module.exports = { var order_sn = res.data.data.orderSn; res = res.data.data.result; if (!res) return false; + var money=that.data.payMoney; var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn; - getApp().globalData.no_clear=1; - wx.requestPayment({ - timeStamp: String(res.timeStamp), - nonceStr: res.nonceStr, - package: res.packageValue, - signType: res.signType, - paySign: res.paySign, - success: function (res) { + //--- 如果是富友支付的时候 -- + if(t.data.data.is_fuioupay){ + const plugin = requirePlugin('fuiou-pay') + + var paramsJson={ + reqType:"11",//必填 01-商户模式,11-机构模式 + reqData:t.data.data.reqData,//必填 富友加密参数 + } + console.log(plugin, plugin.fuioupay) + plugin.fuioupay(parseInt(t.data.data.amt),paramsJson,function (res){ th.setData({submit:0}) getApp().goto(url); - }, - fail: function (res) { + },function (error){ + console.log("插件支付错误",error); + //支付失败的时候 + //getApp().confirmBox(error.code+error.message); + //fail(error.code+":"+error.message) + //wx_paying=0; th.setData({submit:0}) - getApp().my_warnning("取消支付", 0, th); - } - }); + getApp().my_warnning(error.code+":"+error.message, 0, th); + + }) + }else{ + wx.requestPayment({ + timeStamp: String(res.timeStamp), + nonceStr: res.nonceStr, + package: res.packageValue, + signType: res.signType, + paySign: res.paySign, + success: function (res) { + th.setData({submit:0}) + getApp().goto(url); + }, + fail: function (res) { + th.setData({submit:0}) + getApp().my_warnning("取消支付", 0, th); + } + }); + } + + + break; case 3://立即领取 th.setData({submit:0}) diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index 097163c..20164c3 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -15,6 +15,7 @@ var t = function (t) { var regeneratorRuntime = require('../../../utils/runtime.js'); var ut = require('../../../utils/util.js'); var t = require("../../../utils/pay.js"); +var t_pay = require("../../../utils/pay2.js"); Page({ data: { @@ -2591,29 +2592,47 @@ Page({ if (flag) { - await app.request.promisePost('/api/weshop/order/pay/createRechargeOrder', { - data: { - parentSn: order_sn, - store_id: store_id, - }, - }).then(res => { - // success: function(res) { - var n = res.data.data; - self.weixinPay(n, function () { - app.showWarning('支付成功'); - - }, function () { - app.showWarning('支付失败'); - // setTimeout(function() { - // wx.reLaunch({ - // url: '/packageA/pages/cardList/cardList', - // }) - // }, 1000) + + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); + t_pay.pay({ + parentSn: order_sn, + store_id: store_id + }, function () { + wx.showToast({ + title: '支付成功', + icon:'success', + duration: 2000 }); - // } - }); - }; + }, function (e) { + wx.showToast({ + title: e, + icon: 'none', + duration: 2000 + }); + }) + // await app.request.promisePost('/api/weshop/order/pay/createRechargeOrder', { + // data: { + // parentSn: order_sn, + // store_id: store_id, + // }, + // }).then(res => { + // // success: function(res) { + // var n = res.data.data; + // self.weixinPay(n, function () { + // app.showWarning('支付成功'); + // + // }, function () { + // app.showWarning('支付失败'); + // // setTimeout(function() { + // // wx.reLaunch({ + // // url: '/packageA/pages/cardList/cardList', + // // }) + // // }, 1000) + // }); + // // } + // }); + }; }, diff --git a/utils/pay2.js b/utils/pay2.js index cc67d43..ee49f3f 100644 --- a/utils/pay2.js +++ b/utils/pay2.js @@ -2,16 +2,13 @@ var t = getApp(), n = t.request,wx_paying=0; module.exports = { url: "/api/weshop/plus/create/plus/order", + set_pay_url:function (url){ + this.url=url;//让链接地址进行赋值 + }, + //-- createRechargeOrder create/plus/order -- pay: function(dd, succ,fail) { - if(wx_paying) return false; wx_paying=1; - - if(getApp().globalData.scene) - dd.scene=getApp().globalData.scene; - - console.log(dd,'支付场景'); - wx.showLoading(); var i = this; n.post(this.url, { @@ -22,9 +19,31 @@ module.exports = { if(t.data.data=="升级成功"){ "function" == typeof succ && succ(1); }else{ - i.weixinPay(t.data.data, succ,fail); + if(t.data.data.is_fuioupay){ + const plugin = requirePlugin('fuiou-pay') + + var paramsJson={ + reqType:"11",//必填 01-商户模式,11-机构模式 + reqData:t.data.data.reqData,//必填 富友加密参数 + } + console.log(plugin, plugin.fuioupay) + plugin.fuioupay(parseInt(t.data.data.amt),paramsJson,function (res){ + console.log(res); + wx_paying=0; + "function" == typeof succ && succ(); + },function (error){ + console.log("插件支付错误",error); + //支付失败的时候 + //getApp().confirmBox(error.code+error.message); + fail(error.code+":"+error.message) + wx_paying=0; + }) + }else { + i.weixinPay(t.data.data, succ, fail); + } } }else{ + wx_paying=0; "function" == typeof fail && fail(); } return false; @@ -41,6 +60,7 @@ module.exports = { } }); }, + weixinPay: function(n, succ,fail) { if(!n) return false; @@ -58,7 +78,14 @@ module.exports = { }, fail: function(n) { wx_paying=0; - "function" == typeof fail && fail(); + var msg=''; + switch (n.errMsg){ + case "requestPayment:fail": msg="支付失败";break; + case "requestPayment:fail cancel": msg="您已取消支付";break; + default: msg="支付失败:" + n.errMsg.substr("requestPayment:fail ".length); + } + console.log(n); + "function" == typeof fail && fail(msg); } }); }