登录调整

master
yujialong 4 months ago
parent 7f18b99801
commit 6036ec0efd
  1. 88
      src/api/index.js
  2. 314
      src/layouts/header/index.vue
  3. 114
      src/pages/account/login/index.vue
  4. 150
      src/setting.js
  5. 177
      src/store/modules/user.js

@ -3,12 +3,13 @@ const host = Setting.apiBaseURL
export default { export default {
// 登录注册 // 登录注册
logins: `users/users/user/login`, logins: `users/users/user/login`,
verification:`${host}users/users/user/captcha`, verification: `${host}users/users/user/captcha`,
sendPhoneVerificationCode: `users/users/user/sendPhoneVerificationCode`, sendPhoneVerificationCode: `users/users/user/sendPhoneVerificationCode`,
getToken: `users/users/user/getToken`, getToken: `users/users/user/getToken`,
getOtherAccountByPhone: `users/users/user/getOtherAccountByPhone`, getOtherAccountByPhone: `users/users/user/getOtherAccountByPhone`,
unbindAccounts: `users/users/user/unbindAccounts`, unbindAccounts: `users/users/user/unbindAccounts`,
logout: `users/users/user/logout`,
// 加密货币 // 加密货币
market: `/topic/market`, market: `/topic/market`,
@ -29,70 +30,69 @@ export default {
// 个人中心 // 个人中心
uploadUserAvatars: `${host}users/users/userAccount/updateUserAvatars`, uploadUserAvatars: `${host}users/users/userAccount/updateUserAvatars`,
userInfo:`users/users/userInfo/getUserInfo`, userInfo: `users/users/userInfo/getUserInfo`,
updateUser:`users/users/userInfo/updateUser`, updateUser: `users/users/userInfo/updateUser`,
findPasswordByEmail:`users/users/userAccount/findPasswordByEmail`, findPasswordByEmail: `users/users/userAccount/findPasswordByEmail`,
findPasswordByPhone:`users/users/userAccount/findPasswordByPhone`, findPasswordByPhone: `users/users/userAccount/findPasswordByPhone`,
// 用户管理 // 用户管理
saveUser: `users/users/data/user/save`, saveUser: `users/users/data/user/save`,
getDetailByAccount: `occupationlab/occupationlab/architecture/getDetailByAccount`, getDetailByAccount: `occupationlab/occupationlab/architecture/getDetailByAccount`,
getUserList: `users/users/data/user/getUserList`, getUserList: `users/users/data/user/getUserList`,
getUserTotalBySchoolId: `users/users/data/user/getUserTotalBySchoolId`, getUserTotalBySchoolId: `users/users/data/user/getUserTotalBySchoolId`,
checkAccount:`occupationlab/occupationlab/architecture/checkWorkNumOrAccount`, checkAccount: `occupationlab/occupationlab/architecture/checkWorkNumOrAccount`,
getDetail:`users/users/data/user/getDetail`, getDetail: `users/users/data/user/getDetail`,
modifyUser:`users/users/data/user/modify`, modifyUser: `users/users/data/user/modify`,
export_failure:`${host}users/users/data/user/export_failure`, export_failure: `${host}users/users/data/user/export_failure`,
uploadFile:`${host}users/users/data/user/uploadFile`, uploadFile: `${host}users/users/data/user/uploadFile`,
deleteUser:`users/users/data/user/delete`, deleteUser: `users/users/data/user/delete`,
resetPwd: `users/users/userAccount/resetPwd`, resetPwd: `users/users/userAccount/resetPwd`,
sendPhoneOrEmailCode: `users/users/userAccount/sendPhoneOrEmailCode`, sendPhoneOrEmailCode: `users/users/userAccount/sendPhoneOrEmailCode`,
unbindMobilePhone: `users/users/userAccount/unbindMobilePhone`, unbindMobilePhone: `users/users/userAccount/unbindMobilePhone`,
bindPhoneOrEmail: `users/users/userAccount/bindPhoneOrEmail`, bindPhoneOrEmail: `users/users/userAccount/bindPhoneOrEmail`,
examinePassword: `users/users/userAccount/examinePassword`, examinePassword: `users/users/userAccount/examinePassword`,
isClient: `${host}users/users/user/isClient`,
deleteProfile: `users/users/userInfo/deleteProfile`, deleteProfile: `users/users/userInfo/deleteProfile`,
checkEmailOrPhone: `occupationlab/occupationlab/architecture/checkEmailOrPhone`, checkEmailOrPhone: `occupationlab/occupationlab/architecture/checkEmailOrPhone`,
accountIsDisabled: `users/users/user/accountIsDisabled`, accountIsDisabled: `users/users/user/accountIsDisabled`,
userTemplate: `http://121.37.12.51/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`, userTemplate: `http://121.37.12.51/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`,
// 角色管理 // 角色管理
batchRemove:`users/users/role/batchRemove`, batchRemove: `users/users/role/batchRemove`,
getRole:`users/users/role/obtainDetails`, getRole: `users/users/role/obtainDetails`,
getName:`data/data/role/getName`, getName: `data/data/role/getName`,
listRole:`users/users/role/list`, listRole: `users/users/role/list`,
removeRole:`data/data/role/remove`, removeRole: `data/data/role/remove`,
saveOrUpdate:`users/users/role/saveOrUpdate`, saveOrUpdate: `users/users/role/saveOrUpdate`,
getPermissions:`users/users/user-role/getUserRolesPermissionMenu`, getPermissions: `users/users/user-role/getUserRolesPermissionMenu`,
// 权限菜单管理 // 权限菜单管理
doAssign:`data/data/permission/doAssign`, doAssign: `data/data/permission/doAssign`,
queryAllMenus:`users/users/permission/queryAllMenus`, queryAllMenus: `users/users/permission/queryAllMenus`,
savePer:`users/users/user-role/rolePermissionService`, savePer: `users/users/user-role/rolePermissionService`,
toAssign:`data/data/permission/toAssign`, toAssign: `data/data/permission/toAssign`,
// 表展示 // 表展示
getIdQueryTable:`data/data/table/getIdQueryTable`, getIdQueryTable: `data/data/table/getIdQueryTable`,
getTableByClassification:`data/data/table/getTableByClassification`, getTableByClassification: `data/data/table/getTableByClassification`,
getTableByCondition:`data/data/table/getTableByCondition`, getTableByCondition: `data/data/table/getTableByCondition`,
downloadData:`${host}data/data/download`, downloadData: `${host}data/data/download`,
previewData:`data/data/preview`, previewData: `data/data/preview`,
visualPreview:`data/data/visualPreview`, visualPreview: `data/data/visualPreview`,
downloadRecord:`data/data/myDownload/downloadRecord`, downloadRecord: `data/data/myDownload/downloadRecord`,
getDownloadRecord:`data/data/myDownload/getDownloadRecord`, getDownloadRecord: `data/data/myDownload/getDownloadRecord`,
downloadAgain:`data/data/downloadAgain`, downloadAgain: `data/data/downloadAgain`,
isDownload:`data/data/product/isDownload`, isDownload: `data/data/product/isDownload`,
getTableTime:`data/data/tableTime/getTableTime`, getTableTime: `data/data/tableTime/getTableTime`,
getLevel: `data/data/category/getLevel`, getLevel: `data/data/category/getLevel`,
multipleTablePreview: `data/data/multipleTablePreview`, multipleTablePreview: `data/data/multipleTablePreview`,
// 数据操作记录 // 数据操作记录
queryAccumulate:`data/data/dataRecord/queryAccumulate`, queryAccumulate: `data/data/dataRecord/queryAccumulate`,
queryDatabaseInfo:`data/data/dataRecord/queryDatabaseInfo`, queryDatabaseInfo: `data/data/dataRecord/queryDatabaseInfo`,
queryDatabaseInfoByMonth:`data/data/dataRecord/queryDatabaseInfoByMonth`, queryDatabaseInfoByMonth: `data/data/dataRecord/queryDatabaseInfoByMonth`,
saveRecord:`data/data/dataRecord/saveRecord`, saveRecord: `data/data/dataRecord/saveRecord`,
databaseInfoExport:`${host}data/data/dataRecord/databaseInfoExport`, databaseInfoExport: `${host}data/data/dataRecord/databaseInfoExport`,
databaseInfoByMonthExport:`${host}data/data/dataRecord/databaseInfoByMonthExport`, databaseInfoByMonthExport: `${host}data/data/dataRecord/databaseInfoByMonthExport`,
onlineNumber:`data/data/dataRecord/onlineNumber`, onlineNumber: `data/data/dataRecord/onlineNumber`,
getProductInfoBySchoolId:`data/data/product/getProductInfoBySchoolId`, getProductInfoBySchoolId: `data/data/product/getProductInfoBySchoolId`,
} }

@ -1,52 +1,55 @@
<template> <template>
<div class="header"> <div class="header">
<a class="logo" @click="toIndex"> <a class="logo" @click="toIndex">
<img src="@/assets/img/logo.png" alt=""> <img src="@/assets/img/logo.png" alt="">
</a> </a>
<div class="inner"> <div class="inner">
<div style="height: 64px;"></div> <div style="height: 64px;"></div>
<navbar ref="nav" @hideSetting="hideSetting"></navbar> <navbar ref="nav" @hideSetting="hideSetting"></navbar>
<div class="action" v-if="token"> <div class="action" v-if="token">
<img v-if="showSetting" class="icon m-r-20" src="../../assets/img/setting.png" alt="" @click="toManager"> <img v-if="showSetting" class="icon m-r-20" src="../../assets/img/setting.png" alt="" @click="toManager">
<el-dropdown class="user-wrap" @command="userCommand"> <el-dropdown class="user-wrap" @command="userCommand">
<div class="user"> <div class="user">
<el-avatar :size="40" :src="avatar"></el-avatar> <el-avatar :size="40" :src="avatar"></el-avatar>
<span class="username">{{userName}}</span> <span class="username">{{ userName }}</span>
</div> </div>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="person" v-if="!isCustomer">个人资料</el-dropdown-item> <el-dropdown-item command="person" v-if="!isCustomer">个人资料</el-dropdown-item>
<template v-else> <template v-else>
<el-dropdown-item command="resetPw">修改密码</el-dropdown-item> <el-dropdown-item command="resetPw">修改密码</el-dropdown-item>
<el-dropdown-item command="myDownload">我的下载</el-dropdown-item> <el-dropdown-item command="myDownload">我的下载</el-dropdown-item>
</template> </template>
<el-dropdown-item command="logout">退出登录</el-dropdown-item> <el-dropdown-item command="logout">退出登录</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
<div class="login" v-else-if="!isLogin" @click="toLogin"> <div class="login" v-else-if="!isLogin" @click="toLogin">
<img src="@/assets/img/user.png" alt=""> <img src="@/assets/img/user.png" alt="">
<span>登录</span> <span>登录</span>
</div> </div>
</div>
<el-dialog title="修改密码" :visible.sync="passwordVisible" :close-on-click-modal="false" :append-to-body="true" @close="closePassword" width="30%">
<el-form ref="passwordForm" label-width="82px">
<el-form-item label="原密码">
<el-input type="password" v-model="passwordForm.password" placeholder="请输入原密码"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="passwordForm.newPassword" placeholder="请输入新密码" @keyup.enter.native="editPassword"></el-input>
</el-form-item>
<el-form-item label="确认新密码">
<el-input type="password" v-model="passwordForm.reNewPassword" placeholder="请确认新密码" @keyup.enter.native="editPassword"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="passwordVisible = false"> </el-button>
<el-button size="small" type="primary" @click="editPassword"> </el-button>
</span>
</el-dialog>
</div> </div>
<el-dialog title="修改密码" :visible.sync="passwordVisible" :close-on-click-modal="false" :append-to-body="true"
@close="closePassword" width="30%">
<el-form ref="passwordForm" label-width="82px">
<el-form-item label="原密码">
<el-input type="password" v-model="passwordForm.password" placeholder="请输入原密码"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="passwordForm.newPassword" placeholder="请输入新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item>
<el-form-item label="确认新密码">
<el-input type="password" v-model="passwordForm.reNewPassword" placeholder="请确认新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="passwordVisible = false"> </el-button>
<el-button size="small" type="primary" @click="editPassword"> </el-button>
</span>
</el-dialog>
</div>
</template> </template>
<script> <script>
import navbar from '../navbar' import navbar from '../navbar'
@ -54,7 +57,7 @@ import { mapState, mapMutations, mapActions } from 'vuex'
import Setting from '@/setting' import Setting from '@/setting'
import util from '@/libs/util' import util from '@/libs/util'
export default { export default {
data() { data () {
return { return {
token: util.local.get(Setting.tokenKey), token: util.local.get(Setting.tokenKey),
isLogin: this.$route.path == '/login', isLogin: this.$route.path == '/login',
@ -79,7 +82,7 @@ export default {
'routes' 'routes'
]) ])
}, },
mounted() { mounted () {
// ,store,, // ,store,,
if (this.customer) { if (this.customer) {
let customer = atob(decodeURI(this.customer)) == 'false' ? false : true let customer = atob(decodeURI(this.customer)) == 'false' ? false : true
@ -104,7 +107,7 @@ export default {
'setInfo', 'logout', 'setManager', 'setCustomer' 'setInfo', 'logout', 'setManager', 'setCustomer'
]), ]),
// //
getUserInfo() { getUserInfo () {
this.$get(this.api.userInfo).then(res => { this.$get(this.api.userInfo).then(res => {
let userInfo = res.userInfo ? res.userInfo : {} let userInfo = res.userInfo ? res.userInfo : {}
let userAccount = res.userAccount let userAccount = res.userAccount
@ -114,16 +117,12 @@ export default {
avatar: userInfo.userAvatars, avatar: userInfo.userAvatars,
userName: userInfo.userName userName: userInfo.userName
}) })
//
userInfo.userName || this.$get(this.api.isClient).then(res => {
res.customerName && this.setInfo({userName: res.customerName})
}).catch(res => {})
}).catch(err => { }) }).catch(err => { })
}, },
hideSetting() { hideSetting () {
this.showSetting = false this.showSetting = false
}, },
toIndex() { toIndex () {
// //
if (this.$route.path === '/index/list') { if (this.$route.path === '/index/list') {
location.reload() location.reload()
@ -132,11 +131,11 @@ export default {
this.showSetting = true this.showSetting = true
} }
}, },
toLogin() { toLogin () {
window.open(this.$router.resolve('/login').href) window.open(this.$router.resolve('/login').href)
}, },
// //
toManager() { toManager () {
let routes = this.routes let routes = this.routes
if (routes.length) { if (routes.length) {
let route = this.$router.resolve({ let route = this.$router.resolve({
@ -154,7 +153,7 @@ export default {
util.warningMsg('该角色未开放模块,请联系管理员') util.warningMsg('该角色未开放模块,请联系管理员')
} }
}, },
userCommand(command) { userCommand (command) {
if (command == 'person') { if (command == 'person') {
this.$router.push('/setting/person').catch(err => { }) this.$router.push('/setting/person').catch(err => { })
} else if (command == 'resetPw') { } else if (command == 'resetPw') {
@ -165,10 +164,10 @@ export default {
this.logout() this.logout()
} }
}, },
showPassword() { showPassword () {
this.passwordVisible = true this.passwordVisible = true
}, },
editPassword() { editPassword () {
if (!this.passwordForm.password) return util.warningMsg('请输入原密码') if (!this.passwordForm.password) return util.warningMsg('请输入原密码')
if (!this.passwordForm.newPassword) return util.warningMsg('请输入新密码') if (!this.passwordForm.newPassword) return util.warningMsg('请输入新密码')
if (!this.passwordForm.reNewPassword) return util.warningMsg('请确认新密码') if (!this.passwordForm.reNewPassword) return util.warningMsg('请确认新密码')
@ -183,7 +182,7 @@ export default {
this.passwordVisible = false this.passwordVisible = false
}).catch(err => { }) }).catch(err => { })
}, },
closePassword() { closePassword () {
this.passwordForm = { this.passwordForm = {
password: '', password: '',
newPassword: '', newPassword: '',
@ -195,102 +194,125 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
$height: 64px; $height: 64px;
.header{
z-index: 10; .header {
position: fixed; z-index: 10;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: $height;
background-color: #fff;
box-shadow: 0px 0px 6px 0px rgba(178, 178, 178, 0.32);
.inner {
display: flex;
justify-content: space-between;
align-items: center;
min-width: $min-width;
padding: 0 80px 0 10px;
margin: 0 auto;
}
.logo {
position: absolute;
top: 0; top: 0;
left: 0; left: 80px;
width: 100%; font-size: 28px;
color: #568DF2;
line-height: $height;
cursor: pointer;
}
.search {
z-index: 2;
position: absolute;
top: 0;
left: 70%;
transform: translate(-50%);
display: flex;
justify-content: space-between;
align-items: center;
width: 300px;
height: $height; height: $height;
padding: 7px 20px;
margin: 0 auto;
background-color: #fff; background-color: #fff;
box-shadow: 0px 0px 6px 0px rgba(178, 178, 178, 0.32);
.inner{ input {
display: flex; width: 195px;
justify-content: space-between; margin-left: 10px;
align-items: center; font-size: 14px;
min-width: $min-width; color: #333;
padding: 0 80px 0 10px; background-color: transparent;
margin: 0 auto; border: 0;
&::-webkit-input-placeholder {
color: #999
}
&::-moz-placeholder {
color: #999
}
&:-moz-placeholder {
color: #999
}
&:focus {
outline: none;
}
} }
.logo{
position: absolute; .remove {
top: 0; cursor: pointer;
left: 80px;
font-size: 28px;
color: #568DF2;
line-height: $height;
cursor: pointer;
} }
.search{ .search-icon {
z-index: 2; width: 18px;
position: absolute;
top: 0;
left: 70%;
transform: translate(-50%);
display: flex;
justify-content: space-between;
align-items: center;
width: 300px;
height: $height;
padding: 7px 20px;
margin: 0 auto;
background-color: #fff;
input{
width: 195px;
margin-left: 10px;
font-size: 14px;
color: #333;
background-color: transparent;
border: 0;
&::-webkit-input-placeholder{color: #999}
&::-moz-placeholder{color: #999}
&:-moz-placeholder{color: #999}
&:focus{
outline: none;
}
}
.remove{
cursor: pointer;
}
.search-icon{
width: 18px;
}
} }
.action{ }
display: inline-flex;
align-items: center;
.icon{
cursor: pointer;
}
.user-wrap {
display: inline-flex;
align-items: center;
.user{ .action {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
cursor: pointer;
.username{ .icon {
margin-left: 10px; cursor: pointer;
color: #000;
font-size: 16px;
}
}
}
} }
.login{
.user-wrap {
display: inline-flex;
align-items: center;
.user {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
&:hover{
opacity: .9; .username {
} margin-left: 10px;
span{ color: #000;
margin-left: 5px; font-size: 16px;
color: #666;
font-size: 14px;
} }
}
}
}
.login {
display: inline-flex;
align-items: center;
cursor: pointer;
&:hover {
opacity: .9;
}
span {
margin-left: 5px;
color: #666;
font-size: 14px;
} }
}
} }
</style> </style>

@ -9,17 +9,10 @@
</ul> </ul>
<el-form :model="form" :rules="rules" ref="form" style="margin-top: 20px"> <el-form :model="form" :rules="rules" ref="form" style="margin-top: 20px">
<!-- 学号工号 --> <!-- 学号工号 -->
<div v-show="!form.distinguish"> <div v-show="!form.distinguish && !verCodeLogin" class="items">
<el-form-item class="school-select" prop="schoolId">
<label class="label school"></label>
<el-select v-model="form.schoolId" clearable filterable placeholder="请选择学校">
<el-option v-for="(item, i) in schoolList" :key="i" :label="item.schoolName"
:value="item.schoolId"></el-option>
</el-select>
</el-form-item>
<el-form-item class="flex-1" prop="workNumber"> <el-form-item class="flex-1" prop="workNumber">
<label class="label account"></label> <label class="label account"></label>
<el-input v-model.trim="form.workNumber" :placeholder="'请输入学号/工号'" <el-input v-model.trim="form.workNumber" placeholder="请输入学号/工号/手机号/邮箱"
@keyup.enter.native="submit"></el-input> @keyup.enter.native="submit"></el-input>
</el-form-item> </el-form-item>
</div> </div>
@ -28,7 +21,7 @@
<label class="label account"></label> <label class="label account"></label>
<el-input v-model.trim="form.account" placeholder="请输入账号" @keyup.enter.native="submit"></el-input> <el-input v-model.trim="form.account" placeholder="请输入账号" @keyup.enter.native="submit"></el-input>
</el-form-item> </el-form-item>
<template v-if="form.distinguish === 2"> <template v-if="verCodeLogin">
<el-form-item prop="account"> <el-form-item prop="account">
<label class="label account"></label> <label class="label account"></label>
<el-input v-model.trim="form.account" placeholder="请输入手机号/邮箱" @keyup.enter.native="submit"></el-input> <el-input v-model.trim="form.account" placeholder="请输入手机号/邮箱" @keyup.enter.native="submit"></el-input>
@ -44,7 +37,7 @@
</div> </div>
</el-form-item> </el-form-item>
</template> </template>
<template v-if="form.distinguish !== 2"> <template v-else>
<el-form-item prop="password"> <el-form-item prop="password">
<label class="password label"></label> <label class="password label"></label>
<el-input type="password" placeholder="请输入密码" v-model.trim="form.password" @keyup.enter.native="submit"> <el-input type="password" placeholder="请输入密码" v-model.trim="form.password" @keyup.enter.native="submit">
@ -57,8 +50,9 @@
<img @click="getVerImg" :src="verificationIMG" class="ver-img" alt=""> <img @click="getVerImg" :src="verificationIMG" class="ver-img" alt="">
</el-form-item> </el-form-item>
</template> </template>
<div v-show="!form.distinguish" class="default-check"> <div class="bottom">
<el-checkbox v-model="setDefault">设置为默认学校</el-checkbox> <el-link :underline="false" type="primary" @click="switchType">{{ verCodeLogin ? '密码' : '验证码' }}登录</el-link>
<el-link :underline="false" type="primary" @click="toAccount">没有账号点击申请</el-link>
</div> </div>
<el-button class="submit" type="primary" @click="submit">登录</el-button> <el-button class="submit" type="primary" @click="submit">登录</el-button>
</el-form> </el-form>
@ -75,7 +69,8 @@
<div class="ver-code"> <div class="ver-code">
<el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input> <el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input>
<el-button style="top: 1px" type="text" @click="sendPhoneCode(1)" <el-button style="top: 1px" type="text" @click="sendPhoneCode(1)"
:disabled="binding === '' || phoneDisabled">{{ phoneBtnText }}</el-button> :disabled="binding === '' || phoneDisabled">{{
phoneBtnText }}</el-button>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -135,36 +130,30 @@ export default {
tabList: [ tabList: [
{ {
id: 0, id: 0,
label: '学号/工号登录' label: '学生/老师登录'
}, { }, {
id: 1, id: 1,
label: '学校管理员登录' label: '学校管理员登录'
}, {
id: 2,
label: '手机号/邮箱'
} }
], ],
setDefault: !!util.local.get(schoolIdKey), // id
verificationIMG: '', verificationIMG: '',
schoolList: [], schoolList: [],
form: { form: {
schoolId: '',
workNumber: '', workNumber: '',
account: '', account: '', //
password: '', password: '',
code: '', // code: '', //
random: '', // random: '', //
distinguish: 0, // ,1,2 platform: Setting.platformId,
type: 2, // 0-> 1-> 2-> distinguish: 0,
platform: Setting.platformId
}, },
rules: { rules: {
schoolId: [{ required: true, message: "请选择学校", trigger: "change" }], workNumber: [{ required: true, message: "请输入学号/工号/手机号/邮箱", trigger: "blur" }],
workNumber: [{ required: true, message: "请输入学生学号", trigger: "blur" }],
account: [{ required: false, message: "请输入账号", trigger: "blur" }], account: [{ required: false, message: "请输入账号", trigger: "blur" }],
password: [{ required: true, message: "请输入密码", trigger: "blur" }], password: [{ required: true, message: "请输入密码", trigger: "blur" }],
code: [{ required: true, message: "请输入验证码", trigger: "blur" }] code: [{ required: true, message: "请输入验证码", trigger: "blur" }]
}, },
verCodeLogin: false,
phoneDisabledLogin: false, phoneDisabledLogin: false,
phoneTimerLogin: null, phoneTimerLogin: null,
phoneBtnTextLogin: '发送验证码', phoneBtnTextLogin: '发送验证码',
@ -187,7 +176,6 @@ export default {
}, },
components: { vHead, vFooter }, components: { vHead, vFooter },
mounted () { mounted () {
this.getSchool()
this.getVerImg() this.getVerImg()
}, },
methods: { methods: {
@ -197,21 +185,17 @@ export default {
...mapActions('user', [ ...mapActions('user', [
'login', 'setCustomer' 'login', 'setCustomer'
]), ]),
// id //
setSchool (list) { handleRule () {
this.schoolList = list const type = this.form.distinguish
// id const rules = this.rules
const schoolId = util.local.get(schoolIdKey) rules.workNumber[0].required = !type && !this.verCodeLogin
if (schoolId) this.form.schoolId = schoolId rules.account[0].required = (!type && this.verCodeLogin) || type
}, this.rules.account[0].message = type ?
// '请输入账号' :
getSchool () { this.verCodeLogin ?
this.$get(this.api.querySchool, { '请输入手机号/邮箱' :
provinceId: '', '请输入学号/工号/手机号/邮箱'
cityId: ''
}).then(({ list }) => {
this.setSchool(list)
}).catch(res => { })
}, },
// //
typeClick (tab) { typeClick (tab) {
@ -230,14 +214,7 @@ export default {
platform: form.platform platform: form.platform
} }
this.$refs.form.clearValidate() this.$refs.form.clearValidate()
// this.handleRule()
const rules = this.rules
rules.schoolId[0].required = id === 0
rules.workNumber[0].required = id === 0
rules.account[0].required = !!id
this.rules.account[0].message = id === 1 ?
'请输入账号' :
'请输入手机号/邮箱'
}, },
// //
chooseUser (user) { chooseUser (user) {
@ -275,11 +252,7 @@ export default {
this.$refs.form.validate(valid => { this.$refs.form.validate(valid => {
if (valid) { if (valid) {
const form = JSON.parse(JSON.stringify(this.form)) const form = JSON.parse(JSON.stringify(this.form))
const { distinguish } = form if (this.verCodeLogin) form.distinguish = 2
if (!form.distinguish && this.setDefault) util.local.set(schoolIdKey, form.schoolId) //
if (util.local.get(schoolIdKey) && !this.setDefault) util.local.remove(schoolIdKey) // id
if (distinguish) form.schoolId = ''
if (!distinguish) form.distinguish = 1
this.$post(this.api.logins, form).then(({ status, data, message }) => { this.$post(this.api.logins, form).then(({ status, data, message }) => {
// //
if (status == 30001) { if (status == 30001) {
@ -287,15 +260,11 @@ export default {
this.getVerImg() this.getVerImg()
form.code = '' form.code = ''
} else if (status == 200) { } else if (status == 200) {
const accounts = data.userAccounts
// //
if (data instanceof Array) { if (accounts instanceof Array) {
// this.users = accounts
if (data.length === 1) { this.userVisible = true
this.chooseUser(data[0])
} else {
this.users = data
this.userVisible = true
}
} else { } else {
this.token = data.token this.token = data.token
this.setLogin() this.setLogin()
@ -329,6 +298,17 @@ export default {
return true return true
}, },
//
switchType () {
this.verCodeLogin = !this.verCodeLogin
this.$refs.form.clearValidate()
this.handleRule()
},
//
toAccount () {
this.accountVisible = true
},
// //
phoneCountdownLogin () { phoneCountdownLogin () {
let count = 60 let count = 60
@ -502,7 +482,7 @@ export default {
.tab { .tab {
display: flex; display: flex;
justify-content: space-between; justify-content: space-around;
align-items: center; align-items: center;
margin-bottom: 24px; margin-bottom: 24px;
border-bottom: 2px solid #e1e6f2; border-bottom: 2px solid #e1e6f2;
@ -560,10 +540,12 @@ export default {
border-radius: 4px !important; border-radius: 4px !important;
} }
.default-check { .bottom {
text-align: right; display: flex;
justify-content: space-between;
} }
.el-select { .el-select {
width: 100%; width: 100%;
} }

@ -11,84 +11,84 @@ const url = location.host
const dev = process.env.NODE_ENV === 'development' // 本地 const dev = process.env.NODE_ENV === 'development' // 本地
let host = `${location.origin}/` let host = `${location.origin}/`
if (dev) { if (dev) {
host = 'https://www.dataforward.cn/' // host = 'https://www.dataforward.cn/'
// host = 'http://192.168.31.217:9000/' host = 'http://192.168.31.51:9000/'
} }
const Setting = { const Setting = {
/** /**
* 基础配置 * 基础配置
* */ * */
// 网页标题的后缀 // 网页标题的后缀
titleSuffix: '数据前瞻', titleSuffix: '数据前瞻',
// 路由模式,可选值为 history 或 hash // 路由模式,可选值为 history 或 hash
routerMode: 'hash', routerMode: 'hash',
// 页面切换时,是否显示模拟的进度条 // 页面切换时,是否显示模拟的进度条
showProgressBar: true, showProgressBar: true,
/** /**
* 接口地址 * 接口地址
* 测试http://121.37.12.51 * 测试http://121.37.12.51
* 正式https://www.dataforward.cn * 正式https://www.dataforward.cn
* */ * */
// apiBaseURL: env === 'development' ? 'http://192.168.31.151:9000' : 'http://121.37.12.51', // apiBaseURL: env === 'development' ? 'http://192.168.31.151:9000' : 'http://121.37.12.51',
apiBaseURL: host, apiBaseURL: host,
// 加密货币接口地址 // 加密货币接口地址
cryptoBaseURL: `http://159.138.53.111/`, cryptoBaseURL: `http://159.138.53.111/`,
// 接口请求返回错误时,弹窗的持续时间,单位:秒 // 接口请求返回错误时,弹窗的持续时间,单位:秒
modalDuration: 3, modalDuration: 3,
// 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice
errorModalType: 'Message', errorModalType: 'Message',
// Cookies 默认保存时间,单位:天 // Cookies 默认保存时间,单位:天
cookiesExpires: 1, cookiesExpires: 1,
// 长时间未操作,自动退出登录时间 // 长时间未操作,自动退出登录时间
autoLogoutTime: 3600000, autoLogoutTime: 3600000,
/** /**
* localStorage里保存的token的key * localStorage里保存的token的key
*/ */
tokenKey: 'data_token', tokenKey: 'data_token',
/** /**
* localStorage里保存的vuex的key * localStorage里保存的vuex的key
*/ */
storeKey: 'data_store', storeKey: 'data_store',
/** /**
* 默认密码 * 默认密码
*/ */
initialPassword: '1122aa', initialPassword: '1122aa',
/** /**
* 所属平台1->职站 2->数据平台 3->中台 * 所属平台1->职站 2->数据平台 3->中台
*/ */
platformId: 2, platformId: 2,
/** /**
* 平台端区分0->教师端 1->学生端 2->无端 * 平台端区分0->教师端 1->学生端 2->无端
*/ */
platformType: 2, platformType: 2,
/** /**
* 多语言配置 * 多语言配置
* */ * */
i18n: { i18n: {
// 默认语言 // 默认语言
default: 'zh', default: 'zh',
// 是否根据用户电脑配置自动设置语言(仅第一次有效) // 是否根据用户电脑配置自动设置语言(仅第一次有效)
auto: false auto: false
}, },
/** /**
* 布局配置 * 布局配置
* */ * */
layout: { layout: {
}, },
/** /**
* 功能配置 * 功能配置
* */ * */
// 相同路由,不同参数间进行切换,是否强力更新 // 相同路由,不同参数间进行切换,是否强力更新
sameRouteForceUpdate: false, sameRouteForceUpdate: false,
// 是否使用动态路由 // 是否使用动态路由
dynamicRoute: true, dynamicRoute: true,
// 文件上传 // 文件上传
upload: { upload: {
apiURL: 'http://8.134.8.197:8001', apiURL: 'http://8.134.8.197:8001',
maxSize: 30, maxSize: 30,
}, },
}; };
export default Setting; export default Setting;

@ -9,102 +9,99 @@
import Setting from '@/setting' import Setting from '@/setting'
import util from '@/libs/util' import util from '@/libs/util'
import {post,get,del,put} from '@/plugins/requests/index.js' import { post, get } from '@/plugins/requests/index.js'
import api from '@/api' import api from '@/api'
/** /**
* 用户信息 * 用户信息
* */ * */
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png', avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
schoolId: '', schoolId: '',
userName: '', userName: '',
isManager: false, isManager: false,
isCustomer: false, isCustomer: false,
logView: false // 是否查询过日志状态,如果有,则不再调接口 logView: false // 是否查询过日志状态,如果有,则不再调接口
},
mutations: {
SET_INFO: (state, info) => {
if (info.avatar) state.avatar = info.avatar
if (info.schoolId) state.schoolId = info.schoolId
if (info.userName) state.userName = info.userName
}, },
mutations: { SET_AVATAR: (state, avatar) => {
SET_INFO: (state, info) => { state.avatar = avatar
if(info.avatar) state.avatar = info.avatar
if(info.schoolId) state.schoolId = info.schoolId
if(info.userName) state.userName = info.userName
},
SET_AVATAR: (state, avatar) => {
state.avatar = avatar
},
SET_MANAGER: (state, isManager) => {
state.isManager = isManager
},
SET_CUSTOMER: (state, isCustomer) => {
state.isCustomer = isCustomer
},
SET_LOG: (state) => {
state.logView = true
},
}, },
actions: { SET_MANAGER: (state, isManager) => {
login({ state,commit }, userInfo) { state.isManager = isManager
const { account, password, code, random, distinguish } = userInfo },
return new Promise((resolve, reject) => { SET_CUSTOMER: (state, isCustomer) => {
post(api.logins,{ state.isCustomer = isCustomer
account, },
password, SET_LOG: (state) => {
code, state.logView = true
random, },
distinguish, },
type: 2, // 平台端区分:0->教师端 1->学生端 2->无端 actions: {
platform: Setting.platformId, // 所属平台id(1.职站 2.数据平台 3.中台) login ({ state, commit }, userInfo) {
}).then(res => { const { account, password, code, random, distinguish } = userInfo
if(res.status == 200){ return new Promise((resolve, reject) => {
util.local.set(Setting.tokenKey,res.data.token,43200000) post(api.logins, {
util.successMsg('登录成功') account,
get(api.isClient).then(res => { password,
commit('SET_CUSTOMER',res.customer) code,
const userName = res.customerName random,
userName && commit('SET_INFO', { distinguish,
userName type: 2, // 平台端区分:0->教师端 1->学生端 2->无端
}) platform: Setting.platformId, // 所属平台id(1.职站 2.数据平台 3.中台)
}).catch(res => {}) }).then(res => {
post(api.getSchoolIdByToken).then(res => { if (res.status == 200) {
commit('SET_INFO',res) util.local.set(Setting.tokenKey, res.data.token, 43200000)
}).catch(res => {}) util.successMsg('登录成功')
setTimeout(() => { post(api.getSchoolIdByToken).then(res => {
// 登录次数+1 commit('SET_INFO', res)
post(api.saveRecord,{ }).catch(res => { })
type: 3, setTimeout(() => {
}).then(res => {}).catch(res => {}) // 登录次数+1
},3000) post(api.saveRecord, {
resolve() type: 3,
}else{ }).then(res => { }).catch(res => { })
util.errorMsg(res.message) }, 3000)
reject(res) resolve()
} } else {
}).catch(error => { util.errorMsg(res.message)
reject(error) reject(res)
}) }
}) }).catch(error => {
}, reject(error)
logout({ commit, state, dispatch }) { })
return new Promise((resolve, reject) => { })
util.local.remove(Setting.storeKey) },
util.local.remove(Setting.tokenKey) logout ({ commit, state, dispatch }) {
location.reload() return new Promise((resolve, reject) => {
resolve() post(api.logout).then(() => {
}) util.local.remove(Setting.storeKey)
}, util.local.remove(Setting.tokenKey)
setAvatar({ state,commit },avatar) { location.reload()
commit('SET_AVATAR',avatar) resolve()
}, }).catch(error => {
setInfo({ state,commit },info) { reject(error)
commit('SET_INFO',info) })
}, })
setManager({ state,commit },isManager) { },
commit('SET_MANAGER',isManager) setAvatar ({ state, commit }, avatar) {
}, commit('SET_AVATAR', avatar)
setCustomer({ state,commit },isCustomer) { },
commit('SET_CUSTOMER',isCustomer) setInfo ({ state, commit }, info) {
}, commit('SET_INFO', info)
} },
setManager ({ state, commit }, isManager) {
commit('SET_MANAGER', isManager)
},
setCustomer ({ state, commit }, isCustomer) {
commit('SET_CUSTOMER', isCustomer)
},
}
} }
Loading…
Cancel
Save