diff --git a/src/api/index.js b/src/api/index.js index 99014f9..b12cc2e 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,3 +1,11 @@ +/* + * @Author: your name + * @Date: 2021-11-03 14:33:21 + * @LastEditTime: 2021-11-08 15:20:25 + * @LastEditors: your name + * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + * @FilePath: \questionnaired:\code\FE_huoran_data\src\api\index.js + */ import Setting from '@/setting' let host1 = 'http://192.168.31.125:9000'//林 let host2 = 'http://192.168.31.137:9000'// 陈赓 @@ -37,6 +45,7 @@ export default { sendPhoneOrEmailCode: `/users/users/userAccount/sendPhoneOrEmailCode`, bindPhoneOrEmail: `/users/users/userAccount/bindPhoneOrEmail`, examinePassword: `/users/users/userAccount/examinePassword`, + isClient: `/users/users/user/isClient`, userTemplate: `http://39.108.250.202/template/%E6%95%B0%E6%8D%AE%E5%B9%B3%E5%8F%B0%E7%94%A8%E6%88%B7%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx`, // 角色管理 diff --git a/src/layouts/header/index.vue b/src/layouts/header/index.vue index 149c093..ffa2279 100644 --- a/src/layouts/header/index.vue +++ b/src/layouts/header/index.vue @@ -113,9 +113,8 @@ export default { let customer = atob(decodeURI(this.customer)) == 'false' ? false : true this.setCustomer(customer) } - - // 如果登录了,才调用用户信息的接口 - this.token && this.getUserInfo() + // 如果登录了,并且非客户,才调用用户信息的接口(客户是没有用户信息的,也不能进入后台) + this.token && this.isCustomer && this.getUserInfo() }, methods: { ...mapActions('user', [ @@ -125,7 +124,7 @@ export default { this.$get(this.api.userInfo).then(res => { let userInfo = res.userInfo ? res.userInfo : {} let userAccount = res.userAccount - let isManager = userAccount.roleId != '0' + let isManager = userAccount.roleId != '0' // 判断该用户是普通用户还是其他角色,普通用户无法进入后台,要把后台那个图标隐藏 this.isUser = isManager let mg = this.$route.query.mg // 如果是管理员 diff --git a/src/pages/account/login/index.vue b/src/pages/account/login/index.vue index fb6b6c7..c8fc4fc 100644 --- a/src/pages/account/login/index.vue +++ b/src/pages/account/login/index.vue @@ -188,7 +188,9 @@ export default { this.form.phone = this.phone this.phoneVisible = false - this.setCustomer(res.customer) + this.$get(this.api.isClient).then(res => { + this.setCustomer(res.customer) + }).catch(res => {}) util.local.set(Setting.tokenKey,res.token,43200000) util.successMsg('登录成功') setTimeout(() => { diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 8b0f0cb..b2ab1e5 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,3 +1,11 @@ +/* + * @Author: your name + * @Date: 2021-11-03 14:33:21 + * @LastEditTime: 2021-11-08 15:26:33 + * @LastEditors: Please set LastEditors + * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + * @FilePath: \questionnaired:\code\FE_huoran_data\src\store\modules\user.js + */ import Setting from '@/setting' import util from '@/libs/util' @@ -44,9 +52,11 @@ export default { platform: Setting.platformId, // 所属平台id(1.职站 2.数据平台 3.中台) }).then(res => { if(res.status == 200){ - commit('SET_CUSTOMER',res.data.customer) util.local.set(Setting.tokenKey,res.data.token,43200000) util.successMsg('登录成功') + get(api.isClient).then(res => { + commit('SET_CUSTOMER',res.customer) + }).catch(res => {}) setTimeout(() => { // 登录次数+1 post(api.saveRecord,{