//拉起登录授权
showLogin() {
login.getUserInfo(this.code, (res) => {
console.log(res)
if (res.code == 200) {
if (res.data.is_register == 1) {
this.token = res.data.user_info.user_id
uni.setStorageSync('token-center', res.data.user_info.user_id);
uni.showToast({
title: '登录成功!',
mask: true,
icon: 'none'
})
let share_user_id = uni.getStorageSync('top_user_id');
if (share_user_id) {
this.shareRecord();
}
} else {
this.session_key = res.data.session_key
this.open_id = res.data.open_id
this.phoneNumberShowAlert();
}
} else {
uni.showToast({
title: '授权登录失败!',
mask: true,
icon: 'none'
})
}
});
},
onShow() {
this.token = uni.getStorageSync('token-center');
if (this.token) {
this.getUserInfo();
this.getStatisticsInfo();
}else{
uni.login({
// #ifdef MP-WEIXIN
provider: 'weixin',
// #endif
// #ifdef MP-TOUTIAO
provider: 'toutiao',
// #endif
success: (res) => {
if (res.errMsg == "login:ok") {
this.code = res.code;
console.log(this.code)
} else {
uni.showToast({
title: '系统异常,请联系管理员!'
})
}
}
})
}
},