Showing
5 changed files
with
26 additions
and
12 deletions
@@ -170,7 +170,7 @@ class App extends Component { | @@ -170,7 +170,7 @@ class App extends Component { | ||
170 | console.log(error); | 170 | console.log(error); |
171 | }); | 171 | }); |
172 | 172 | ||
173 | - event.on('user-is-login', (loginedCallBack, loginSuccess) => { | 173 | + event.one('user-is-login', (loginedCallBack, loginSuccess) => { |
174 | let userInfo = Taro.getStorageSync('userInfo'); | 174 | let userInfo = Taro.getStorageSync('userInfo'); |
175 | if (userInfo && userInfo.uid) { | 175 | if (userInfo && userInfo.uid) { |
176 | checkUidAndSessionKey(userInfo.uid, userInfo.session_key).then(result => { | 176 | checkUidAndSessionKey(userInfo.uid, userInfo.session_key).then(result => { |
@@ -183,7 +183,9 @@ class App extends Component { | @@ -183,7 +183,9 @@ class App extends Component { | ||
183 | } else { | 183 | } else { |
184 | event.one('my-user-login-success', () => { | 184 | event.one('my-user-login-success', () => { |
185 | if (loginSuccess) { | 185 | if (loginSuccess) { |
186 | + setTimeout(() => { | ||
186 | loginSuccess(); | 187 | loginSuccess(); |
188 | + }, 1000); | ||
187 | } | 189 | } |
188 | }) | 190 | }) |
189 | Taro.navigateTo({ | 191 | Taro.navigateTo({ |
@@ -207,7 +209,9 @@ class App extends Component { | @@ -207,7 +209,9 @@ class App extends Component { | ||
207 | } else { | 209 | } else { |
208 | event.one('my-user-login-success', () => { | 210 | event.one('my-user-login-success', () => { |
209 | if (loginSuccess) { | 211 | if (loginSuccess) { |
212 | + setTimeout(() => { | ||
210 | loginSuccess(); | 213 | loginSuccess(); |
214 | + }, 1000); | ||
211 | } | 215 | } |
212 | }) | 216 | }) |
213 | Taro.navigateTo({ | 217 | Taro.navigateTo({ |
@@ -223,7 +227,9 @@ class App extends Component { | @@ -223,7 +227,9 @@ class App extends Component { | ||
223 | } else { | 227 | } else { |
224 | event.one('my-user-login-success', () => { | 228 | event.one('my-user-login-success', () => { |
225 | if (loginSuccess) { | 229 | if (loginSuccess) { |
230 | + setTimeout(() => { | ||
226 | loginSuccess(); | 231 | loginSuccess(); |
232 | + }, 1000); | ||
227 | } | 233 | } |
228 | }) | 234 | }) |
229 | Taro.navigateTo({ | 235 | Taro.navigateTo({ |
@@ -241,7 +247,9 @@ class App extends Component { | @@ -241,7 +247,9 @@ class App extends Component { | ||
241 | } else { | 247 | } else { |
242 | event.one('my-user-login-success', () => { | 248 | event.one('my-user-login-success', () => { |
243 | if (loginSuccess) { | 249 | if (loginSuccess) { |
250 | + setTimeout(() => { | ||
244 | loginSuccess(); | 251 | loginSuccess(); |
252 | + }, 1000); | ||
245 | } | 253 | } |
246 | }) | 254 | }) |
247 | Taro.navigateTo({ | 255 | Taro.navigateTo({ |
@@ -252,7 +260,9 @@ class App extends Component { | @@ -252,7 +260,9 @@ class App extends Component { | ||
252 | } else { | 260 | } else { |
253 | event.one('my-user-login-success', () => { | 261 | event.one('my-user-login-success', () => { |
254 | if (loginSuccess) { | 262 | if (loginSuccess) { |
263 | + setTimeout(() => { | ||
255 | loginSuccess(); | 264 | loginSuccess(); |
265 | + }, 1000); | ||
256 | } | 266 | } |
257 | }) | 267 | }) |
258 | Taro.navigateTo({ | 268 | Taro.navigateTo({ |
@@ -261,7 +271,7 @@ class App extends Component { | @@ -261,7 +271,7 @@ class App extends Component { | ||
261 | } | 271 | } |
262 | }); | 272 | }); |
263 | 273 | ||
264 | - event.on('judge-user-is-login', (isLogined, isLoginCallback) => { | 274 | + event.one('judge-user-is-login', (isLogined, isLoginCallback) => { |
265 | let userInfo = Taro.getStorageSync('userInfo'); | 275 | let userInfo = Taro.getStorageSync('userInfo'); |
266 | if (userInfo && userInfo.uid) { | 276 | if (userInfo && userInfo.uid) { |
267 | checkUidAndSessionKey(userInfo.uid, userInfo.session_key).then(result => { | 277 | checkUidAndSessionKey(userInfo.uid, userInfo.session_key).then(result => { |
@@ -83,7 +83,7 @@ export default class Login extends Component { | @@ -83,7 +83,7 @@ export default class Login extends Component { | ||
83 | 83 | ||
84 | eventOnAll() { | 84 | eventOnAll() { |
85 | const prefix = 'phonenumber'; | 85 | const prefix = 'phonenumber'; |
86 | - event.on(this.addPrefix(prefix, USER_GET_PHONENUMBER_ERROR), (errMsg) => { | 86 | + event.one(this.addPrefix(prefix, USER_GET_PHONENUMBER_ERROR), (errMsg) => { |
87 | if (errMsg === 'getPhoneNumber:fail user deny') { | 87 | if (errMsg === 'getPhoneNumber:fail user deny') { |
88 | errMsg = '获取手机号失败,请使用验证码登录'; | 88 | errMsg = '获取手机号失败,请使用验证码登录'; |
89 | } | 89 | } |
@@ -93,13 +93,13 @@ export default class Login extends Component { | @@ -93,13 +93,13 @@ export default class Login extends Component { | ||
93 | icon: 'none' | 93 | icon: 'none' |
94 | }); | 94 | }); |
95 | }); | 95 | }); |
96 | - event.on(this.addPrefix(prefix, USER_LOGIN_CALLBACK), (error) => { | 96 | + event.one(this.addPrefix(prefix, USER_LOGIN_CALLBACK), (error) => { |
97 | console.log(error); | 97 | console.log(error); |
98 | }); | 98 | }); |
99 | - event.on(this.addPrefix(prefix, USER_LOGIN_SUCCESS), () => { | 99 | + event.one(this.addPrefix(prefix, USER_LOGIN_SUCCESS), () => { |
100 | this.redirectAction(); | 100 | this.redirectAction(); |
101 | }); | 101 | }); |
102 | - event.on(this.addPrefix(prefix, USER_CHANGE_LOGIN_STATUS), (message) => { | 102 | + event.one(this.addPrefix(prefix, USER_CHANGE_LOGIN_STATUS), (message) => { |
103 | const union_id = wx.getStorageSync('unionid'); | 103 | const union_id = wx.getStorageSync('unionid'); |
104 | this.setState({ | 104 | this.setState({ |
105 | inviteCode: this.$router.params.inviteCode ? this.$router.params.inviteCode : '', | 105 | inviteCode: this.$router.params.inviteCode ? this.$router.params.inviteCode : '', |
@@ -17,19 +17,19 @@ Page({ | @@ -17,19 +17,19 @@ Page({ | ||
17 | */ | 17 | */ |
18 | onLoad: function (options) { | 18 | onLoad: function (options) { |
19 | let that = this; | 19 | let that = this; |
20 | - event.on('user-login-success', () => { | 20 | + event.one('user-login-success', () => { |
21 | // 返回上一页 | 21 | // 返回上一页 |
22 | this.goReferer(); // 如果不需要绑定手机则返回前一页 | 22 | this.goReferer(); // 如果不需要绑定手机则返回前一页 |
23 | }); | 23 | }); |
24 | - event.on('change-login-status', params => { | 24 | + event.one('change-login-status', params => { |
25 | that.setData({ | 25 | that.setData({ |
26 | loginText: params.text || '微信登录', | 26 | loginText: params.text || '微信登录', |
27 | loginTips: params.tips || '', | 27 | loginTips: params.tips || '', |
28 | loginButtonType: params.openType || '' | 28 | loginButtonType: params.openType || '' |
29 | }); | 29 | }); |
30 | }); | 30 | }); |
31 | - event.on('user-login-callback', this.loginCallback); | ||
32 | - event.on('user-get-phonenumber-error', this.getPhonenumberError); | 31 | + event.one('user-login-callback', this.loginCallback); |
32 | + event.one('user-get-phonenumber-error', this.getPhonenumberError); | ||
33 | }, | 33 | }, |
34 | 34 | ||
35 | getPhonenumberError(error) { | 35 | getPhonenumberError(error) { |
@@ -96,7 +96,8 @@ Page({ | @@ -96,7 +96,8 @@ Page({ | ||
96 | * 生命周期函数--监听页面卸载 | 96 | * 生命周期函数--监听页面卸载 |
97 | */ | 97 | */ |
98 | onUnload: function () { | 98 | onUnload: function () { |
99 | - | 99 | + event.remove('user-login-callback', this.loginCallback); |
100 | + event.remove('user-get-phonenumber-error', this.getPhonenumberError); | ||
100 | }, | 101 | }, |
101 | 102 | ||
102 | /** | 103 | /** |
@@ -56,7 +56,7 @@ Page({ | @@ -56,7 +56,7 @@ Page({ | ||
56 | that.fetchOrderList(2,1); | 56 | that.fetchOrderList(2,1); |
57 | } | 57 | } |
58 | }); | 58 | }); |
59 | - event.on('refresh-order', () => { | 59 | + event.one('refresh-order', () => { |
60 | // console.log("======refresh-order") | 60 | // console.log("======refresh-order") |
61 | let currentType = that.data.activeIndex + 2; | 61 | let currentType = that.data.activeIndex + 2; |
62 | this.fetchOrderList(currentType,1); | 62 | this.fetchOrderList(currentType,1); |
@@ -23,6 +23,7 @@ class EventEmitter { | @@ -23,6 +23,7 @@ class EventEmitter { | ||
23 | 23 | ||
24 | events = this._events; | 24 | events = this._events; |
25 | handler = events[type]; | 25 | handler = events[type]; |
26 | + console.log(events); | ||
26 | 27 | ||
27 | if (!handler) | 28 | if (!handler) |
28 | return false; | 29 | return false; |
@@ -64,6 +65,7 @@ class EventEmitter { | @@ -64,6 +65,7 @@ class EventEmitter { | ||
64 | throw new Error('"listener" argument must be a function'); | 65 | throw new Error('"listener" argument must be a function'); |
65 | 66 | ||
66 | events = this._events; | 67 | events = this._events; |
68 | + console.log(events); | ||
67 | if (typeof events === 'undefined') { | 69 | if (typeof events === 'undefined') { |
68 | events = this._events = Object.create(null); | 70 | events = this._events = Object.create(null); |
69 | this._eventsCount = 0; | 71 | this._eventsCount = 0; |
@@ -81,6 +83,7 @@ class EventEmitter { | @@ -81,6 +83,7 @@ class EventEmitter { | ||
81 | throw new Error('"listener" argument must be a function'); | 83 | throw new Error('"listener" argument must be a function'); |
82 | 84 | ||
83 | events = this._events; | 85 | events = this._events; |
86 | + console.log(events); | ||
84 | 87 | ||
85 | if (typeof events === 'undefined') { | 88 | if (typeof events === 'undefined') { |
86 | events = this._events = Object.create(null); | 89 | events = this._events = Object.create(null); |
-
Please register or login to post a comment