Commit f3225f83ea1f7e11437c9b77ac133f1dd717fb78
1 parent
4019c168
首页分享的优化~~
Showing
2 changed files
with
32 additions
and
5 deletions
app.js
... | ... | @@ -75,7 +75,8 @@ App({ |
75 | 75 | sp_scene: null, |
76 | 76 | |
77 | 77 | navBarHeight:44, //默认高度44 |
78 | - is_pc:0, //是不是在pc端打开小程序 | |
78 | + is_pc:0, //是不是在pc端打开小程序 | |
79 | + is_get_login:0 | |
79 | 80 | }, |
80 | 81 | auth: o, |
81 | 82 | request: a, |
... | ... | @@ -139,7 +140,7 @@ App({ |
139 | 140 | } |
140 | 141 | }) |
141 | 142 | } |
142 | - else if(app.globalData.user_id){ //-- 启用默认的user_id -- | |
143 | + else if(app.globalData.user_id){ //-- 启用默认的user_id -- | |
143 | 144 | app.promiseGet("/api/weshop/users/get/" + app.globalData.setting.stoid + "/" + app.globalData.user_id,{}).then(res=>{ |
144 | 145 | if(res.data.code==0){ |
145 | 146 | app.globalData.userInfo = res.data.data; |
... | ... | @@ -165,6 +166,9 @@ App({ |
165 | 166 | app.request.get("/api/weshop/users/openidandkey", { |
166 | 167 | data: dd, |
167 | 168 | success: function (e) { |
169 | + //说明会员是有wx.login运行拿了一下是不是会员 | |
170 | + app.globalData.is_get_login=1; | |
171 | + | |
168 | 172 | if (e.data.code == 0) { |
169 | 173 | //如果有会员的话,没有sessionKey |
170 | 174 | if (!e.data.data.sessionKey) { |
... | ... | @@ -796,6 +800,26 @@ App({ |
796 | 800 | }); |
797 | 801 | }, |
798 | 802 | |
803 | + | |
804 | + //--- 最多十秒 --- | |
805 | + waitfor_login(func){ | |
806 | + var n = 0; | |
807 | + var that=this; | |
808 | + if (!this.globalData.is_get_login) { | |
809 | + var inter = setInterval(function () { | |
810 | + n++; | |
811 | + if (that.globalData.is_get_login) { | |
812 | + clearInterval(inter); | |
813 | + func(); | |
814 | + } | |
815 | + if (n > 20) { | |
816 | + clearInterval(inter); | |
817 | + func(); | |
818 | + } | |
819 | + }, 500); | |
820 | + } | |
821 | + }, | |
822 | + | |
799 | 823 | //------定时等待某个值,有值才进行运算-------- |
800 | 824 | waitfor: function (page, key, pop_value, func) { |
801 | 825 | var n = 0; | ... | ... |
pages/index/index/index.js
... | ... | @@ -216,9 +216,12 @@ Page({ |
216 | 216 | } |
217 | 217 | }) |
218 | 218 | |
219 | - if (!getApp().globalData.user_id) { | |
220 | - ut.new_user_go(os.stoid, first_leader); | |
221 | - } | |
219 | + //先查看一下是不是系统会员 | |
220 | + getApp().waitfor_login(()=> { | |
221 | + if (!getApp().globalData.user_id) { | |
222 | + ut.new_user_go(os.stoid, first_leader); | |
223 | + } | |
224 | + }) | |
222 | 225 | |
223 | 226 | } |
224 | 227 | ... | ... |