|
|
|
@ -32,39 +32,53 @@ export default {
|
|
|
|
|
// 初始化应用 |
|
|
|
|
async initApp() { |
|
|
|
|
await uni.hideTabBar() |
|
|
|
|
console.log('initapp') |
|
|
|
|
uni.hideTabBar({ |
|
|
|
|
animation: false |
|
|
|
|
}) |
|
|
|
|
// 检查用户登录状态 |
|
|
|
|
this.checkLogin() |
|
|
|
|
if (!getOpenId()) { |
|
|
|
|
// 如果没有openid则获取 |
|
|
|
|
this.getWxOpenId().then(() => { |
|
|
|
|
this.checkLogin() |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
// 检查用户登录状态 |
|
|
|
|
this.checkLogin() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
checkLogin() { |
|
|
|
|
console.log('accessToken', getAccessToken()) |
|
|
|
|
if (!getAccessToken()) { |
|
|
|
|
// 如果没有token则获取 |
|
|
|
|
this.login() |
|
|
|
|
} else { |
|
|
|
|
this.loginSuccess() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
login() { |
|
|
|
|
console.log('openId', getOpenId()) |
|
|
|
|
if (getOpenId()) { |
|
|
|
|
clearTimeout(this.timer) |
|
|
|
|
const data = { |
|
|
|
|
type: 34, |
|
|
|
|
code: getOpenId(), |
|
|
|
|
state: 'default', |
|
|
|
|
userType: this.getUserType() |
|
|
|
|
} |
|
|
|
|
this.$store.dispatch('Login', data).then(() => { |
|
|
|
|
this.loginSuccess() |
|
|
|
|
getWxOpenId() { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
uni.login({ |
|
|
|
|
success: res => { |
|
|
|
|
setOpenId(res.code) |
|
|
|
|
resolve() |
|
|
|
|
}, |
|
|
|
|
fail: err => { |
|
|
|
|
console.log('getOpenIdFail', err) |
|
|
|
|
reject() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.timer && clearTimeout(this.timer) |
|
|
|
|
this.timer = setTimeout(() => { |
|
|
|
|
this.login() |
|
|
|
|
}, 200) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
login() { |
|
|
|
|
const data = { |
|
|
|
|
type: 34, |
|
|
|
|
code: getOpenId(), |
|
|
|
|
state: 'default', |
|
|
|
|
userType: this.getUserType() |
|
|
|
|
} |
|
|
|
|
this.$store.dispatch('Login', data).then(() => { |
|
|
|
|
this.loginSuccess() |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
getUserType() { |
|
|
|
|
// 企业邀请 |
|
|
|
@ -76,15 +90,10 @@ export default {
|
|
|
|
|
loginSuccess() { |
|
|
|
|
this.$store.dispatch('GetInfo').then(res => { |
|
|
|
|
this.handlerNavigateTo(res.data.user) |
|
|
|
|
console.log('user', res.data.user) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
handlerNavigateTo(user) { |
|
|
|
|
if (this.redirect) { |
|
|
|
|
uni.reLaunch({ |
|
|
|
|
url: this.redirect |
|
|
|
|
}) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
// 邀请企业 |
|
|
|
|
if (this.inviteId) { |
|
|
|
|
uni.reLaunch({ |
|
|
|
@ -93,19 +102,11 @@ export default {
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 审核中 |
|
|
|
|
if (user.audit == 1) { |
|
|
|
|
uni.reLaunch({ |
|
|
|
|
url: '/sub/common/waiting' |
|
|
|
|
}) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 局内用户首次登录 |
|
|
|
|
if (user.audit == null) { |
|
|
|
|
if (user.audit == null || user.audit == 1) { |
|
|
|
|
// 局内用户首次登录 |
|
|
|
|
uni.reLaunch({ |
|
|
|
|
url: '/sub/owner/edit' |
|
|
|
|
url: `/sub/owner/edit?audit=${user.audit}` |
|
|
|
|
}) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|