From 0110fab5f2738f7b06002df4bf2339220a6b642a Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Mon, 29 Apr 2024 17:48:37 +0800 Subject: [PATCH] 会员分享的优化 --- app.js | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/app.js b/app.js index ac67cb9..1bd8ac4 100644 --- a/app.js +++ b/app.js @@ -107,59 +107,59 @@ App({ var app = this; if (!app.globalData.userInfo) { - var user = wx.getStorageSync("userinfo"); - if (user && user.user_id) { - - //--生成会员 -- - app.promiseGet("/api/weshop/users/get/" + user.store_id + "/" + user.user_id, {}).then(res => { - - app.globalData.is_get_login=1; - - if (res.data.code == 0) { - - user = res.data.data; - //-- 小程序会员被解绑了,就要清空会员 -- - if (user['is_weappuser'] == 0) { - user = null; - app.globalData.userInfo = null; - app.globalData.user_id = 0; - } else { - app.globalData.userInfo = user; - app.globalData.user_id = user.user_id; - - //调用接口判断是不是会员 - app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + user.user_id, {}).then(res => { - if (res.data.code == 0) { - getApp().globalData.guide_id = res.data.data.id; - } - }) - app.promiseGet("/api/weshop/users/getAndUpdateUser/" +user.store_id + "/" + user.user_id, {}) - - } - wx.setStorageSync("userinfo", user); - } else { - user = null; - app.globalData.userInfo = null; - app.globalData.user_id = 0; - wx.setStorageSync("userinfo", null); - } - }) - } - else if(app.globalData.user_id){ //-- 启用默认的user_id -- - - app.promiseGet("/api/weshop/users/get/" + app.globalData.setting.stoid + "/" + app.globalData.user_id,{}).then(res=>{ - app.globalData.is_get_login=1; - if(res.data.code==0){ - app.globalData.userInfo = res.data.data; - wx.setStorageSync("userinfo",app.globalData.userInfo); - //刷一下导购 - app.promiseGet("/api/weshop/users/getAndUpdateUser/" +app.globalData.setting.stoid + "/" + app.globalData.user_id, {}) - } - }) - } - else { - //--拿下code-- - wx.login({ + // var user = wx.getStorageSync("userinfo"); + // if (user && user.user_id) { + // + // //--生成会员 -- + // app.promiseGet("/api/weshop/users/get/" + user.store_id + "/" + user.user_id, {}).then(res => { + // + // app.globalData.is_get_login=1; + // + // if (res.data.code == 0) { + // + // user = res.data.data; + // //-- 小程序会员被解绑了,就要清空会员 -- + // if (user['is_weappuser'] == 0) { + // user = null; + // app.globalData.userInfo = null; + // app.globalData.user_id = 0; + // } else { + // app.globalData.userInfo = user; + // app.globalData.user_id = user.user_id; + // + // //调用接口判断是不是会员 + // app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + user.user_id, {}).then(res => { + // if (res.data.code == 0) { + // getApp().globalData.guide_id = res.data.data.id; + // } + // }) + // app.promiseGet("/api/weshop/users/getAndUpdateUser/" +user.store_id + "/" + user.user_id, {}) + // + // } + // wx.setStorageSync("userinfo", user); + // } else { + // user = null; + // app.globalData.userInfo = null; + // app.globalData.user_id = 0; + // wx.setStorageSync("userinfo", null); + // } + // }) + // } + // else if(app.globalData.user_id){ //-- 启用默认的user_id -- + // + // app.promiseGet("/api/weshop/users/get/" + app.globalData.setting.stoid + "/" + app.globalData.user_id,{}).then(res=>{ + // app.globalData.is_get_login=1; + // if(res.data.code==0){ + // app.globalData.userInfo = res.data.data; + // wx.setStorageSync("userinfo",app.globalData.userInfo); + // //刷一下导购 + // app.promiseGet("/api/weshop/users/getAndUpdateUser/" +app.globalData.setting.stoid + "/" + app.globalData.user_id, {}) + // } + // }) + // } + // else { + //--拿下code-- + wx.login({ success: function (o) { var dd = { js_code: o.code, @@ -186,7 +186,8 @@ App({ app.globalData.openid = e.data.data.weapp_openid; //把会员的信息存在内存 wx.setStorageSync("userinfo", e.data.data); - + //刷一下导购 + app.promiseGet("/api/weshop/users/getAndUpdateUser/" +app.globalData.setting.stoid + "/" + app.globalData.user_id, {}) //调用接口判断是不是会员 app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + e.data.data.user_id, {}).then(res => { if (res.data.code == 0) { @@ -202,7 +203,7 @@ App({ }) } }) - } + //} } -- libgit2 0.21.4