登录调整

master
yujialong 4 months ago
parent 5c6c5e8ea4
commit 7d741c9436
  1. 2
      src/api/index.js
  2. 4
      src/layouts/header/index.vue
  3. 26
      src/pages/account/login/index.vue
  4. 20
      src/pages/account/redirect/index.vue
  5. 29
      src/store/modules/user.js

@ -6,7 +6,6 @@ const host2 = 'http://121.37.12.51/'
export default {
logins: `users/users/user/login`, //登录
verification: `${host}users/users/user/captcha`,// 验证码图片
isClient: `users/users/user/isClient`,// 是否为客户
getUserAllRoleByToken: `users/users/role/getUserAllRoleByToken`,
getSchoolIdByToken: `users/users/data/user/getSchoolIdByToken`,
deleteProfile: `users/users/userInfo/deleteProfile`,
@ -14,6 +13,7 @@ export default {
getCurrentTime: `competition/competition/management/getCurrentTime`,
heartbeatDetection: `nakadai/message/heartbeatDetection`,
encrypt: `nakadai/data/encrypt`,
logout: `users/users/user/logout`,
getPlayAuth: `nakadai/nakadai/oss/getPlayAuth`, // 获取播放凭证

@ -170,10 +170,6 @@ export default {
this.setUserId(userId)
userAvatars && this.setAvatar(userAvatars)
this.setUserName(userName)
} else {
this.$get(this.api.isClient).then(res => {
res.customerName && this.setUserName(res.customerName)
}).catch(res => { })
}
}).catch(res => { })
},

@ -13,19 +13,11 @@
<el-input v-model.trim="loginForm.account" placeholder="请输入手机号/邮箱"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
type="password"
placeholder="请输入密码"
v-model.trim="loginForm.password"
>
<el-input type="password" placeholder="请输入密码" v-model.trim="loginForm.password">
</el-input>
</el-form-item>
<el-form-item prop="code">
<el-input
placeholder="请输入验证码"
v-model.trim="loginForm.code"
@keyup.enter.native="submitFormLogin"
>
<el-input placeholder="请输入验证码" v-model.trim="loginForm.code" @keyup.enter.native="submitFormLogin">
</el-input>
<img @click="getVerImg" :src="verificationIMG" class="verification" alt="">
</el-form-item>
@ -46,8 +38,8 @@
<el-form-item label="验证码">
<div style="display: flex;">
<el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input>
<el-button style="margin-left: 10px" type="text" @click="sendPhoneCode"
:disabled="phoneDisabled">{{ phoneBtnText }}
<el-button style="margin-left: 10px" type="text" @click="sendPhoneCode" :disabled="phoneDisabled">{{
phoneBtnText }}
</el-button>
</div>
</el-form-item>
@ -112,7 +104,7 @@ export default {
"SET_ROLENAME", 'SET_FROM'
]),
...mapActions("user", [
"setCustomer", "setCustomerName"
"setCustomerName"
]),
getVerImg () { //
this.loginForm.random = Math.floor(Math.random() * 999999999);
@ -153,17 +145,11 @@ export default {
}).catch(err => { })
},
queryCustomer () { //
this.$get(this.api.isClient).then(res => {
util.successMsg("登录成功");
this.setCustomer(res.customer);
res.customerName && this.setCustomerName(res.customerName);
const path = '/product/list' //
this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => {
const list = res.permissionMenu[0].children
this.$router.push(list.find(e => e.path === path) ? path : list[0].path)
}).catch(err => { })
}).catch(res => {});
},
phoneCountdown () {
let count = 60;
@ -236,6 +222,7 @@ export default {
height: 100%;
background-image: url(../../../assets/img/login-bg.png);
background-size: 100%;
.header {
width: 100%;
height: 60px;
@ -257,6 +244,7 @@ export default {
}
}
}
/deep/ .main {
position: absolute;
left: 50%;

@ -2,7 +2,7 @@
<script>
import { mapActions, mapMutations } from "vuex";
import util from "@/libs/util";
import Util from '@/libs/util'
import Setting from "@/setting";
export default {
data: function () {
@ -19,32 +19,28 @@ export default {
"SET_ROLENAME", 'SET_FROM'
]),
...mapActions("user", [
"setCustomer", "setCustomerName"
"setCustomerName"
]),
setLogin () {
this.SET_FROM(true)
util.local.set(Setting.tokenKey, window.atob(decodeURI(this.token)), Setting.tokenExpires);
Util.local.set(Setting.tokenKey, window.atob(decodeURI(this.token)), Setting.tokenExpires);
this.getRole()
this.queryCustomer()
},
//
getRole () {
this.$post(`${this.api.getUserAllRoleByToken}?platformId=${Setting.platformId}`).then(res => {
async getRole () {
const res = await this.$post(`${this.api.getUserAllRoleByToken}?platformId=${Setting.platformId}`)
this.SET_ROLENAME(res)
}).catch(err => { })
},
queryCustomer () { //
this.$get(this.api.isClient).then(res => {
util.successMsg('登录成功')
this.setCustomer(res.customer)
this.setCustomerName(res.customerName)
async queryCustomer () { //
Util.successMsg('登录成功')
this.setCustomerName(Util.cookies.get('customerName'))
const path = '/product/list' //
this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => {
const list = res.permissionMenu[0].children
this.$router.push(list.find(e => e.path === path) ? path : list[0].path)
}).catch(err => { })
}).catch(res => { })
}
}
};

@ -1,8 +1,7 @@
import Setting from "@/setting";
import util from "@/libs/util";
import { post, get, del, put } from "@/plugins/requests/index.js";
import { post } from "@/plugins/requests/index.js";
import api from "@/api";
import addRoutes from "@/libs/route/addRoutes";
/**
* 用户信息
@ -10,7 +9,6 @@ import addRoutes from "@/libs/route/addRoutes";
export default {
namespaced: true,
state: {
customer: false, // true:为客户,没有个人中心
customerName: "", // 客户名称
title: "",
logoUrl: "",
@ -32,9 +30,6 @@ export default {
state.roleId = info.roleId;
state.dataTime = info.dataTime;
},
SET_CUSTOMER: (state, customer) => {
state.customer = customer;
},
SET_CUSTOMER_NAME: (state, customerName) => {
state.customerName = customerName;
},
@ -72,12 +67,7 @@ export default {
post(api.logins, userInfo).then(res => {
// console.log(JSON.stringify(res));
if (res.status == 200) {
let { data } = res;
// 生成路由权限
// 每个系统都是用这套角色权限代码的,后端也是基本一样,除了个别字段可能会不一样
// 总体来说就两个步骤: 1是生成能够访问的路由的数组集合,2是生成能看到的按钮的数组集合
// res.message.listValue && Setting.dynamicRoute && addRoutes(res.message.listValue)
// 2021-10-13重做权限,因权限系统封装
let { data } = res
util.local.set(Setting.tokenKey, data.token, Setting.tokenExpires);
commit("SET_CUSTOMER", data.customer);
commit("SET_CUSTOMER_NAME", data.customerName);
@ -97,8 +87,9 @@ export default {
},
logout ({ commit, state, dispatch }) {
return new Promise((resolve, reject) => {
util.local.remove(Setting.storeKey);
util.local.remove(Setting.tokenKey);
post(api.logout).then(() => {
util.local.remove(Setting.storeKey)
util.local.remove(Setting.tokenKey)
if (state.fromClient) {
util.cookies.remove('serverLogin')
location.href = Setting.isDev
@ -109,8 +100,11 @@ export default {
} else {
location.reload()
}
resolve();
});
resolve()
}).catch(error => {
reject(error)
})
})
},
setInfo ({ state, commit }, info) {
commit("SET_INFO", info);
@ -121,9 +115,6 @@ export default {
setLogoUrl ({ state, commit }, logoUrl) {
commit("SET_LOGO_URL", logoUrl);
},
setCustomer({ state, commit }, customer) {
commit("SET_CUSTOMER", customer);
},
setCustomerName ({ state, commit }, customerName) {
commit("SET_CUSTOMER_NAME", customerName);
},

Loading…
Cancel
Save