Authored by QC-L

更新事件监听

... ... @@ -170,7 +170,7 @@ class App extends Component {
console.log(error);
});
event.on('user-is-login', (loginedCallBack, loginSuccess) => {
event.one('user-is-login', (loginedCallBack, loginSuccess) => {
let userInfo = Taro.getStorageSync('userInfo');
if (userInfo && userInfo.uid) {
checkUidAndSessionKey(userInfo.uid, userInfo.session_key).then(result => {
... ... @@ -183,7 +183,9 @@ class App extends Component {
} else {
event.one('my-user-login-success', () => {
if (loginSuccess) {
loginSuccess();
setTimeout(() => {
loginSuccess();
}, 1000);
}
})
Taro.navigateTo({
... ... @@ -207,7 +209,9 @@ class App extends Component {
} else {
event.one('my-user-login-success', () => {
if (loginSuccess) {
loginSuccess();
setTimeout(() => {
loginSuccess();
}, 1000);
}
})
Taro.navigateTo({
... ... @@ -223,7 +227,9 @@ class App extends Component {
} else {
event.one('my-user-login-success', () => {
if (loginSuccess) {
loginSuccess();
setTimeout(() => {
loginSuccess();
}, 1000);
}
})
Taro.navigateTo({
... ... @@ -241,7 +247,9 @@ class App extends Component {
} else {
event.one('my-user-login-success', () => {
if (loginSuccess) {
loginSuccess();
setTimeout(() => {
loginSuccess();
}, 1000);
}
})
Taro.navigateTo({
... ... @@ -252,7 +260,9 @@ class App extends Component {
} else {
event.one('my-user-login-success', () => {
if (loginSuccess) {
loginSuccess();
setTimeout(() => {
loginSuccess();
}, 1000);
}
})
Taro.navigateTo({
... ... @@ -261,7 +271,7 @@ class App extends Component {
}
});
event.on('judge-user-is-login', (isLogined, isLoginCallback) => {
event.one('judge-user-is-login', (isLogined, isLoginCallback) => {
let userInfo = Taro.getStorageSync('userInfo');
if (userInfo && userInfo.uid) {
checkUidAndSessionKey(userInfo.uid, userInfo.session_key).then(result => {
... ...
... ... @@ -83,7 +83,7 @@ export default class Login extends Component {
eventOnAll() {
const prefix = 'phonenumber';
event.on(this.addPrefix(prefix, USER_GET_PHONENUMBER_ERROR), (errMsg) => {
event.one(this.addPrefix(prefix, USER_GET_PHONENUMBER_ERROR), (errMsg) => {
if (errMsg === 'getPhoneNumber:fail user deny') {
errMsg = '获取手机号失败,请使用验证码登录';
}
... ... @@ -93,13 +93,13 @@ export default class Login extends Component {
icon: 'none'
});
});
event.on(this.addPrefix(prefix, USER_LOGIN_CALLBACK), (error) => {
event.one(this.addPrefix(prefix, USER_LOGIN_CALLBACK), (error) => {
console.log(error);
});
event.on(this.addPrefix(prefix, USER_LOGIN_SUCCESS), () => {
event.one(this.addPrefix(prefix, USER_LOGIN_SUCCESS), () => {
this.redirectAction();
});
event.on(this.addPrefix(prefix, USER_CHANGE_LOGIN_STATUS), (message) => {
event.one(this.addPrefix(prefix, USER_CHANGE_LOGIN_STATUS), (message) => {
const union_id = wx.getStorageSync('unionid');
this.setState({
inviteCode: this.$router.params.inviteCode ? this.$router.params.inviteCode : '',
... ...
... ... @@ -17,19 +17,19 @@ Page({
*/
onLoad: function (options) {
let that = this;
event.on('user-login-success', () => {
event.one('user-login-success', () => {
// 返回上一页
this.goReferer(); // 如果不需要绑定手机则返回前一页
});
event.on('change-login-status', params => {
event.one('change-login-status', params => {
that.setData({
loginText: params.text || '微信登录',
loginTips: params.tips || '',
loginButtonType: params.openType || ''
});
});
event.on('user-login-callback', this.loginCallback);
event.on('user-get-phonenumber-error', this.getPhonenumberError);
event.one('user-login-callback', this.loginCallback);
event.one('user-get-phonenumber-error', this.getPhonenumberError);
},
getPhonenumberError(error) {
... ... @@ -96,7 +96,8 @@ Page({
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
event.remove('user-login-callback', this.loginCallback);
event.remove('user-get-phonenumber-error', this.getPhonenumberError);
},
/**
... ...
... ... @@ -56,7 +56,7 @@ Page({
that.fetchOrderList(2,1);
}
});
event.on('refresh-order', () => {
event.one('refresh-order', () => {
// console.log("======refresh-order")
let currentType = that.data.activeIndex + 2;
this.fetchOrderList(currentType,1);
... ...
... ... @@ -23,6 +23,7 @@ class EventEmitter {
events = this._events;
handler = events[type];
console.log(events);
if (!handler)
return false;
... ... @@ -62,8 +63,9 @@ class EventEmitter {
let events;
if (typeof listener !== 'function')
throw new Error('"listener" argument must be a function');
events = this._events;
console.log(events);
if (typeof events === 'undefined') {
events = this._events = Object.create(null);
this._eventsCount = 0;
... ... @@ -81,6 +83,7 @@ class EventEmitter {
throw new Error('"listener" argument must be a function');
events = this._events;
console.log(events);
if (typeof events === 'undefined') {
events = this._events = Object.create(null);
... ...