Commit b45b1075a06650ad7d448c1f670b52b36f5e341a
Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev
Showing
1 changed file
with
275 additions
and
193 deletions
pages/user/plus/plus.js
1 | 1 | var t = getApp(), |
2 | 2 | a = t.request, |
3 | - o = t.globalData.setting, | |
3 | + o = t.globalData.setting, | |
4 | 4 | os = o, |
5 | 5 | i = require("../../../utils/util.js"), |
6 | 6 | ut = i, |
7 | 7 | s = require("../../../utils/common.js"), |
8 | - w = require("../../../utils/wxParse/wxParse.js"),t_pay = require("../../../utils/pay2.js"); | |
9 | - var regeneratorRuntime = require('../../../utils/runtime.js'); | |
8 | + w = require("../../../utils/wxParse/wxParse.js"), | |
9 | + t_pay = require("../../../utils/pay2.js"); | |
10 | +var regeneratorRuntime = require('../../../utils/runtime.js'); | |
10 | 11 | |
11 | 12 | Page({ |
12 | 13 | /** |
... | ... | @@ -19,24 +20,24 @@ Page({ |
19 | 20 | screenheight: 0, |
20 | 21 | canvasHidden: true, |
21 | 22 | shareImgPath: null, |
22 | - is_plusCard: "",//卡的列表 | |
23 | + is_plusCard: "", //卡的列表 | |
23 | 24 | imagePath: "", |
24 | - is_pulscardname: "",//plus会员的名字 | |
25 | - is_card: 0,//用于判断是否是续费页和购买页面 0不是PLUS会员 | |
26 | - content: "",//等级卡规则 | |
27 | - is_card_rule: "",//等级卡规则判断用 | |
28 | - is_show: 0, //页面要加载完才能显示 | |
29 | - open_yq: 0, //显示打开邀请码的弹窗 | |
30 | - by_index:null, //购买卡的下班 | |
25 | + is_pulscardname: "", //plus会员的名字 | |
26 | + is_card: 0, //用于判断是否是续费页和购买页面 0不是PLUS会员 | |
27 | + content: "", //等级卡规则 | |
28 | + is_card_rule: "", //等级卡规则判断用 | |
29 | + is_show: 0, //页面要加载完才能显示 | |
30 | + open_yq: 0, //显示打开邀请码的弹窗 | |
31 | + by_index: null, //购买卡的下班 | |
31 | 32 | |
32 | - isyaoqingma:0, //是否邀请码 | |
33 | - is_salesman:0, //是否营业员 | |
34 | - inp_recommon: null, //输入的邀请码 | |
33 | + isyaoqingma: 0, //是否邀请码 | |
34 | + is_salesman: 0, //是否营业员 | |
35 | + inp_recommon: null, //输入的邀请码 | |
35 | 36 | inp_serviceman: null, //输入的营业员 |
36 | - is_fengxiang: 0, //是不是分享过来的 | |
37 | - def_recommon: null, //分享人的手机号 | |
38 | - def_serviceman: null, //分享人的营业员 | |
39 | - fir_leader:0, //分享人的ID | |
37 | + is_fengxiang: 0, //是不是分享过来的 | |
38 | + def_recommon: null, //分享人的手机号 | |
39 | + def_serviceman: null, //分享人的营业员 | |
40 | + fir_leader: 0, //分享人的ID | |
40 | 41 | }, |
41 | 42 | swiperChange: function (e) { |
42 | 43 | var currentId = e.detail.current; |
... | ... | @@ -48,34 +49,41 @@ Page({ |
48 | 49 | * 生命周期函数--监听页面加载 |
49 | 50 | */ |
50 | 51 | onLoad: function (options) { |
51 | - var that = this,th=that; | |
52 | - var store_id=getApp().globalData.setting.stoid; | |
52 | + var that = this, | |
53 | + th = that; | |
54 | + var store_id = getApp().globalData.setting.stoid; | |
53 | 55 | //获取用户设备信息,屏幕宽度 |
54 | 56 | wx.getSystemInfo({ |
55 | 57 | success: res => { |
56 | - that.setData({screenWidth: res.screenWidth}) | |
58 | + that.setData({ | |
59 | + screenWidth: res.screenWidth | |
60 | + }) | |
57 | 61 | } |
58 | 62 | }) |
59 | 63 | var fir_leader = options.scene; |
60 | - if (fir_leader) that.setData({fir_leader:fir_leader}) | |
64 | + if (fir_leader) that.setData({ | |
65 | + fir_leader: fir_leader | |
66 | + }) | |
61 | 67 | //--先判断会员状态-- |
62 | 68 | var user_info = getApp().globalData.userInfo; |
63 | 69 | if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { |
64 | - wx.navigateTo({ url: '/pages/togoin/togoin?first_leader=' + fir_leader, }) | |
65 | - return false; | |
66 | - } | |
70 | + wx.navigateTo({ | |
71 | + url: '/pages/togoin/togoin?first_leader=' + fir_leader, | |
72 | + }) | |
73 | + return false; | |
74 | + } | |
67 | 75 | //-----------商家配置信息----- 等级卡规则,是否又开邀请码,营业员------------ |
68 | 76 | getApp().request.get("/api/weshop/storeconfig/get/" + store_id, { |
69 | 77 | success: function (res) { |
70 | 78 | var is_cardrule = res.data.data.cardrules; |
71 | - var switch_list= res.data.data.switch_list; | |
72 | - var swi_arr=JSON.parse(switch_list); | |
79 | + var switch_list = res.data.data.switch_list; | |
80 | + var swi_arr = JSON.parse(switch_list); | |
73 | 81 | |
74 | 82 | w.wxParse("content", "html", is_cardrule, that, 6); |
75 | 83 | that.setData({ |
76 | - is_card_rule: is_cardrule, | |
77 | - isyaoqingma:parseInt(swi_arr.isyaoqingma), | |
78 | - is_salesman:parseInt(swi_arr.is_staffno) | |
84 | + is_card_rule: is_cardrule, | |
85 | + isyaoqingma: parseInt(swi_arr.isyaoqingma), | |
86 | + is_salesman: parseInt(swi_arr.is_staffno) | |
79 | 87 | }); |
80 | 88 | } |
81 | 89 | }); |
... | ... | @@ -85,12 +93,14 @@ Page({ |
85 | 93 | * 生命周期函数--监听页面显示 |
86 | 94 | */ |
87 | 95 | onShow: function () { |
88 | - var user_info = getApp().globalData.userInfo; | |
89 | - if(!user_info) return false; | |
90 | - | |
91 | - var th=this,that=th,app_d=getApp().globalData; | |
92 | - var store_id=os.stoid; | |
93 | - var fir_leader=this.data.fir_leader; | |
96 | + var user_info = getApp().globalData.userInfo; | |
97 | + if (!user_info) return false; | |
98 | + | |
99 | + var th = this, | |
100 | + that = th, | |
101 | + app_d = getApp().globalData; | |
102 | + var store_id = os.stoid; | |
103 | + var fir_leader = this.data.fir_leader; | |
94 | 104 | |
95 | 105 | if (fir_leader != null && fir_leader != undefined && fir_leader != "") { |
96 | 106 | var r_url = "/api/weshop/plus/vip/mem/list?storeId=" + store_id + "&userId=" + fir_leader |
... | ... | @@ -126,8 +136,12 @@ Page({ |
126 | 136 | } |
127 | 137 | if (is_ok == 1) { |
128 | 138 | //--保存或者更新会员信息-- |
129 | - that.setData({ def_recommon: user_information.MobileTel, def_serviceman: user_information.StaffNo, is_fengxiang: 1 }) | |
130 | - th.save_th_plus_user(); | |
139 | + that.setData({ | |
140 | + def_recommon: user_information.MobileTel, | |
141 | + def_serviceman: user_information.StaffNo, | |
142 | + is_fengxiang: 1 | |
143 | + }) | |
144 | + th.save_th_plus_user(); | |
131 | 145 | } |
132 | 146 | } |
133 | 147 | }); |
... | ... | @@ -138,14 +152,16 @@ Page({ |
138 | 152 | getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + app_d.user_id, { |
139 | 153 | success: function (e) { |
140 | 154 | var userInfo = e.data.data; |
141 | - if(userInfo['card_field'] && !getApp().globalData.is_card_back){ | |
142 | - var u_url = "/pages/user/cardinfo/cardinfo"; | |
143 | - wx.reLaunch({url: u_url}) | |
155 | + if (userInfo['card_field'] && !getApp().globalData.is_card_back) { | |
156 | + var u_url = "/pages/user/cardinfo/cardinfo"; | |
157 | + wx.reLaunch({ | |
158 | + url: u_url | |
159 | + }) | |
144 | 160 | } |
145 | 161 | }, |
146 | 162 | }); |
147 | 163 | |
148 | - this.getPlusCardType(); | |
164 | + this.getPlusCardType(); | |
149 | 165 | }, |
150 | 166 | |
151 | 167 | /** |
... | ... | @@ -170,18 +186,23 @@ Page({ |
170 | 186 | var plusCard = res.data.data; |
171 | 187 | var arr = [1219, 2089, 3031]; |
172 | 188 | var new_arr = new Array(); |
173 | - var parr=[]; | |
189 | + var parr = []; | |
174 | 190 | for (var i = 0; i < plusCard.length; i++) { |
175 | - //plusCard[i].free=arr[i]; | |
176 | - if(plusCard[i].IsStopBuy) { continue; } | |
177 | - if (plusCard[i].CardImg == "") plusCard[i].CardImg = th.data.url + "/miniapp/images/plus/bg"+(i + 1)+ ".jpg?v=1"; | |
178 | - var item = {"fee": plusCard[i].CardFee, 'index': i} | |
179 | - new_arr.push(item); | |
180 | - parr.push(plusCard[i]); | |
191 | + //plusCard[i].free=arr[i]; | |
192 | + if (plusCard[i].IsStopBuy) { | |
193 | + continue; | |
194 | + } | |
195 | + if (plusCard[i].CardImg == "") plusCard[i].CardImg = th.data.url + "/miniapp/images/plus/bg" + (i + 1) + ".jpg?v=1"; | |
196 | + var item = { | |
197 | + "fee": plusCard[i].CardFee, | |
198 | + 'index': i | |
199 | + } | |
200 | + new_arr.push(item); | |
201 | + parr.push(plusCard[i]); | |
181 | 202 | } |
182 | 203 | |
183 | 204 | //看是不是还有卡项是可以购买的 |
184 | - if(new_arr && new_arr.length>0){ | |
205 | + if (new_arr && new_arr.length > 0) { | |
185 | 206 | //根據距離遠近排序,越近在前面,升序 |
186 | 207 | new_arr.sort(function (a, b) { |
187 | 208 | if (a.fee < b.fee) { |
... | ... | @@ -195,39 +216,48 @@ Page({ |
195 | 216 | |
196 | 217 | //里面和外面要显示统一 |
197 | 218 | switch (new_arr.length) { |
198 | - case 1:arr=[3031]; break; | |
199 | - case 2: arr = [2089, 3031]; break; | |
200 | - case 3: arr = [1219, 2089, 3031];break; | |
219 | + case 1: | |
220 | + arr = [3031]; | |
221 | + break; | |
222 | + case 2: | |
223 | + arr = [2089, 3031]; | |
224 | + break; | |
225 | + case 3: | |
226 | + arr = [1219, 2089, 3031]; | |
227 | + break; | |
201 | 228 | } |
202 | 229 | |
203 | 230 | //---给数组添加立省多少钱--- |
204 | 231 | for (i = 0; i < parr.length; i++) { |
205 | - //判断是否停用 | |
206 | - for (var j = 0; j < new_arr.length; j++) { | |
207 | - if (i == new_arr[j].index) { | |
208 | - parr[i].free = arr[j]; | |
209 | - break; | |
210 | - } | |
232 | + //判断是否停用 | |
233 | + for (var j = 0; j < new_arr.length; j++) { | |
234 | + if (i == new_arr[j].index) { | |
235 | + parr[i].free = arr[j]; | |
236 | + break; | |
237 | + } | |
211 | 238 | } |
212 | 239 | } |
213 | 240 | th.setData({ |
214 | - is_plusCard: parr, is_show: 1 | |
241 | + is_plusCard: parr, | |
242 | + is_show: 1 | |
215 | 243 | }) |
216 | 244 | |
217 | - }else{ | |
218 | - th.setData({is_show: 1}); | |
219 | - wx.showToast({ | |
220 | - title: "暂无可购买的等级卡项", | |
221 | - icon: 'none', | |
222 | - duration: 4000 | |
223 | - }) | |
245 | + } else { | |
246 | + th.setData({ | |
247 | + is_show: 1 | |
248 | + }); | |
249 | + wx.showToast({ | |
250 | + title: "暂无可购买的等级卡项", | |
251 | + icon: 'none', | |
252 | + duration: 4000 | |
253 | + }) | |
224 | 254 | |
225 | - } | |
226 | - setTimeout(function(){ | |
227 | - var goods_list = th.selectComponent("#goods_list"); //组件的id | |
228 | - goods_list.init(); | |
229 | - goods_list.get_list(); | |
230 | - },1000) | |
255 | + } | |
256 | + setTimeout(function () { | |
257 | + var goods_list = th.selectComponent("#goods_list"); //组件的id | |
258 | + goods_list.init(); | |
259 | + goods_list.get_list(); | |
260 | + }, 1000) | |
231 | 261 | |
232 | 262 | }) |
233 | 263 | }, |
... | ... | @@ -241,33 +271,57 @@ Page({ |
241 | 271 | th.buy_card(); |
242 | 272 | } else { |
243 | 273 | //--如果后台都没有勾邀请码,营业员,立即购买-- |
244 | - if (!th.data.isyaoqingma && !th.data.is_salesman) {th.buy_card(); return false;} | |
245 | - th.setData({open_yq: 1}) | |
274 | + if (!th.data.isyaoqingma && !th.data.is_salesman) { | |
275 | + th.buy_card(); | |
276 | + return false; | |
277 | + } | |
278 | + th.setData({ | |
279 | + open_yq: 1 | |
280 | + }) | |
246 | 281 | } |
247 | 282 | }, |
248 | - | |
283 | + //--绑定邀请码的输入-- | |
284 | + b_input: function (e) { | |
285 | + var value = e.detail.value.trim(); | |
286 | + // let { isyaoqingma, is_salesman }=this.data; | |
287 | + var name = e.currentTarget.dataset.name; | |
288 | + // if((name=="isyaoqingma" && isyaoqingma) || (name=="is_salesman" && is_salesman) ){ | |
289 | + // if(!value){ | |
290 | + // wx.showToast({ | |
291 | + // title: '不能为空', | |
292 | + // }) | |
293 | + // return false; | |
294 | + // } | |
295 | + // } | |
296 | + var ob = {}; | |
297 | + ob[name] = value; | |
298 | + this.setData(ob); | |
299 | + }, | |
249 | 300 | //--立即购买卡-- |
250 | 301 | buy_card: async function () { |
251 | 302 | var th = this; |
252 | 303 | var is_card = 0; |
253 | 304 | //--商家是不是有等级卡功能,开通的人数是不是够用,开通是时间是不是到期-- |
254 | - await getApp().request.promiseGet("/api/weshop/plus/plus/card/register", | |
255 | - {data: {storeId: os.stoid}}).then(res => { | |
305 | + await getApp().request.promiseGet("/api/weshop/plus/plus/card/register", { | |
306 | + data: { | |
307 | + storeId: os.stoid | |
308 | + } | |
309 | + }).then(res => { | |
256 | 310 | if (res.data.code == 0) is_card = 1; |
257 | 311 | }) |
258 | 312 | if (is_card == 0) { |
259 | - getApp().my_warnning("请联系商家升级plus功能", 0, th); | |
260 | - return false; | |
261 | - } | |
262 | - | |
313 | + getApp().my_warnning("请联系商家升级plus功能", 0, th); | |
314 | + return false; | |
315 | + } | |
316 | + | |
263 | 317 | var item = th.data.is_plusCard[th.data.by_index]; |
264 | 318 | var req = {}; |
265 | 319 | req.cardId = item.CardId; |
266 | 320 | req.rechargeType = 3; |
267 | 321 | //如果不是你导购,也不是等级会员分享 |
268 | 322 | if (th.data.is_fengxiang == 1) { |
269 | - if (th.data.def_recommon) req.recommon = th.data.def_recommon | |
270 | - if (th.data.def_serviceman) req.serviceman = th.data.def_serviceman | |
323 | + if (th.data.def_recommon) req.recommon = th.data.def_recommon | |
324 | + if (th.data.def_serviceman) req.serviceman = th.data.def_serviceman | |
271 | 325 | } else { |
272 | 326 | //---后台要求要输入邀请码--- |
273 | 327 | if (th.data.isyaoqingma) { |
... | ... | @@ -275,13 +329,12 @@ Page({ |
275 | 329 | getApp().my_warnning("请输入邀请码", 0, th); |
276 | 330 | return false; |
277 | 331 | } |
278 | - | |
279 | - //--邀请人不能是自己的手机号-- | |
280 | - if(th.data.inp_recommon==getApp().globalData.userInfo.mobile){ | |
281 | - getApp().my_warnning("邀请人不能填自已", 0, th); | |
282 | - return false; | |
283 | - } | |
284 | - | |
332 | + | |
333 | + //--邀请人不能是自己的手机号-- | |
334 | + if (th.data.inp_recommon == getApp().globalData.userInfo.mobile) { | |
335 | + getApp().my_warnning("邀请人不能填自已", 0, th); | |
336 | + return false; | |
337 | + } | |
285 | 338 | req.recommon = th.data.inp_recommon |
286 | 339 | } |
287 | 340 | //--后台要求要输入营业员-- |
... | ... | @@ -296,137 +349,166 @@ Page({ |
296 | 349 | req.storeId = os.stoid; |
297 | 350 | req.userId = getApp().globalData.user_id; |
298 | 351 | //--如果有邀请码,和营业员的情况下-- |
299 | - if(req.recommon || req.serviceman ) { | |
300 | - var req_data = {storeId: os.stoid, userId: req.userId}; | |
301 | - if(req.recommon) req_data.inviteCode=req.recommon; | |
302 | - if(req.serviceman) req_data.staffNo=req.serviceman; | |
352 | + if (req.recommon || req.serviceman) { | |
353 | + var req_data = { | |
354 | + storeId: os.stoid, | |
355 | + userId: req.userId | |
356 | + }; | |
357 | + if (req.recommon) req_data.inviteCode = req.recommon; | |
358 | + if (req.serviceman) req_data.staffNo = req.serviceman; | |
303 | 359 | getApp().request.get("/api/weshop/plus/vip/mem/referee/code/check", { |
304 | - data:req_data, | |
305 | - success:function(res){ | |
306 | - if(res.data.code==0) { | |
307 | - t_pay.pay(req, th.success, function () { | |
308 | - getApp().my_warnning("支付失败", 0, th); | |
309 | - }); | |
310 | - }else{ | |
311 | - getApp().my_warnning(res.data.msg, 0, th); | |
312 | - } | |
313 | - } | |
360 | + data: req_data, | |
361 | + success: function (res) { | |
362 | + if (res.data.code == 0) { | |
363 | + t_pay.pay(req, th.success, function () { | |
364 | + getApp().my_warnning("支付失败", 0, th); | |
365 | + }); | |
366 | + } else { | |
367 | + getApp().my_warnning(res.data.msg, 0, th); | |
368 | + } | |
369 | + } | |
314 | 370 | }) |
315 | - }else{ | |
371 | + } else { | |
316 | 372 | t_pay.pay(req, th.success, function () { |
317 | 373 | getApp().my_warnning("支付失败", 0, th); |
318 | 374 | }); |
319 | 375 | } |
320 | 376 | }, |
321 | 377 | //返回会员页面 |
322 | - OpeningClose: function() { | |
323 | - this.setData({open_yq:0}); | |
378 | + OpeningClose: function () { | |
379 | + this.setData({ | |
380 | + open_yq: 0 | |
381 | + }); | |
324 | 382 | }, |
325 | 383 | |
326 | 384 | //返回会员中心 |
327 | - back_user:function () { | |
385 | + back_user: function () { | |
328 | 386 | setTimeout(function () { |
329 | - wx.reLaunch({url:"/pages/user/index/index"}); | |
330 | - },1000) | |
387 | + wx.reLaunch({ | |
388 | + url: "/pages/user/index/index" | |
389 | + }); | |
390 | + }, 1000) | |
331 | 391 | }, |
332 | - | |
392 | + | |
333 | 393 | //--支付成功,跳转到等级卡续费页面-- |
334 | - success:function () { | |
335 | - //调一次就不再调用了 | |
336 | - if(getApp().globalData.is_card_back) return false; | |
337 | - if(getApp().globalData.plus_buy_back){ | |
338 | - //值在这里换 | |
339 | - getApp().globalData.is_card_back=1; | |
340 | - getApp().globalData.plus_buy_back=0; | |
341 | - //返回购物车购买 | |
342 | - wx.navigateBack({ delta: 1,}); | |
343 | - return false; | |
344 | - }else{ | |
345 | - var u_url = "/pages/user/cardinfo/cardinfo"; | |
346 | - wx.reLaunch({url: u_url}) | |
347 | - } | |
348 | - | |
349 | - }, | |
394 | + success: function () { | |
395 | + //调一次就不再调用了 | |
396 | + if (getApp().globalData.is_card_back) return false; | |
397 | + if (getApp().globalData.plus_buy_back) { | |
398 | + //值在这里换 | |
399 | + getApp().globalData.is_card_back = 1; | |
400 | + getApp().globalData.plus_buy_back = 0; | |
401 | + //返回购物车购买 | |
402 | + wx.navigateBack({ | |
403 | + delta: 1, | |
404 | + }); | |
405 | + return false; | |
406 | + } else { | |
407 | + var u_url = "/pages/user/cardinfo/cardinfo"; | |
408 | + wx.reLaunch({ | |
409 | + url: u_url | |
410 | + }) | |
411 | + } | |
350 | 412 | |
351 | - //--绑定邀请码的输入-- | |
352 | - b_input:function (e) { | |
353 | - var value=e.detail.value; | |
354 | - var name=e.currentTarget.dataset.name; | |
355 | - var ob={}; | |
356 | - ob[name]=value | |
357 | - this.setData(ob); | |
358 | 413 | }, |
359 | 414 | |
360 | - get_user_plus:async function(){ | |
361 | - var user_id=getApp().globalData.user_id; | |
362 | - var fuser=null; | |
363 | - var user_information =null; | |
364 | - var store_id = os.stoid; | |
365 | - var that=this; | |
366 | - //--获取登记卡邀请信息-- | |
367 | - await getApp().request.promiseGet("/api/weshop/usersPlus/get/" + os.stoid + "/" + user_id,{1:1}).then(res=>{ | |
368 | - if (res.data.code==0){ | |
369 | - fuser=res.data.data; | |
370 | - } | |
371 | - }) | |
372 | - if (!fuser) return false; | |
373 | - var r_url = "/api/weshop/plus/vip/mem/list?storeId=" + store_id + "&userId=" + fuser.plus_user_id; | |
374 | - //--获取等级卡信息-- | |
375 | - await getApp().request.promiseGet(r_url,{1:1}).then(res=>{ | |
376 | - if (res.data.code == 0) { | |
377 | - user_information = res.data.data[0]; | |
378 | - } | |
379 | - }) | |
380 | - if (user_information){ | |
381 | - var now = ut.gettimestamp(); | |
382 | - var is_ok = 1; | |
383 | - if (user_information['ExpiryDate']) { | |
384 | - var str = user_information['ExpiryDate'].replace(/-/g, '/'); | |
385 | - var end = new Date(str); | |
386 | - end = Date.parse(end) / 1000; | |
387 | - if (end < now) { is_ok = 0;} | |
388 | - } else { | |
415 | + | |
416 | + | |
417 | + get_user_plus: async function () { | |
418 | + var user_id = getApp().globalData.user_id; | |
419 | + var fuser = null; | |
420 | + var user_information = null; | |
421 | + var store_id = os.stoid; | |
422 | + var that = this; | |
423 | + //--获取登记卡邀请信息-- | |
424 | + await getApp().request.promiseGet("/api/weshop/usersPlus/get/" + os.stoid + "/" + user_id, { | |
425 | + 1: 1 | |
426 | + }).then(res => { | |
427 | + if (res.data.code == 0) { | |
428 | + fuser = res.data.data; | |
429 | + } | |
430 | + }) | |
431 | + if (!fuser) return false; | |
432 | + var r_url = "/api/weshop/plus/vip/mem/list?storeId=" + store_id + "&userId=" + fuser.plus_user_id; | |
433 | + //--获取等级卡信息-- | |
434 | + await getApp().request.promiseGet(r_url, { | |
435 | + 1: 1 | |
436 | + }).then(res => { | |
437 | + if (res.data.code == 0) { | |
438 | + user_information = res.data.data[0]; | |
439 | + } | |
440 | + }) | |
441 | + if (user_information) { | |
442 | + var now = ut.gettimestamp(); | |
443 | + var is_ok = 1; | |
444 | + if (user_information['ExpiryDate']) { | |
445 | + var str = user_information['ExpiryDate'].replace(/-/g, '/'); | |
446 | + var end = new Date(str); | |
447 | + end = Date.parse(end) / 1000; | |
448 | + if (end < now) { | |
389 | 449 | is_ok = 0; |
390 | 450 | } |
451 | + } else { | |
452 | + is_ok = 0; | |
453 | + } | |
391 | 454 | |
392 | - if (is_ok == 1) { | |
393 | - var fir_leader=fuser.plus_user_id | |
394 | - that.setData({ def_recommon: user_information.MobileTel, def_serviceman: user_information.StaffNo, is_fengxiang: 1,fir_leader:fir_leader }) | |
395 | - //--先判断会员状态-- | |
396 | - var user_info = getApp().globalData.userInfo; | |
397 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
398 | - wx.navigateTo({ url: '/pages/togoin/togoin?first_leader=' + fir_leader, }) | |
399 | - return false; | |
400 | - } | |
455 | + if (is_ok == 1) { | |
456 | + var fir_leader = fuser.plus_user_id | |
457 | + that.setData({ | |
458 | + def_recommon: user_information.MobileTel, | |
459 | + def_serviceman: user_information.StaffNo, | |
460 | + is_fengxiang: 1, | |
461 | + fir_leader: fir_leader | |
462 | + }) | |
463 | + //--先判断会员状态-- | |
464 | + var user_info = getApp().globalData.userInfo; | |
465 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
466 | + wx.navigateTo({ | |
467 | + url: '/pages/togoin/togoin?first_leader=' + fir_leader, | |
468 | + }) | |
469 | + return false; | |
470 | + } | |
401 | 471 | } |
402 | - } | |
472 | + } | |
403 | 473 | }, |
404 | - | |
405 | - save_th_plus_user:async function(){ | |
406 | - var f_user_id=this.data.fir_leader; | |
407 | - if (f_user_id){ | |
474 | + | |
475 | + save_th_plus_user: async function () { | |
476 | + var f_user_id = this.data.fir_leader; | |
477 | + if (f_user_id) { | |
408 | 478 | var user_id = getApp().globalData.user_id; |
409 | 479 | var user_plus = null; |
410 | - var now=ut.gettimestamp(); | |
480 | + var now = ut.gettimestamp(); | |
411 | 481 | //--获取登记卡邀请信息-- |
412 | - await getApp().request.promiseGet("/api/weshop/usersPlus/get/" + os.stoid + "/" + user_id, { 1: 1 }).then(res => { | |
482 | + await getApp().request.promiseGet("/api/weshop/usersPlus/get/" + os.stoid + "/" + user_id, { | |
483 | + 1: 1 | |
484 | + }).then(res => { | |
413 | 485 | if (res.data.code == 0) { |
414 | 486 | user_plus = res.data.data; |
415 | 487 | } |
416 | - }) | |
417 | - | |
488 | + }) | |
489 | + | |
418 | 490 | //--如果有值,要更新-- |
419 | - if (!user_plus){ | |
420 | - getApp().request.post("/api/weshop/usersPlus/save", { | |
421 | - data: { store_id: os.stoid, user_id: user_id, plus_user_id: f_user_id, addtime: now }, | |
422 | - success: function (res) { } | |
423 | - }) | |
424 | - }else{ | |
425 | - getApp().request.put("/api/weshop/usersPlus/update",{ | |
426 | - data: { store_id: os.stoid, user_id: user_id, plus_user_id: f_user_id, edittime: now}, | |
427 | - success:function(res){ } | |
428 | - }) | |
491 | + if (!user_plus) { | |
492 | + getApp().request.post("/api/weshop/usersPlus/save", { | |
493 | + data: { | |
494 | + store_id: os.stoid, | |
495 | + user_id: user_id, | |
496 | + plus_user_id: f_user_id, | |
497 | + addtime: now | |
498 | + }, | |
499 | + success: function (res) {} | |
500 | + }) | |
501 | + } else { | |
502 | + getApp().request.put("/api/weshop/usersPlus/update", { | |
503 | + data: { | |
504 | + store_id: os.stoid, | |
505 | + user_id: user_id, | |
506 | + plus_user_id: f_user_id, | |
507 | + edittime: now | |
508 | + }, | |
509 | + success: function (res) {} | |
510 | + }) | |
429 | 511 | } |
430 | - } | |
512 | + } | |
431 | 513 | } |
432 | 514 | }) |
433 | 515 | \ No newline at end of file | ... | ... |