From ece4303b2ec71377f13870d834a2cdb9612543d1 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Thu, 29 Aug 2024 11:07:52 +0800 Subject: [PATCH] 3.0注册的优化 --- packageA/pages/profile/profile.js | 17 ++++++++++++++++- packageD/components/diy_login/login.js | 272 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------- packageE/pages/togoin/togoin.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- packageE/pages/user/labels/labels.js | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 323 insertions(+), 79 deletions(-) diff --git a/packageA/pages/profile/profile.js b/packageA/pages/profile/profile.js index 86f3a58..1033966 100644 --- a/packageA/pages/profile/profile.js +++ b/packageA/pages/profile/profile.js @@ -1050,7 +1050,22 @@ Page({ if (e.data.code == 0) { app.globalData.user_id = e.data.data.user_id; - } else { + } + else if(e.data.code==-3){ + wx.showModal({ + title: e.data.msg, + success: function (e) { + if(e.confirm){ + dd.isreplacemobile=1; + if (th.data.loading) return false; + th.setData({loading: 1}); + th.zu_ce(dd); + } + } + }); + return false; + } + else { return ut.m_toast("授权登入失败!" + e.data.msg); } getApp().globalData.login_back = 1; diff --git a/packageD/components/diy_login/login.js b/packageD/components/diy_login/login.js index 6533841..23d69dd 100644 --- a/packageD/components/diy_login/login.js +++ b/packageD/components/diy_login/login.js @@ -175,103 +175,245 @@ Component({ }) }, - + + save_the_data: async function (r, e, sessionKey, openid) { var app = getApp(), a = app, th = this; - var dd = { - oauth: "miniapp", - nickname: a.clear_word(r.nickName), - head_pic: r.avatarUrl, - sex: r.gender, - terminal: "miniapp", - sessionKey: sessionKey, - openid: openid, - encryptedData: e.encryptedData, - iv: e.iv, - store_id: getApp().globalData.setting.stoid, - }; - //--如果有邀请人的时候-- - if (th.data.first_leader) { - //判断一下分享人是不是分享商 - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + th.data.first_leader, {}).then(res => { - if (res.data.code == 0) { - var user = res.data.data; - if (user.is_distribut == 1) { + + app.request.get("/api/weshop/manager/managerConfig/get", { + data: { + storeId: getApp().globalData.setting.stoid + }, + success: function (res2) { + if (res2.data.code == 0) { + if (res2.data.data.is_newphone == 1) { + var dd = { + oauth: "miniapp", + nickname: a.clear_word(r.nickName), + head_pic: r.avatarUrl, + sex: r.gender, + terminal: "miniapp", + sessionKey: sessionKey, + openid: openid, + code: e.code, + isNewPhone: 1, + store_id: getApp().globalData.setting.stoid, + }; + } else { + var dd = { + oauth: "miniapp", + nickname: a.clear_word(r.nickName), + head_pic: r.avatarUrl, + sex: r.gender, + terminal: "miniapp", + sessionKey: sessionKey, + openid: openid, + encryptedData: e.encryptedData, + iv: e.iv, + store_id: getApp().globalData.setting.stoid, + }; + } + + + //--如果有邀请人的时候-- + if (th.data.first_leader) { dd.first_leader = th.data.first_leader; } + //-- 导购会员ID -- + if (getApp().globalData.guide_id) { + dd.guide_id = getApp().globalData.guide_id; + } + + //门店的扫描识别码 + if (getApp().globalData.store_number) { + dd.SunCode = encodeURIComponent(getApp().globalData.store_number.trim()); + } + + console.log("-----会员注册的信息-------"); + console.log(dd); + + + var need_go = 0; + //如果有需要完善的信息没有完善,就需要跳转 + if (th.data.name_need_go) { need_go = 1; } + if (th.data.birth_need_go) { need_go = 1; } + if (th.data.idcard_need_go) { need_go = 1; } + if (th.data.address_need_go) { need_go = 1; } + if (th.data.pick_need_go) { need_go = 1; } + if (th.data.sex_need_go) { need_go = 1; } + if (th.data.introducer_need_go) { need_go = 1; } + + if (need_go) { + + if (res2.data.data.is_newphone == 1) { + var req_data = { + sessionKey: sessionKey, + code: e.code, + isNewPhone: 1, + store_id: getApp().globalData.setting.stoid, + } + }else{ + var req_data = { + sessionKey: sessionKey, + encryptedData: e.encryptedData, + iv: e.iv, + store_id: getApp().globalData.setting.stoid, + } + } + //-- 获取一下手机 -- + getApp().request.promiseGet("/api/weshop/users/getmobile", { data: req_data }).then(res => { + if (res.data.code == 0) { + dd.mobile = res.data.data; + getApp().globalData.zc_dd = dd; + + var g_url="/packageA/pages/profile/profile?is_back=1"; + if(th.data.is_reg){ + g_url+="&is_reg=1"; + } + + th.cancle_bind();//关闭 + wx.navigateTo({ + url:g_url + }) + } + }) + + } else { + if (th.data.is_lable_set) { + if (res2.data.data.is_newphone == 1) { + var req_data = { + sessionKey: sessionKey, + code: e.code, + isNewPhone: 1, + store_id: getApp().globalData.setting.stoid, + } + }else{ + var req_data = { + sessionKey: sessionKey, + encryptedData: e.encryptedData, + iv: e.iv, + store_id: getApp().globalData.setting.stoid, + } + } + + //-- 获取一下手机 -- + getApp().request.promiseGet("/api/weshop/users/getmobile", { data: req_data }).then(res => { + if (res.data.code == 0) { + dd.mobile = res.data.data; + getApp().globalData.zc_dd = dd; + + var g_url="/packageE/pages/user/labels/labels?pageType=1"; + if(th.data.is_reg){ + g_url+="&is_reg=1"; + } + + th.cancle_bind();//关闭 + wx.navigateTo({ url: g_url }) + } + }) + } else { + + th.setData({ sub: 0 }); + wx.showLoading({ + title: '处理中.', + mask: true + }) + th.zu_ce(dd); //调用注册的函数 + } + } + + + } else { + th.setData({ sub: 0 }); + return app.my_warnning("授权登入失败,请稍后再试!", 0, that); } - }) - } - //-- 导购会员ID -- - if (getApp().globalData.guide_id) { - dd.guide_id = getApp().globalData.guide_id; - } + }, + failStatus: function (t) { + th.setData({ sub: 0 }); + return app.my_warnning("授权登入失败,请稍后再试!", 0, that); + }, + fail: function (t) { + th.setData({ sub: 0 }); + return i.clearAuth(), i.alertLoginErrorAndGoHome(), !1; + } + }); + }, - //门店的扫描识别码 - if (getApp().globalData.store_number) { - dd.SunCode = encodeURIComponent(getApp().globalData.store_number.trim()); + zu_ce: function (dd) { + + + if(this.data.sub) return false; + this.setData({ sub: 1 }); + + if(getApp().globalData.h5_openid){ + dd.wxopenid=getApp().globalData.h5_openid; } - console.log("-----会员注册的信息-------"); - console.log(dd); + var th = this; app.request.get("/api/weshop/users/thirdLogin", { data: dd, success: function (e) { + wx.hideLoading(); + th.setData({ sub: 0 }); + if (e.data.code == 0) { + th.cancle_bind();//关闭 app.globalData.user_id = e.data.data.user_id; - } else { + app.globalData.userInfo = e.data.data; + } + else if(e.data.code==-3){ + wx.showModal({ + title: e.data.msg, + success: function (e) { + if(e.confirm){ + dd.isreplacemobile=1; + th.zu_ce(dd); + } + } + }); + return false; + } + else { return app.showWarning("授权登入失败!" + e.data.msg); } + getApp().globalData.login_back = 1; + wx.setStorageSync("userinfo", e.data.data); + wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(app.globalData.userInfo.head_pic); + //调用接口判断是不是会员 + app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + e.data.data.user_id, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + getApp().globalData.guide_pick_id = res.data.data.pickup_id + } + }) - var need_go = 0; - var t_user = e.data.data; + getApp().showWarning("绑定成功"); + setTimeout(()=>{ + //-- 看情况,是跳转等级卡,还是跳转到新人有礼 -- + getApp().go_to_page(th.data.is_reg,function (){ - getApp().globalData.login_back = 1; - wx.setStorageSync("userinfo", e.data.data); - wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(a.globalData.userInfo.head_pic); + }) + },1000) - //如果有需要完善的信息没有完善,就需要跳转 - if (!t_user['vipname'] && th.data.name_need_go) { - need_go = 1; - } - if (!t_user['birthday'] && th.data.birth_need_go) { - need_go = 1; - } - if (!t_user['idcard'] && th.data.idcard_need_go) { - need_go = 1; - } - if (!t_user['address'] && th.data.address_need_go) { - need_go = 1; - } - if (!t_user['pickup_id'] && th.data.pick_need_go) { - need_go = 1; - } - if (!t_user['sex'] && th.data.sex_need_go) { - need_go = 1; - } - if (!t_user['fromuser_id'] && th.data.introducer_need_go) { - need_go = 1; - } - if (need_go) { - getApp().goto("/packageA/pages/profile/profile?is_back=1"); - } else { - that.cancle_bind();//关闭 - } }, failStatus: function (t) { - return app.my_warnning("授权登入失败,请稍后再试!", 0, that); + th.setData({ sub: 0 }); + return app.my_warnning("授权登入失败,请稍后再试!", 0, th); }, fail: function (t) { + th.setData({ sub: 0 }); return i.clearAuth(), i.alertLoginErrorAndGoHome(), !1; } }); }, + + bind_bnerr: function (e) { var _errImg = e.target.dataset.errorimg; var _errObj = {}; diff --git a/packageE/pages/togoin/togoin.js b/packageE/pages/togoin/togoin.js index dce08a5..40268af 100644 --- a/packageE/pages/togoin/togoin.js +++ b/packageE/pages/togoin/togoin.js @@ -12,7 +12,8 @@ Page({ first_leader: '', //-- 邀请人 -- config2: null, sub: 0, - is_reg:1 + is_reg:1, + openid:'' }, onLoad: function (options) { if (wx.getUserProfile) { @@ -22,6 +23,14 @@ Page({ } getApp().globalData.isLoad_ad = 1; + if(options.openid){ + this.data.openid=options.openid; + getApp().globalData.h5_openid=options.openid; + + console.log("options.openid") + console.log(options.openid) + } + // if(options.is_reg){ // this.data.is_reg=1; // } @@ -78,6 +87,20 @@ Page({ th.setData({ template_id: template_id }); } }) + + setTimeout(()=>{ + if(getApp().globalData.user_id){ + getApp().goto('/pages/user/index/index'); + }else{ + if(!this.data.openid){ + //getApp().goto('/packageH/pages/getopenid/index'); + } + } + + },800) + + + }, @@ -380,7 +403,7 @@ Page({ } }) } else { - th.setData({ sub: 1 }); + th.setData({ sub: 0 }); wx.showLoading({ title: '处理中.', mask: true @@ -406,22 +429,45 @@ Page({ }); }, + + zu_ce: function (dd) { + + + if(this.data.sub) return false; + this.setData({ sub: 1 }); + + if(getApp().globalData.h5_openid){ + dd.wxopenid=getApp().globalData.h5_openid; + } + var th = this; app.request.get("/api/weshop/users/thirdLogin", { data: dd, success: function (e) { + + wx.hideLoading(); + th.setData({ sub: 0 }); + if (e.data.code == 0) { app.globalData.user_id = e.data.data.user_id; - } else { - - wx.showToast({ - title: "授权登入失败!" + e.data.msg, - icon: 'none', - duration: 2000 + app.globalData.userInfo = e.data.data; + } + else if(e.data.code==-3){ + wx.showModal({ + title: e.data.msg, + success: function (e) { + if(e.confirm){ + dd.isreplacemobile=1; + th.zu_ce(dd); + } + } }); return false; } + else { + return app.showWarning("授权登入失败!" + e.data.msg); + } getApp().globalData.login_back = 1; wx.setStorageSync("userinfo", e.data.data); 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({ }) - }, failStatus: function (t) { th.setData({ sub: 0 }); @@ -453,7 +498,6 @@ Page({ }); }, - bind_bnerr: function (e) { var _errImg = e.target.dataset.errorimg; var _errObj = {}; diff --git a/packageE/pages/user/labels/labels.js b/packageE/pages/user/labels/labels.js index 93db6f3..772c744 100644 --- a/packageE/pages/user/labels/labels.js +++ b/packageE/pages/user/labels/labels.js @@ -247,7 +247,11 @@ Page({ th.setData({ is_check: 1 }) - + + if(getApp().globalData.h5_openid){ + getApp().globalData.zc_dd.openid=getApp().globalData.h5_openid; + } + app.request.get("/api/weshop/users/thirdLogin", { data: getApp().globalData.zc_dd, success: function (e) { @@ -291,7 +295,25 @@ Page({ }) }, 2000); - } else { + } + + else if(e.data.code==-3){ + wx.showModal({ + title: e.data.msg, + success: function (e) { + if(e.confirm){ + getApp().globalData.zc_dd.isreplacemobile=1; + th.setData({loading: 0,is_check:0}); + th.update_label(); + } + } + }); + return false; + + } + + + else { getApp().my_warnning("系统繁忙,请稍后再试", 0, th); th.setData({ is_check: 0 @@ -429,13 +451,34 @@ Page({ this.setData({ is_check: 1 }) + if(getApp().globalData.h5_openid){ + getApp().globalData.zc_dd.openid=getApp().globalData.h5_openid; + } + app.request.get("/api/weshop/users/thirdLogin", { data: getApp().globalData.zc_dd, success: function (e) { wx.hideLoading(); if (e.data.code == 0) { app.globalData.user_id = e.data.data.user_id; - } else { + } + + else if(e.data.code==-3){ + + wx.showModal({ + title: e.data.msg, + success: function (e) { + if(e.confirm){ + getApp().globalData.zc_dd.isreplacemobile=1; + th.setData({loading: 0,is_check:0}); + th.goto_user(); + } + } + }); + return false; + } + + else { return app.showWarning("授权登入失败!" + e.data.msg); } getApp().globalData.login_back = 1; -- libgit2 0.21.4