Commit ece4303b2ec71377f13870d834a2cdb9612543d1

Authored by yvan.ni
1 parent 767a574a

3.0注册的优化

packageA/pages/profile/profile.js
@@ -1050,7 +1050,22 @@ Page({ @@ -1050,7 +1050,22 @@ Page({
1050 1050
1051 if (e.data.code == 0) { 1051 if (e.data.code == 0) {
1052 app.globalData.user_id = e.data.data.user_id; 1052 app.globalData.user_id = e.data.data.user_id;
1053 - } else { 1053 + }
  1054 + else if(e.data.code==-3){
  1055 + wx.showModal({
  1056 + title: e.data.msg,
  1057 + success: function (e) {
  1058 + if(e.confirm){
  1059 + dd.isreplacemobile=1;
  1060 + if (th.data.loading) return false;
  1061 + th.setData({loading: 1});
  1062 + th.zu_ce(dd);
  1063 + }
  1064 + }
  1065 + });
  1066 + return false;
  1067 + }
  1068 + else {
1054 return ut.m_toast("授权登入失败!" + e.data.msg); 1069 return ut.m_toast("授权登入失败!" + e.data.msg);
1055 } 1070 }
1056 getApp().globalData.login_back = 1; 1071 getApp().globalData.login_back = 1;
packageD/components/diy_login/login.js
@@ -175,103 +175,245 @@ Component({ @@ -175,103 +175,245 @@ Component({
175 }) 175 })
176 }, 176 },
177 177
178 - 178 +
  179 +
179 save_the_data: async function (r, e, sessionKey, openid) { 180 save_the_data: async function (r, e, sessionKey, openid) {
180 var app = getApp(), a = app, th = this; 181 var app = getApp(), a = app, th = this;
181 - var dd = {  
182 - oauth: "miniapp",  
183 - nickname: a.clear_word(r.nickName),  
184 - head_pic: r.avatarUrl,  
185 - sex: r.gender,  
186 - terminal: "miniapp",  
187 - sessionKey: sessionKey,  
188 - openid: openid,  
189 - encryptedData: e.encryptedData,  
190 - iv: e.iv,  
191 - store_id: getApp().globalData.setting.stoid,  
192 - };  
193 - //--如果有邀请人的时候--  
194 - if (th.data.first_leader) {  
195 - //判断一下分享人是不是分享商  
196 - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + th.data.first_leader, {}).then(res => {  
197 - if (res.data.code == 0) {  
198 - var user = res.data.data;  
199 - if (user.is_distribut == 1) { 182 +
  183 + app.request.get("/api/weshop/manager/managerConfig/get", {
  184 + data: {
  185 + storeId: getApp().globalData.setting.stoid
  186 + },
  187 + success: function (res2) {
  188 + if (res2.data.code == 0) {
  189 + if (res2.data.data.is_newphone == 1) {
  190 + var dd = {
  191 + oauth: "miniapp",
  192 + nickname: a.clear_word(r.nickName),
  193 + head_pic: r.avatarUrl,
  194 + sex: r.gender,
  195 + terminal: "miniapp",
  196 + sessionKey: sessionKey,
  197 + openid: openid,
  198 + code: e.code,
  199 + isNewPhone: 1,
  200 + store_id: getApp().globalData.setting.stoid,
  201 + };
  202 + } else {
  203 + var dd = {
  204 + oauth: "miniapp",
  205 + nickname: a.clear_word(r.nickName),
  206 + head_pic: r.avatarUrl,
  207 + sex: r.gender,
  208 + terminal: "miniapp",
  209 + sessionKey: sessionKey,
  210 + openid: openid,
  211 + encryptedData: e.encryptedData,
  212 + iv: e.iv,
  213 + store_id: getApp().globalData.setting.stoid,
  214 + };
  215 + }
  216 +
  217 +
  218 + //--如果有邀请人的时候--
  219 + if (th.data.first_leader) {
200 dd.first_leader = th.data.first_leader; 220 dd.first_leader = th.data.first_leader;
201 } 221 }
  222 + //-- 导购会员ID --
  223 + if (getApp().globalData.guide_id) {
  224 + dd.guide_id = getApp().globalData.guide_id;
  225 + }
  226 +
  227 + //门店的扫描识别码
  228 + if (getApp().globalData.store_number) {
  229 + dd.SunCode = encodeURIComponent(getApp().globalData.store_number.trim());
  230 + }
  231 +
  232 + console.log("-----会员注册的信息-------");
  233 + console.log(dd);
  234 +
  235 +
  236 + var need_go = 0;
  237 + //如果有需要完善的信息没有完善,就需要跳转
  238 + if (th.data.name_need_go) { need_go = 1; }
  239 + if (th.data.birth_need_go) { need_go = 1; }
  240 + if (th.data.idcard_need_go) { need_go = 1; }
  241 + if (th.data.address_need_go) { need_go = 1; }
  242 + if (th.data.pick_need_go) { need_go = 1; }
  243 + if (th.data.sex_need_go) { need_go = 1; }
  244 + if (th.data.introducer_need_go) { need_go = 1; }
  245 +
  246 + if (need_go) {
  247 +
  248 + if (res2.data.data.is_newphone == 1) {
  249 + var req_data = {
  250 + sessionKey: sessionKey,
  251 + code: e.code,
  252 + isNewPhone: 1,
  253 + store_id: getApp().globalData.setting.stoid,
  254 + }
  255 + }else{
  256 + var req_data = {
  257 + sessionKey: sessionKey,
  258 + encryptedData: e.encryptedData,
  259 + iv: e.iv,
  260 + store_id: getApp().globalData.setting.stoid,
  261 + }
  262 + }
  263 + //-- 获取一下手机 --
  264 + getApp().request.promiseGet("/api/weshop/users/getmobile", { data: req_data }).then(res => {
  265 + if (res.data.code == 0) {
  266 + dd.mobile = res.data.data;
  267 + getApp().globalData.zc_dd = dd;
  268 +
  269 + var g_url="/packageA/pages/profile/profile?is_back=1";
  270 + if(th.data.is_reg){
  271 + g_url+="&is_reg=1";
  272 + }
  273 +
  274 + th.cancle_bind();//关闭
  275 + wx.navigateTo({
  276 + url:g_url
  277 + })
  278 + }
  279 + })
  280 +
  281 + } else {
  282 + if (th.data.is_lable_set) {
  283 + if (res2.data.data.is_newphone == 1) {
  284 + var req_data = {
  285 + sessionKey: sessionKey,
  286 + code: e.code,
  287 + isNewPhone: 1,
  288 + store_id: getApp().globalData.setting.stoid,
  289 + }
  290 + }else{
  291 + var req_data = {
  292 + sessionKey: sessionKey,
  293 + encryptedData: e.encryptedData,
  294 + iv: e.iv,
  295 + store_id: getApp().globalData.setting.stoid,
  296 + }
  297 + }
  298 +
  299 + //-- 获取一下手机 --
  300 + getApp().request.promiseGet("/api/weshop/users/getmobile", { data: req_data }).then(res => {
  301 + if (res.data.code == 0) {
  302 + dd.mobile = res.data.data;
  303 + getApp().globalData.zc_dd = dd;
  304 +
  305 + var g_url="/packageE/pages/user/labels/labels?pageType=1";
  306 + if(th.data.is_reg){
  307 + g_url+="&is_reg=1";
  308 + }
  309 +
  310 + th.cancle_bind();//关闭
  311 + wx.navigateTo({ url: g_url })
  312 + }
  313 + })
  314 + } else {
  315 +
  316 + th.setData({ sub: 0 });
  317 + wx.showLoading({
  318 + title: '处理中.',
  319 + mask: true
  320 + })
  321 + th.zu_ce(dd); //调用注册的函数
  322 + }
  323 + }
  324 +
  325 +
  326 + } else {
  327 + th.setData({ sub: 0 });
  328 + return app.my_warnning("授权登入失败,请稍后再试!", 0, that);
202 } 329 }
203 - })  
204 - }  
205 - //-- 导购会员ID --  
206 - if (getApp().globalData.guide_id) {  
207 - dd.guide_id = getApp().globalData.guide_id;  
208 - } 330 + },
  331 + failStatus: function (t) {
  332 + th.setData({ sub: 0 });
  333 + return app.my_warnning("授权登入失败,请稍后再试!", 0, that);
  334 + },
  335 + fail: function (t) {
  336 + th.setData({ sub: 0 });
  337 + return i.clearAuth(), i.alertLoginErrorAndGoHome(), !1;
  338 + }
  339 + });
  340 + },
209 341
210 - //门店的扫描识别码  
211 - if (getApp().globalData.store_number) {  
212 - dd.SunCode = encodeURIComponent(getApp().globalData.store_number.trim()); 342 + zu_ce: function (dd) {
  343 +
  344 +
  345 + if(this.data.sub) return false;
  346 + this.setData({ sub: 1 });
  347 +
  348 + if(getApp().globalData.h5_openid){
  349 + dd.wxopenid=getApp().globalData.h5_openid;
213 } 350 }
214 351
215 - console.log("-----会员注册的信息-------");  
216 - console.log(dd); 352 + var th = this;
217 app.request.get("/api/weshop/users/thirdLogin", { 353 app.request.get("/api/weshop/users/thirdLogin", {
218 data: dd, 354 data: dd,
219 success: function (e) { 355 success: function (e) {
220 356
  357 + wx.hideLoading();
  358 + th.setData({ sub: 0 });
  359 +
221 if (e.data.code == 0) { 360 if (e.data.code == 0) {
  361 + th.cancle_bind();//关闭
222 app.globalData.user_id = e.data.data.user_id; 362 app.globalData.user_id = e.data.data.user_id;
223 - } else { 363 + app.globalData.userInfo = e.data.data;
  364 + }
  365 + else if(e.data.code==-3){
  366 + wx.showModal({
  367 + title: e.data.msg,
  368 + success: function (e) {
  369 + if(e.confirm){
  370 + dd.isreplacemobile=1;
  371 + th.zu_ce(dd);
  372 + }
  373 + }
  374 + });
  375 + return false;
  376 + }
  377 + else {
224 return app.showWarning("授权登入失败!" + e.data.msg); 378 return app.showWarning("授权登入失败!" + e.data.msg);
225 } 379 }
  380 + getApp().globalData.login_back = 1;
  381 + wx.setStorageSync("userinfo", e.data.data);
  382 + wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(app.globalData.userInfo.head_pic);
226 383
  384 + //调用接口判断是不是会员
  385 + app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + e.data.data.user_id, {}).then(res => {
  386 + if (res.data.code == 0) {
  387 + getApp().globalData.guide_id = res.data.data.id;
  388 + getApp().globalData.guide_pick_id = res.data.data.pickup_id
  389 + }
  390 + })
227 391
228 - var need_go = 0;  
229 - var t_user = e.data.data; 392 + getApp().showWarning("绑定成功");
230 393
  394 + setTimeout(()=>{
  395 + //-- 看情况,是跳转等级卡,还是跳转到新人有礼 --
  396 + getApp().go_to_page(th.data.is_reg,function (){
231 397
232 - getApp().globalData.login_back = 1;  
233 - wx.setStorageSync("userinfo", e.data.data);  
234 - wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(a.globalData.userInfo.head_pic); 398 + })
  399 + },1000)
235 400
236 - //如果有需要完善的信息没有完善,就需要跳转  
237 - if (!t_user['vipname'] && th.data.name_need_go) {  
238 - need_go = 1;  
239 - }  
240 - if (!t_user['birthday'] && th.data.birth_need_go) {  
241 - need_go = 1;  
242 - }  
243 - if (!t_user['idcard'] && th.data.idcard_need_go) {  
244 - need_go = 1;  
245 - }  
246 - if (!t_user['address'] && th.data.address_need_go) {  
247 - need_go = 1;  
248 - }  
249 - if (!t_user['pickup_id'] && th.data.pick_need_go) {  
250 - need_go = 1;  
251 - }  
252 - if (!t_user['sex'] && th.data.sex_need_go) {  
253 - need_go = 1;  
254 - }  
255 - if (!t_user['fromuser_id'] && th.data.introducer_need_go) {  
256 - need_go = 1;  
257 - }  
258 401
259 - if (need_go) {  
260 - getApp().goto("/packageA/pages/profile/profile?is_back=1");  
261 - } else {  
262 - that.cancle_bind();//关闭  
263 - }  
264 402
265 }, 403 },
266 failStatus: function (t) { 404 failStatus: function (t) {
267 - return app.my_warnning("授权登入失败,请稍后再试!", 0, that); 405 + th.setData({ sub: 0 });
  406 + return app.my_warnning("授权登入失败,请稍后再试!", 0, th);
268 }, 407 },
269 fail: function (t) { 408 fail: function (t) {
  409 + th.setData({ sub: 0 });
270 return i.clearAuth(), i.alertLoginErrorAndGoHome(), !1; 410 return i.clearAuth(), i.alertLoginErrorAndGoHome(), !1;
271 } 411 }
272 }); 412 });
273 }, 413 },
274 414
  415 +
  416 +
275 bind_bnerr: function (e) { 417 bind_bnerr: function (e) {
276 var _errImg = e.target.dataset.errorimg; 418 var _errImg = e.target.dataset.errorimg;
277 var _errObj = {}; 419 var _errObj = {};
packageE/pages/togoin/togoin.js
@@ -12,7 +12,8 @@ Page({ @@ -12,7 +12,8 @@ Page({
12 first_leader: '', //-- 邀请人 -- 12 first_leader: '', //-- 邀请人 --
13 config2: null, 13 config2: null,
14 sub: 0, 14 sub: 0,
15 - is_reg:1 15 + is_reg:1,
  16 + openid:''
16 }, 17 },
17 onLoad: function (options) { 18 onLoad: function (options) {
18 if (wx.getUserProfile) { 19 if (wx.getUserProfile) {
@@ -22,6 +23,14 @@ Page({ @@ -22,6 +23,14 @@ Page({
22 } 23 }
23 getApp().globalData.isLoad_ad = 1; 24 getApp().globalData.isLoad_ad = 1;
24 25
  26 + if(options.openid){
  27 + this.data.openid=options.openid;
  28 + getApp().globalData.h5_openid=options.openid;
  29 +
  30 + console.log("options.openid")
  31 + console.log(options.openid)
  32 + }
  33 +
25 // if(options.is_reg){ 34 // if(options.is_reg){
26 // this.data.is_reg=1; 35 // this.data.is_reg=1;
27 // } 36 // }
@@ -78,6 +87,20 @@ Page({ @@ -78,6 +87,20 @@ Page({
78 th.setData({ template_id: template_id }); 87 th.setData({ template_id: template_id });
79 } 88 }
80 }) 89 })
  90 +
  91 + setTimeout(()=>{
  92 + if(getApp().globalData.user_id){
  93 + getApp().goto('/pages/user/index/index');
  94 + }else{
  95 + if(!this.data.openid){
  96 + //getApp().goto('/packageH/pages/getopenid/index');
  97 + }
  98 + }
  99 +
  100 + },800)
  101 +
  102 +
  103 +
81 }, 104 },
82 105
83 106
@@ -380,7 +403,7 @@ Page({ @@ -380,7 +403,7 @@ Page({
380 } 403 }
381 }) 404 })
382 } else { 405 } else {
383 - th.setData({ sub: 1 }); 406 + th.setData({ sub: 0 });
384 wx.showLoading({ 407 wx.showLoading({
385 title: '处理中.', 408 title: '处理中.',
386 mask: true 409 mask: true
@@ -406,22 +429,45 @@ Page({ @@ -406,22 +429,45 @@ Page({
406 }); 429 });
407 }, 430 },
408 431
  432 +
  433 +
409 zu_ce: function (dd) { 434 zu_ce: function (dd) {
  435 +
  436 +
  437 + if(this.data.sub) return false;
  438 + this.setData({ sub: 1 });
  439 +
  440 + if(getApp().globalData.h5_openid){
  441 + dd.wxopenid=getApp().globalData.h5_openid;
  442 + }
  443 +
410 var th = this; 444 var th = this;
411 app.request.get("/api/weshop/users/thirdLogin", { 445 app.request.get("/api/weshop/users/thirdLogin", {
412 data: dd, 446 data: dd,
413 success: function (e) { 447 success: function (e) {
  448 +
  449 + wx.hideLoading();
  450 + th.setData({ sub: 0 });
  451 +
414 if (e.data.code == 0) { 452 if (e.data.code == 0) {
415 app.globalData.user_id = e.data.data.user_id; 453 app.globalData.user_id = e.data.data.user_id;
416 - } else {  
417 -  
418 - wx.showToast({  
419 - title: "授权登入失败!" + e.data.msg,  
420 - icon: 'none',  
421 - duration: 2000 454 + app.globalData.userInfo = e.data.data;
  455 + }
  456 + else if(e.data.code==-3){
  457 + wx.showModal({
  458 + title: e.data.msg,
  459 + success: function (e) {
  460 + if(e.confirm){
  461 + dd.isreplacemobile=1;
  462 + th.zu_ce(dd);
  463 + }
  464 + }
422 }); 465 });
423 return false; 466 return false;
424 } 467 }
  468 + else {
  469 + return app.showWarning("授权登入失败!" + e.data.msg);
  470 + }
425 getApp().globalData.login_back = 1; 471 getApp().globalData.login_back = 1;
426 wx.setStorageSync("userinfo", e.data.data); 472 wx.setStorageSync("userinfo", e.data.data);
427 wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(app.globalData.userInfo.head_pic); 473 wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(app.globalData.userInfo.head_pic);
@@ -440,7 +486,6 @@ Page({ @@ -440,7 +486,6 @@ Page({
440 }) 486 })
441 487
442 488
443 -  
444 }, 489 },
445 failStatus: function (t) { 490 failStatus: function (t) {
446 th.setData({ sub: 0 }); 491 th.setData({ sub: 0 });
@@ -453,7 +498,6 @@ Page({ @@ -453,7 +498,6 @@ Page({
453 }); 498 });
454 }, 499 },
455 500
456 -  
457 bind_bnerr: function (e) { 501 bind_bnerr: function (e) {
458 var _errImg = e.target.dataset.errorimg; 502 var _errImg = e.target.dataset.errorimg;
459 var _errObj = {}; 503 var _errObj = {};
packageE/pages/user/labels/labels.js
@@ -247,7 +247,11 @@ Page({ @@ -247,7 +247,11 @@ Page({
247 th.setData({ 247 th.setData({
248 is_check: 1 248 is_check: 1
249 }) 249 })
250 - 250 +
  251 + if(getApp().globalData.h5_openid){
  252 + getApp().globalData.zc_dd.openid=getApp().globalData.h5_openid;
  253 + }
  254 +
251 app.request.get("/api/weshop/users/thirdLogin", { 255 app.request.get("/api/weshop/users/thirdLogin", {
252 data: getApp().globalData.zc_dd, 256 data: getApp().globalData.zc_dd,
253 success: function (e) { 257 success: function (e) {
@@ -291,7 +295,25 @@ Page({ @@ -291,7 +295,25 @@ Page({
291 }) 295 })
292 296
293 }, 2000); 297 }, 2000);
294 - } else { 298 + }
  299 +
  300 + else if(e.data.code==-3){
  301 + wx.showModal({
  302 + title: e.data.msg,
  303 + success: function (e) {
  304 + if(e.confirm){
  305 + getApp().globalData.zc_dd.isreplacemobile=1;
  306 + th.setData({loading: 0,is_check:0});
  307 + th.update_label();
  308 + }
  309 + }
  310 + });
  311 + return false;
  312 +
  313 + }
  314 +
  315 +
  316 + else {
295 getApp().my_warnning("系统繁忙,请稍后再试", 0, th); 317 getApp().my_warnning("系统繁忙,请稍后再试", 0, th);
296 th.setData({ 318 th.setData({
297 is_check: 0 319 is_check: 0
@@ -429,13 +451,34 @@ Page({ @@ -429,13 +451,34 @@ Page({
429 451
430 this.setData({ is_check: 1 }) 452 this.setData({ is_check: 1 })
431 453
  454 + if(getApp().globalData.h5_openid){
  455 + getApp().globalData.zc_dd.openid=getApp().globalData.h5_openid;
  456 + }
  457 +
432 app.request.get("/api/weshop/users/thirdLogin", { 458 app.request.get("/api/weshop/users/thirdLogin", {
433 data: getApp().globalData.zc_dd, 459 data: getApp().globalData.zc_dd,
434 success: function (e) { 460 success: function (e) {
435 wx.hideLoading(); 461 wx.hideLoading();
436 if (e.data.code == 0) { 462 if (e.data.code == 0) {
437 app.globalData.user_id = e.data.data.user_id; 463 app.globalData.user_id = e.data.data.user_id;
438 - } else { 464 + }
  465 +
  466 + else if(e.data.code==-3){
  467 +
  468 + wx.showModal({
  469 + title: e.data.msg,
  470 + success: function (e) {
  471 + if(e.confirm){
  472 + getApp().globalData.zc_dd.isreplacemobile=1;
  473 + th.setData({loading: 0,is_check:0});
  474 + th.goto_user();
  475 + }
  476 + }
  477 + });
  478 + return false;
  479 + }
  480 +
  481 + else {
439 return app.showWarning("授权登入失败!" + e.data.msg); 482 return app.showWarning("授权登入失败!" + e.data.msg);
440 } 483 }
441 getApp().globalData.login_back = 1; 484 getApp().globalData.login_back = 1;