Commit 0110fab5f2738f7b06002df4bf2339220a6b642a

Authored by yvan.ni
1 parent 38d768ed

会员分享的优化

Showing 1 changed file with 56 additions and 55 deletions
@@ -107,59 +107,59 @@ App({ @@ -107,59 +107,59 @@ App({
107 107
108 var app = this; 108 var app = this;
109 if (!app.globalData.userInfo) { 109 if (!app.globalData.userInfo) {
110 - var user = wx.getStorageSync("userinfo");  
111 - if (user && user.user_id) {  
112 -  
113 - //--生成会员 --  
114 - app.promiseGet("/api/weshop/users/get/" + user.store_id + "/" + user.user_id, {}).then(res => {  
115 -  
116 - app.globalData.is_get_login=1;  
117 -  
118 - if (res.data.code == 0) {  
119 -  
120 - user = res.data.data;  
121 - //-- 小程序会员被解绑了,就要清空会员 --  
122 - if (user['is_weappuser'] == 0) {  
123 - user = null;  
124 - app.globalData.userInfo = null;  
125 - app.globalData.user_id = 0;  
126 - } else {  
127 - app.globalData.userInfo = user;  
128 - app.globalData.user_id = user.user_id;  
129 -  
130 - //调用接口判断是不是会员  
131 - app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + user.user_id, {}).then(res => {  
132 - if (res.data.code == 0) {  
133 - getApp().globalData.guide_id = res.data.data.id;  
134 - }  
135 - })  
136 - app.promiseGet("/api/weshop/users/getAndUpdateUser/" +user.store_id + "/" + user.user_id, {})  
137 -  
138 - }  
139 - wx.setStorageSync("userinfo", user);  
140 - } else {  
141 - user = null;  
142 - app.globalData.userInfo = null;  
143 - app.globalData.user_id = 0;  
144 - wx.setStorageSync("userinfo", null);  
145 - }  
146 - })  
147 - }  
148 - else if(app.globalData.user_id){ //-- 启用默认的user_id --  
149 -  
150 - app.promiseGet("/api/weshop/users/get/" + app.globalData.setting.stoid + "/" + app.globalData.user_id,{}).then(res=>{  
151 - app.globalData.is_get_login=1;  
152 - if(res.data.code==0){  
153 - app.globalData.userInfo = res.data.data;  
154 - wx.setStorageSync("userinfo",app.globalData.userInfo);  
155 - //刷一下导购  
156 - app.promiseGet("/api/weshop/users/getAndUpdateUser/" +app.globalData.setting.stoid + "/" + app.globalData.user_id, {})  
157 - }  
158 - })  
159 - }  
160 - else {  
161 - //--拿下code--  
162 - wx.login({ 110 + // var user = wx.getStorageSync("userinfo");
  111 + // if (user && user.user_id) {
  112 + //
  113 + // //--生成会员 --
  114 + // app.promiseGet("/api/weshop/users/get/" + user.store_id + "/" + user.user_id, {}).then(res => {
  115 + //
  116 + // app.globalData.is_get_login=1;
  117 + //
  118 + // if (res.data.code == 0) {
  119 + //
  120 + // user = res.data.data;
  121 + // //-- 小程序会员被解绑了,就要清空会员 --
  122 + // if (user['is_weappuser'] == 0) {
  123 + // user = null;
  124 + // app.globalData.userInfo = null;
  125 + // app.globalData.user_id = 0;
  126 + // } else {
  127 + // app.globalData.userInfo = user;
  128 + // app.globalData.user_id = user.user_id;
  129 + //
  130 + // //调用接口判断是不是会员
  131 + // app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + user.user_id, {}).then(res => {
  132 + // if (res.data.code == 0) {
  133 + // getApp().globalData.guide_id = res.data.data.id;
  134 + // }
  135 + // })
  136 + // app.promiseGet("/api/weshop/users/getAndUpdateUser/" +user.store_id + "/" + user.user_id, {})
  137 + //
  138 + // }
  139 + // wx.setStorageSync("userinfo", user);
  140 + // } else {
  141 + // user = null;
  142 + // app.globalData.userInfo = null;
  143 + // app.globalData.user_id = 0;
  144 + // wx.setStorageSync("userinfo", null);
  145 + // }
  146 + // })
  147 + // }
  148 + // else if(app.globalData.user_id){ //-- 启用默认的user_id --
  149 + //
  150 + // app.promiseGet("/api/weshop/users/get/" + app.globalData.setting.stoid + "/" + app.globalData.user_id,{}).then(res=>{
  151 + // app.globalData.is_get_login=1;
  152 + // if(res.data.code==0){
  153 + // app.globalData.userInfo = res.data.data;
  154 + // wx.setStorageSync("userinfo",app.globalData.userInfo);
  155 + // //刷一下导购
  156 + // app.promiseGet("/api/weshop/users/getAndUpdateUser/" +app.globalData.setting.stoid + "/" + app.globalData.user_id, {})
  157 + // }
  158 + // })
  159 + // }
  160 + // else {
  161 + //--拿下code--
  162 + wx.login({
163 success: function (o) { 163 success: function (o) {
164 var dd = { 164 var dd = {
165 js_code: o.code, 165 js_code: o.code,
@@ -186,7 +186,8 @@ App({ @@ -186,7 +186,8 @@ App({
186 app.globalData.openid = e.data.data.weapp_openid; 186 app.globalData.openid = e.data.data.weapp_openid;
187 //把会员的信息存在内存 187 //把会员的信息存在内存
188 wx.setStorageSync("userinfo", e.data.data); 188 wx.setStorageSync("userinfo", e.data.data);
189 - 189 + //刷一下导购
  190 + app.promiseGet("/api/weshop/users/getAndUpdateUser/" +app.globalData.setting.stoid + "/" + app.globalData.user_id, {})
190 //调用接口判断是不是会员 191 //调用接口判断是不是会员
191 app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + e.data.data.user_id, {}).then(res => { 192 app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + e.data.data.user_id, {}).then(res => {
192 if (res.data.code == 0) { 193 if (res.data.code == 0) {
@@ -202,7 +203,7 @@ App({ @@ -202,7 +203,7 @@ App({
202 }) 203 })
203 } 204 }
204 }) 205 })
205 - } 206 + //}
206 207
207 208
208 } 209 }