Commit c731240086b03c6fc4557affabc68d8db74b4266

Authored by yvan.ni
1 parent 1c666d38

wx_paying不使用全局

packageA/pages/cart2_ser/cart2_ser.js
... ... @@ -274,6 +274,7 @@ Page({
274 274  
275 275 //----------子页返回父页触发----------
276 276 onShow: function() {
  277 + t_pay.set_fir();
277 278 var th = this;
278 279 if (th.data.isclose == 0) {
279 280 wx.navigateTo({
... ...
packageA/pages/chongzhiDetails/chongzhiDetails.js
... ... @@ -22,7 +22,7 @@ Page({
22 22 * 生命周期函数--监听页面加载
23 23 */
24 24 onLoad: function (options) {
25   -
  25 +
26 26 const self = this;
27 27 if(options.type)
28 28 self.setData({type:options.type});
... ... @@ -106,6 +106,7 @@ Page({
106 106 * 生命周期函数--监听页面显示
107 107 */
108 108 onShow: function () {
  109 + t_pay.set_fir();
109 110 getApp().check_can_share();
110 111 },
111 112  
... ...
packageA/pages/details_serviceCard/details_serviceCard.js
... ... @@ -17,6 +17,7 @@ Page({
17 17 * 生命周期函数--监听页面加载
18 18 */
19 19 onLoad: function(options) {
  20 +
20 21 self = this;
21 22 this.data.options = options;
22 23  
... ... @@ -43,6 +44,7 @@ Page({
43 44 * 生命周期函数--监听页面显示
44 45 */
45 46 onShow: function() {
  47 + t_pay.set_fir();
46 48 getApp().check_can_share();
47 49 if (app.globalData.userInfo) {
48 50 if (!this.data.isLogin) {
... ...
packageA/pages/myGift/myGift.js
... ... @@ -50,7 +50,8 @@ Page({
50 50 * 生命周期函数--监听页面加载
51 51 */
52 52 onLoad: function (options) {
53   - self = this;
  53 +
  54 + self = this;
54 55 if(options.index){
55 56 this.setData({currentIndex:1}); //查看我的礼包
56 57 }
... ... @@ -88,7 +89,7 @@ Page({
88 89 * 生命周期函数--监听页面显示
89 90 */
90 91 onShow: function () {
91   -
  92 + t_pay.set_fir();
92 93 getApp().check_can_share();
93 94 if(app.globalData.userInfo) {
94 95 if(!this.data.isLogin) {
... ...
packageA/pages/myGiftDetails/myGiftDetails.js
... ... @@ -23,7 +23,8 @@ Page({
23 23 * 生命周期函数--监听页面加载
24 24 */
25 25 onLoad: function (options) {
26   - self = this;
  26 +
  27 + self = this;
27 28  
28 29 // 如果从商品详情页点击促销栏里的礼包跳转过来的话,不显示底部按钮
29 30 // showBtn 控制按钮是否显示
... ... @@ -66,6 +67,7 @@ Page({
66 67 * 生命周期函数--监听页面显示
67 68 */
68 69 onShow: function () {
  70 + t_pay.set_fir();
69 71 getApp().check_can_share();
70 72 if(app.globalData.userInfo) {
71 73 if(!this.data.isLogin) {
... ...
packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js
... ... @@ -129,6 +129,7 @@ Page({
129 129  
130 130 onLoad: function (t) {
131 131 wx.setNavigationBarTitle({ title: "填写订单", })
  132 +
132 133 var th = this;
133 134 this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, });
134 135 th.data.param = t;
... ... @@ -156,6 +157,7 @@ Page({
156 157  
157 158 //----------子页返回父页触发----------
158 159 onShow: function () {
  160 + util_pay.set_fir();
159 161 var th = this;
160 162 th.setData({ show_submit: 0 }); //让提交先掩藏
161 163 th.data.g_cart_q_time = null;
... ...
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
... ... @@ -597,6 +597,7 @@ Page({
597 597 //----------子页返回父页触发----------
598 598 onShow: function () {
599 599 var th = this;
  600 + util_pay.set_fir();
600 601  
601 602 if (th.data.isclose == 0) {
602 603 wx.navigateTo({
... ...
packageC/pages/presell/cart/cart.js
... ... @@ -157,6 +157,7 @@ Page({
157 157  
158 158 //----------子页返回父页触发----------
159 159 onShow: function () {
  160 + util_pay.set_fir();
160 161 var th = this;
161 162 th.setData({ show_submit: 0 }); //让提交先掩藏
162 163 th.data.g_cart_q_time = null;
... ...
packageC/pages/presell/cart/cart2.js
... ... @@ -160,6 +160,7 @@ Page({
160 160 //----------子页返回父页触发----------
161 161 onShow: function () {
162 162 var th = this;
  163 + util_pay.set_fir();
163 164 th.data.g_cart_q_time = null;
164 165 if (th.data.isclose == 0) {
165 166 wx.navigateTo({
... ...
packageC/pages/presell/cart/cart2_pre.js
... ... @@ -251,6 +251,7 @@ Page({
251 251  
252 252 //----------子页返回父页触发----------
253 253 onShow: function () {
  254 + util_pay.set_fir();
254 255 var th = this;
255 256 if (th.data.isclose == 0) {
256 257 wx.navigateTo({
... ...
packageD/pages/user/deposit/prepaid/prepaid.js
... ... @@ -16,7 +16,8 @@ Page({
16 16 },
17 17 /* 生命周期函数--监听页面初次渲染完成*/
18 18 onReady: function() {
19   - var th=this;
  19 + var th=this;
  20 +
20 21  
21 22 getApp().request.get("/api/wx/weappSendlist/page", {
22 23 data: {
... ... @@ -96,6 +97,7 @@ Page({
96 97 wx.setNavigationBarTitle({
97 98 title: "流动资金转预存",
98 99 })
  100 + t_pay.set_fir();
99 101  
100 102 if(getApp().globalData.user_id && !this.data.is_get){
101 103 this.yuck();
... ...
packageD/pages/user/integral/integral.js
... ... @@ -207,7 +207,7 @@ Page({
207 207 * 生命周期函数--监听页面加载
208 208 */
209 209 onLoad: function (options) {
210   -
  210 +
211 211 var th=this;
212 212 getApp().request.get("/api/wx/weappSendlist/page", {
213 213 data: {
... ... @@ -325,7 +325,8 @@ Page({
325 325 * 生命周期函数--监听页面显示
326 326 */
327 327 onShow: function () {
328   - getApp().check_can_share();
  328 + t_pay.set_fir();
  329 + getApp().check_can_share();
329 330 //--先判断会员状态--
330 331 var user_info = getApp().globalData.userInfo;
331 332 if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
... ...
packageE/pages/cart/cart2/cart2.js
... ... @@ -152,6 +152,7 @@ Page({
152 152  
153 153 },
154 154 onLoad: function (t) {
  155 +
155 156 wx.setNavigationBarTitle({ title: "填写订单", })
156 157 var th = this;
157 158 this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, });
... ... @@ -200,6 +201,7 @@ Page({
200 201  
201 202 //----------子页返回父页触发----------
202 203 onShow: function () {
  204 + util_pay.set_fir();
203 205 var th = this;
204 206 th.data.g_cart_q_time = null;
205 207  
... ...
packageE/pages/user/cardinfo/cardinfo.js
... ... @@ -9,7 +9,6 @@ var t = getApp(),
9 9 var regeneratorRuntime = require('../../../../utils/runtime.js');
10 10 //wx.downloadFile把线上地址设为本地地址
11 11 Page({
12   -
13 12 /**
14 13 * 页面的初始数据
15 14 */
... ... @@ -50,6 +49,7 @@ Page({
50 49 * 生命周期函数--监听页面加载
51 50 */
52 51 onLoad: function (options) {
  52 +
53 53 //--先判断会员状态--
54 54 var user_info = getApp().globalData.userInfo;
55 55 if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
... ... @@ -682,6 +682,7 @@ Page({
682 682 * 生命周期函数--监听页面显示
683 683 */
684 684 onShow: function () {
  685 + t_pay.set_fir();
685 686 //同步初始化
686 687 this.init();
687 688  
... ...
packageE/pages/user/monthgiftbag/giftpackbuy/giftpackbuy.js
... ... @@ -139,6 +139,7 @@ Page({
139 139 this.getList();
140 140 },
141 141 onShow: function () {
  142 + com.set_py_fir();
142 143 getApp().check_can_share();
143 144 var th=this;
144 145 //--先判断会员状态--
... ...
packageE/pages/user/monthgiftbag/giftpackinfo/giftpackinfo.js
... ... @@ -198,6 +198,7 @@ Page({
198 198 },
199 199  
200 200 onShow: function () {
  201 + com.set_py_fir();
201 202 getApp().check_can_share();
202 203 getApp().is_Single_page(this, function () {
203 204 //--先判断会员状态--
... ...
packageE/pages/user/monthgiftbag/giftpacklist/giftpacklist.js
... ... @@ -173,6 +173,7 @@ Page({
173 173 },
174 174  
175 175 onShow: function () {
  176 + com.set_py_fir();
176 177 getApp().check_can_share();
177 178 getApp().is_Single_page(this, function () {
178 179 //--先判断会员状态--
... ...
packageE/pages/user/monthgiftbag/public/buy_com.js
1   -//-- const subscribe = require("../../../../../../MdUNIApp_new2/packageD/pages/subscribe/subscribe"); --
2 1 const t_pay = require("../../../../../utils/pay2.js");
3 2 module.exports = {
  3 + set_py_fir(){
  4 + t_pay.set_fir();
  5 + },
4 6 //开启定位
5 7 wait_for_store_config: function (th) {
6 8 var t_time = setInterval(function () {
... ...
pages/giftpack/buygiftpack/giftpackbuy.js
... ... @@ -139,6 +139,7 @@ Page({
139 139 this.getList();
140 140 },
141 141 onShow: function () {
  142 + com.set_py_fir();
142 143 getApp().check_can_share();
143 144 var th=this;
144 145 //--先判断会员状态--
... ...
pages/giftpack/giftpacklist/giftpacklist.js
... ... @@ -165,6 +165,7 @@ Page({
165 165 },
166 166  
167 167 onShow: function () {
  168 + com.set_py_fir();
168 169 getApp().check_can_share();
169 170 getApp().is_Single_page(this, function () {
170 171 //--先判断会员状态--
... ...
pages/giftpack/public/buy_com.js
1 1 const t_pay = require("../../../utils/pay2.js");
2 2 module.exports = {
  3 + set_py_fir(){
  4 + t_pay.set_fir();
  5 + },
3 6 //开启定位
4 7 wait_for_store_config: function (th) {
5 8 var t_time = setInterval(function () {
... ...
pages/user/order_detail/order_detail.js
... ... @@ -15,6 +15,7 @@ Page({
15 15 conf:null,
16 16 },
17 17 onLoad: function(e) {
  18 +
18 19 var th=this;
19 20 var r = void 0 !== e.isGoup && e.isGoup;
20 21  
... ... @@ -63,6 +64,7 @@ Page({
63 64 }), this.requestOrderDetail(e.order_id), wx.removeStorageSync("order:order_detail:update");
64 65 },
65 66 onShow: function() {
  67 + py.set_fir();
66 68 wx.getStorageSync("order:order_detail:update") && (wx.removeStorageSync("order:order_detail:update"),
67 69 this.requestOrderDetail(this.data.order.order_id));
68 70 },
... ...
pages/user/order_list/order_list.js
... ... @@ -78,6 +78,7 @@ Page({
78 78 searchContent: '',
79 79 },
80 80 onLoad: function (t) {
  81 +
81 82 self = this;
82 83 // 设置日期选择器的结束时间为当前日期
83 84 var now = new Date();
... ... @@ -108,6 +109,7 @@ Page({
108 109 s.init(this, "", "orderList");
109 110 },
110 111 onShow: function () {
  112 + t_pay.set_fir();
111 113 var th = this;
112 114 //---查看会员的等级价---
113 115 getApp().getConfig2(function (e) {
... ...
pages/user/plus/plus.js
... ... @@ -9,7 +9,6 @@ var t = getApp(),
9 9 t_pay = require("../../../utils/pay2.js");
10 10 var regeneratorRuntime = require('../../../utils/runtime.js');
11 11  
12   -
13 12 Page({
14 13 /**
15 14 * 页面的初始数据
... ... @@ -129,6 +128,8 @@ Page({
129 128 var user_info = getApp().globalData.userInfo;
130 129 if (!user_info) return false;
131 130  
  131 + t_pay.set_fir();
  132 +
132 133 var th = this,
133 134 that = th,
134 135 app_d = getApp().globalData;
... ...
utils/pay.js
1   -var t = getApp(), n = t.request,wx_paying=0;
  1 +var t = getApp(), n = t.request;
2 2  
3 3 module.exports = {
  4 + wx_paying:0,
  5 + set_fir(){
  6 + this.wx_paying=0;
  7 + },
4 8 url: "/api/weshop/order/pay/createOrder",
5 9 rechange: function(t, e, a) {
6 10 var i = this;
... ... @@ -21,8 +25,8 @@ module.exports = {
21 25 },
22 26 pay: function(t, e, a,sto,type) {
23 27  
24   - if(wx_paying) return false;
25   - wx_paying=1;
  28 + if(this.wx_paying) return false;
  29 + this.wx_paying=1;
26 30  
27 31 var i = this;
28 32 var dd = {
... ... @@ -56,13 +60,13 @@ module.exports = {
56 60 console.log(plugin, plugin.fuioupay)
57 61 plugin.fuioupay(parseInt(t.data.data.amt),paramsJson,function (res){
58 62 console.log(res);
59   - wx_paying=0;
  63 + i.wx_paying=0;
60 64 getApp().showSuccess("支付成功!", e);
61 65  
62 66 },function (error){
63 67 console.log("插件支付错误",error);
64 68 //支付失败的时候
65   -
  69 + i.wx_paying=0;
66 70 var msg='取消支付';
67 71 if(error.code){
68 72 msg=error.code+":"+error.message;
... ... @@ -74,7 +78,7 @@ module.exports = {
74 78 url: "/pages/user/order_list/order_list",
75 79 });
76 80 },1000)
77   - wx_paying=0;
  81 +
78 82 })
79 83 }else{
80 84 i.weixinPay(t.data.data, e, a);
... ... @@ -83,33 +87,35 @@ module.exports = {
83 87  
84 88  
85 89 }else{
  90 + i.wx_paying=0;
86 91 getApp().confirmBox(t.data.msg);
87 92 setTimeout(function(){
88 93 wx.redirectTo({
89 94 url: "/pages/user/order_list/order_list",
90 95 });
91 96 },1000)
92   - wx_paying=0;
  97 +
93 98 }
94 99 return false;
95 100 },
96 101 fail: function() {
97 102 console.log('======fail', )
98 103 wx.hideLoading();
99   - wx_paying=0;
  104 + i.wx_paying=0;
100 105 "function" == typeof a && a();
101 106 },
102 107 failStatus: function() {
103 108 wx.hideLoading();
104   - wx_paying=0;
  109 + i.wx_paying=0;
105 110 "function" == typeof a && a();
106 111 }
107 112 });
108 113 },
109 114 weixinPay: function(n, e, a) {
  115 + var th=this;
110 116 if(!n) return false;
111 117  
112   - getApp().globalData.no_clear=1;
  118 + getApp().globalData.no_clear=1;
113 119  
114 120 //有的话用最新的支付方式
115 121 if(n.orderInfo) {
... ... @@ -121,11 +127,11 @@ module.exports = {
121 127 paySign: n.paySign,
122 128 orderInfo: n.orderInfo, // 需要新增的 订单 信息
123 129 success (n) {
124   - wx_paying=0;
  130 + th.wx_paying=0;
125 131 t.showSuccess("支付成功!", e);
126 132 },
127 133 fail (n) {
128   - wx_paying=0;
  134 + th.wx_paying=0;
129 135 if(!n.errMsg ) {
130 136 getApp().showWarning("支付失败");
131 137 "function" == typeof fail && fail();
... ... @@ -146,11 +152,11 @@ module.exports = {
146 152 signType: n.signType,
147 153 paySign: n.paySign,
148 154 success: function (n) {
149   - wx_paying=0;
  155 + th.wx_paying=0;
150 156 console.log(n), t.showSuccess("支付成功!", e);
151 157 },
152 158 fail: function (n) {
153   - wx_paying=0;
  159 + th.wx_paying=0;
154 160 console.log(n), "requestPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") :
155 161 t.confirmBox("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)),
156 162 "function" == typeof a && a();
... ...
utils/pay2.js
1   -var t = getApp(), n = t.request,wx_paying=0;
  1 +var t = getApp(), n = t.request;
2 2  
3 3 module.exports = {
  4 + wx_paying:0,
4 5 url: "/api/weshop/plus/create/plus/order",
5 6 set_pay_url:function (url){
6 7 this.url=url;//让链接地址进行赋值
7 8 },
  9 + set_fir(){
  10 + this.wx_paying=0;
  11 + },
8 12 //-- createRechargeOrder create/plus/order --
9 13 pay: function(dd, succ,fail) {
10   - if(wx_paying) return false;
11   - wx_paying=1;
  14 + if(this.wx_paying) return false;
  15 + this.wx_paying=1;
12 16 wx.showLoading();
13 17 var i = this;
14 18 n.post(this.url, {
... ... @@ -31,7 +35,7 @@ module.exports = {
31 35 console.log(plugin, plugin.fuioupay)
32 36 plugin.fuioupay(parseInt(t.data.data.amt),paramsJson,function (res){
33 37 console.log(res);
34   - wx_paying=0;
  38 + i.wx_paying=0;
35 39 "function" == typeof succ && succ();
36 40 },function (error){
37 41 console.log("插件支付错误",error);
... ... @@ -42,26 +46,26 @@ module.exports = {
42 46 msg=error.code+":"+error.message;
43 47 }
44 48 fail(msg)
45   - wx_paying=0;
  49 + i.wx_paying=0;
46 50 })
47 51 }else {
48 52 i.weixinPay(t.data.data, succ, fail);
49 53 }
50 54 }
51 55 }else{
52   - wx_paying=0;
  56 + i.wx_paying=0;
53 57 "function" == typeof fail && fail(t.data.msg);
54 58 }
55 59 return false;
56 60 },
57 61 fail: function() {
58 62 wx.hideLoading();
59   - wx_paying=0;
  63 + i.wx_paying=0;
60 64 "function" == typeof fail && fail();
61 65 },
62 66 failStatus: function() {
63 67 wx.hideLoading();
64   - wx_paying=0;
  68 + i.wx_paying=0;
65 69 "function" == typeof fail && fail();
66 70 }
67 71 });
... ... @@ -69,8 +73,10 @@ module.exports = {
69 73  
70 74 //-- 这里是专享礼包的调用 --
71 75 pay_data:function (t,succ,fail){
  76 + var th=this;
72 77 var ob=t.data.data.result;
73 78 if(!ob){
  79 + this.set_fir();
74 80 fail('支付参数错误');
75 81 return false;
76 82 }
... ... @@ -85,10 +91,10 @@ module.exports = {
85 91 console.log(plugin, plugin.fuioupay)
86 92 plugin.fuioupay(parseInt(ob.amt),paramsJson,function (res){
87 93 console.log(res);
88   - wx_paying=0;
  94 + th.wx_paying=0;
89 95 "function" == typeof succ && succ();
90 96 },function (error){
91   - wx_paying=0;
  97 + th.wx_paying=0;
92 98 console.log("插件支付错误",error);
93 99 //支付失败的时候
94 100 //getApp().confirmBox(error.code+error.message);
... ... @@ -104,8 +110,12 @@ module.exports = {
104 110 }
105 111 },
106 112 weixinPay: function(n, succ,fail) {
107   - if(!n) return false;
  113 + if(!n){
  114 + this.set_fir();
  115 + return false;
  116 + }
108 117  
  118 + var th=this;
109 119 getApp().globalData.no_clear=1;
110 120  
111 121 wx.requestPayment({
... ... @@ -115,11 +125,11 @@ module.exports = {
115 125 signType: n.signType,
116 126 paySign: n.paySign,
117 127 success: function(n) {
118   - wx_paying=0;
  128 + th.wx_paying=0;
119 129 "function" == typeof succ && succ();
120 130 },
121 131 fail: function(n) {
122   - wx_paying=0;
  132 + th.wx_paying=0;
123 133 var msg='';
124 134 switch (n.errMsg){
125 135 case "requestPayment:fail": msg="支付失败";break;
... ...