Browse Source

修改登录逻辑

master
parent
commit
435597a129
  1. 21
      App.vue
  2. 13
      pages.json
  3. 71
      pages/login.vue
  4. 2
      sub/invite/addEnterprise.vue
  5. 14
      sub/owner/edit.vue
  6. 4
      sub/owner/invite.vue
  7. 3
      utils/permission.js

21
App.vue

@ -14,12 +14,6 @@ export default {
uni.hideTabBar() uni.hideTabBar()
// //
this.initConfig() this.initConfig()
if (!getOpenId()) {
this.applogin()
return
}
//
// this.checkLogin()
}, },
initConfig() { initConfig() {
this.globalData.config = config this.globalData.config = config
@ -33,21 +27,6 @@ export default {
console.error('获取设备信息失败:', err) console.error('获取设备信息失败:', err)
} }
}) })
},
checkLogin() {
if (!getAccessToken()) {
this.$tab.reLaunch('/pages/login')
}
},
async applogin() {
uni.login({
success: res => {
setOpenId(res.code)
},
fail: err => {
console.log('getOpenIdFail', err)
}
})
} }
} }
} }

13
pages.json

@ -1,5 +1,11 @@
{ {
"pages": [{ "pages": [{
"path": "pages/login",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle": "custom"
}
}, {
"path": "pages/index", "path": "pages/index",
"style": { "style": {
"navigationBarTitleText": "首页", "navigationBarTitleText": "首页",
@ -10,13 +16,6 @@
} }
} }
}, },
{
"path": "pages/login",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle": "custom"
}
},
{ {
"path": "pages/enterprise", "path": "pages/enterprise",
"style": { "style": {

71
pages/login.vue

@ -32,39 +32,53 @@ export default {
// //
async initApp() { async initApp() {
await uni.hideTabBar() await uni.hideTabBar()
console.log('initapp')
uni.hideTabBar({ uni.hideTabBar({
animation: false animation: false
}) })
// if (!getOpenId()) {
this.checkLogin() // openid
this.getWxOpenId().then(() => {
this.checkLogin()
})
} else {
//
this.checkLogin()
}
}, },
checkLogin() { checkLogin() {
console.log('accessToken', getAccessToken()) console.log('accessToken', getAccessToken())
if (!getAccessToken()) { if (!getAccessToken()) {
// token
this.login() this.login()
} else { } else {
this.loginSuccess() this.loginSuccess()
} }
}, },
login() { getWxOpenId() {
console.log('openId', getOpenId()) return new Promise((resolve, reject) => {
if (getOpenId()) { uni.login({
clearTimeout(this.timer) success: res => {
const data = { setOpenId(res.code)
type: 34, resolve()
code: getOpenId(), },
state: 'default', fail: err => {
userType: this.getUserType() console.log('getOpenIdFail', err)
} reject()
this.$store.dispatch('Login', data).then(() => { }
this.loginSuccess()
}) })
} else { })
this.timer && clearTimeout(this.timer) },
this.timer = setTimeout(() => { login() {
this.login() const data = {
}, 200) type: 34,
code: getOpenId(),
state: 'default',
userType: this.getUserType()
} }
this.$store.dispatch('Login', data).then(() => {
this.loginSuccess()
})
}, },
getUserType() { getUserType() {
// //
@ -76,15 +90,10 @@ export default {
loginSuccess() { loginSuccess() {
this.$store.dispatch('GetInfo').then(res => { this.$store.dispatch('GetInfo').then(res => {
this.handlerNavigateTo(res.data.user) this.handlerNavigateTo(res.data.user)
console.log('user', res.data.user)
}) })
}, },
handlerNavigateTo(user) { handlerNavigateTo(user) {
if (this.redirect) {
uni.reLaunch({
url: this.redirect
})
return
}
// //
if (this.inviteId) { if (this.inviteId) {
uni.reLaunch({ uni.reLaunch({
@ -93,19 +102,11 @@ export default {
return 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({ uni.reLaunch({
url: '/sub/owner/edit' url: `/sub/owner/edit?audit=${user.audit}`
}) })
return return
} }

2
sub/invite/addEnterprise.vue

@ -274,7 +274,7 @@ export default {
this.form.tags = data this.form.tags = data
}) })
uni.$on('prove', data => { uni.$on('prove', data => {
if (this.form.id) { if (this.form.id != '') {
this.getProve() this.getProve()
} else { } else {
this.prove.push(data) this.prove.push(data)

14
sub/owner/edit.vue

@ -137,7 +137,10 @@ export default {
} }
} }
}, },
async onLoad() { async onLoad(options) {
if (options.audit) {
this.form.audit = options.audit
}
await this.getDict() await this.getDict()
}, },
onShow() { onShow() {
@ -157,9 +160,12 @@ export default {
} }
}, },
init() { init() {
getUserProfile().then(res => { console.log('登录信息', this.$store.getters)
this.form = res.data if (this.$store.getters.userId) {
}) getUserProfile().then(res => {
this.form = res.data
})
}
}, },
async getDict() { async getDict() {
const dict = await getDictBatchByType({ const dict = await getDictBatchByType({

4
sub/owner/invite.vue

@ -24,7 +24,7 @@ export default {
onShareAppMessage() { onShareAppMessage() {
return { return {
title: '邀请企业入驻', title: '邀请企业入驻',
path: `/sub/invite/index?inviteId=${this.$store.getters.userId}`, path: `/pages/login?inviteId=${this.$store.getters.userId}`,
imageUrl: imageUrl:
'http://82.156.141.150:9001/api/v1/download-shared-object/aHR0cDovL2xvY2FsaG9zdDo5MDAwL2h1YW5iYW8vbWluaWFwcC9pbnZhdGUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUQxODY1RVA2NEczMEdEUUhDVTglMkYyMDI1MDIxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMThUMDcyMDI0WiZYLUFtei1FeHBpcmVzPTQzMTk5JlgtQW16LVNlY3VyaXR5LVRva2VuPWV5SmhiR2NpT2lKSVV6VXhNaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpoWTJObGMzTkxaWGtpT2lKQlJERTROalZGVURZMFJ6TXdSMFJSU0VOVk9DSXNJbVY0Y0NJNk1UY3pPVGt3TmpJME55d2ljR0Z5Wlc1MElqb2lZV1J0YVc0aWZRLmp6djBhdEY5QVBYXzVjYWg4c18yeXhVV3oxek9BekFzSVdzemVrUmZwcXlHd0RPWkptazlUSGJRUnBDdVNmLVMyU0otWTI1cldUd2hpNUlrY0xBSThRJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZ2ZXJzaW9uSWQ9bnVsbCZYLUFtei1TaWduYXR1cmU9MjcxZTkzOTE1MDkwYzUzYmRjYTg0MjQ1MTJhYjk3ZWQxZWMyN2QzM2MwM2U3NGUwYmRhNTBmYjQyNWI0N2MyOQ' 'http://82.156.141.150:9001/api/v1/download-shared-object/aHR0cDovL2xvY2FsaG9zdDo5MDAwL2h1YW5iYW8vbWluaWFwcC9pbnZhdGUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUQxODY1RVA2NEczMEdEUUhDVTglMkYyMDI1MDIxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMThUMDcyMDI0WiZYLUFtei1FeHBpcmVzPTQzMTk5JlgtQW16LVNlY3VyaXR5LVRva2VuPWV5SmhiR2NpT2lKSVV6VXhNaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpoWTJObGMzTkxaWGtpT2lKQlJERTROalZGVURZMFJ6TXdSMFJSU0VOVk9DSXNJbVY0Y0NJNk1UY3pPVGt3TmpJME55d2ljR0Z5Wlc1MElqb2lZV1J0YVc0aWZRLmp6djBhdEY5QVBYXzVjYWg4c18yeXhVV3oxek9BekFzSVdzemVrUmZwcXlHd0RPWkptazlUSGJRUnBDdVNmLVMyU0otWTI1cldUd2hpNUlrY0xBSThRJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZ2ZXJzaW9uSWQ9bnVsbCZYLUFtei1TaWduYXR1cmU9MjcxZTkzOTE1MDkwYzUzYmRjYTg0MjQ1MTJhYjk3ZWQxZWMyN2QzM2MwM2U3NGUwYmRhNTBmYjQyNWI0N2MyOQ'
} }
@ -32,7 +32,7 @@ export default {
onShareTimeline() { onShareTimeline() {
return { return {
title: '邀请企业入驻', // title: '邀请企业入驻', //
path: `/sub/invite/index?inviteId=${this.$store.getters.userId}`, path: `/pages/login?inviteId=${this.$store.getters.userId}`,
imageUrl: imageUrl:
'http://82.156.141.150:9001/api/v1/download-shared-object/aHR0cDovL2xvY2FsaG9zdDo5MDAwL2h1YW5iYW8vbWluaWFwcC9pbnZh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VXhNaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpoWTJObGMzTkxaWGtpT2lKQlJERTROalZGVURZMFJ6TXdSMFJSU0VOVk9DSXNJbVY0Y0NJNk1UY3pPVGt3TmpJME55d2ljR0Z5Wlc1MElqb2lZV1J0YVc0aWZRLmp6djBhdEY5QVBYXzVjYWg4c18yeXhVV3oxek9BekFzSVdzemVrUmZwcXlHd0RPWkptazlUSGJRUnBDdVNmLVMyU0otWTI1cldUd2hpNUlrY0xBSThRJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZ2ZXJzaW9uSWQ9bnVsbCZYLUFtei1TaWduYXR1cmU9MjcxZTkzOTE1MDkwYzUzYmRjYTg0MjQ1MTJhYjk3ZWQxZWMyN2QzM2MwM2U3NGUwYmRhNTBmYjQyNWI0N2MyOQ'
} }

3
utils/permission.js

@ -36,6 +36,9 @@ export function checkRole(value) {
console.log(roles); console.log(roles);
const permissionRoles = value const permissionRoles = value
const super_admin = "admin" const super_admin = "admin"
if (!roles) {
return false
}
const hasRole = roles.some(role => { const hasRole = roles.some(role => {
return super_admin === role || permissionRoles.includes(role) return super_admin === role || permissionRoles.includes(role)
}) })

Loading…
Cancel
Save