登录修改

dev_2022-04-07
yujialong 3 years ago
parent 4eff988c3a
commit 13f701d7d3
  1. 18
      src/api/index.js
  2. 8
      src/layouts/header/index.vue
  3. 268
      src/pages/account/login/index.vue
  4. 2
      src/pages/index/list/index.vue
  5. 21
      src/pages/setting/person/info.vue

@ -1,16 +1,19 @@
import Setting from "@/setting"; import Setting from "@/setting";
let host = Setting.apiBaseURL; const host = Setting.apiBaseURL;
let uploadURL = "http://39.108.250.202:9000/"; const host1 = `http://192.168.31.137:9000/`
const uploadURL = "http://39.108.250.202:9000/";
export default { export default {
host, host,
// 登录 // 登录
logins: `users/users/user/login`, //登录 logins: `${host1}users/users/user/login`,
verification: `${host}users/users/user/captcha`,// 验证码图片 verification: `${host1}users/users/user/captcha`,// 验证码图片
logoDetail: `occupationlab/sys/logo/detail`, //查看系统设置信息 logoDetail: `occupationlab/sys/logo/detail`, //查看系统设置信息
isClient: `${host}users/users/user/isClient`, isClient: `${host1}users/users/user/isClient`,
sendPhoneVerificationCode: `${host1}users/users/user/sendPhoneVerificationCode`,
getToken: `${host1}users/users/user/getToken`,
platformLogList: `nakadai/log/platformLogList`, platformLogList: `nakadai/log/platformLogList`,
logNotification: `nakadai/log/logNotification`, logNotification: `nakadai/log/logNotification`,
@ -81,18 +84,19 @@ export default {
queryProvince: `nakadai/nakadai/province/queryProvince`, //查询省份 queryProvince: `nakadai/nakadai/province/queryProvince`, //查询省份
queryCity: `nakadai/nakadai/city/queryCity`, //查询城市 queryCity: `nakadai/nakadai/city/queryCity`, //查询城市
querySchool: `nakadai/nakadai/school/querySchool`, //根据学校名称查询学校信息 querySchool: `${host1}nakadai/nakadai/school/querySchool`, //根据学校名称查询学校信息
queryCourseDiscipline: `nakadai/nakadai/subject/courseDiscipline`, //查询课程学科 queryCourseDiscipline: `nakadai/nakadai/subject/courseDiscipline`, //查询课程学科
queryCourseProfessionalClass: `nakadai/nakadai/subject/courseProfessionalClass`, //查询专业类 queryCourseProfessionalClass: `nakadai/nakadai/subject/courseProfessionalClass`, //查询专业类
queryCourseProfessional: `nakadai/nakadai/subject/courseProfessional`, //查询专业 queryCourseProfessional: `nakadai/nakadai/subject/courseProfessional`, //查询专业
// 个人中心 // 个人中心
uploadUserAvatars: `users/users/userAccount/updateUserAvatars`, //更改头像 uploadUserAvatars: `${host}users/users/userAccount/updateUserAvatars`, //更改头像
queryUserInfoDetails: `users/users/userAccount/queryUserInfoDetails`,//个人中心信息展示 queryUserInfoDetails: `users/users/userAccount/queryUserInfoDetails`,//个人中心信息展示
updatePersonCenter: `users/users/userAccount/updatePersonCenter`,//个人中心信息修改 updatePersonCenter: `users/users/userAccount/updatePersonCenter`,//个人中心信息修改
examinePassword: `users/users/userAccount/examinePassword`,//更换密码 examinePassword: `users/users/userAccount/examinePassword`,//更换密码
bindPhoneOrEmail: `users/users/userAccount/bindPhoneOrEmail`,// 绑定手机或邮箱 bindPhoneOrEmail: `users/users/userAccount/bindPhoneOrEmail`,// 绑定手机或邮箱
sendPhoneOrEmailCode: `users/users/userAccount/sendPhoneOrEmailCode`,// 更换手机号或邮箱--发送手机验证码 sendPhoneOrEmailCode: `users/users/userAccount/sendPhoneOrEmailCode`,// 更换手机号或邮箱--发送手机验证码
unbindMobilePhone: `users/users/userAccount/unbindMobilePhone`,
joinPractice: `tms/classTech/joinPractice`, //通过邀请码进入实验 joinPractice: `tms/classTech/joinPractice`, //通过邀请码进入实验
queryArchievement: `tms/classTech/queryExperimentalReport`, //查看教学实验报告 queryArchievement: `tms/classTech/queryExperimentalReport`, //查看教学实验报告

@ -75,10 +75,10 @@ export default {
}).catch(res => {}) }).catch(res => {})
}, },
getSystemDetail () { getSystemDetail () {
this.$get(this.api.logoDetail).then(res => { this.$get(this.api.logoDetail).then(({ data }) => {
if (res.data) { if (data) {
this.setTitle(res.data.title); this.setTitle(data.title);
this.setLogoUrl(res.data.logoUrl); this.setLogoUrl(data.logoUrl);
} }
}).catch(res => {}); }).catch(res => {});
}, },

@ -6,18 +6,18 @@
<ul class="tab"> <ul class="tab">
<li v-for="(item,index) in tabList" :key="index" :class="{active: form.distinguish == item.id}" @click="typeClick(item)">{{item.label}}</li> <li v-for="(item,index) in tabList" :key="index" :class="{active: form.distinguish == item.id}" @click="typeClick(item)">{{item.label}}</li>
</ul> </ul>
<el-form :model="form" :rules="loginRules" 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">
<div class="items" style="margin-bottom: 20px">
<el-form-item class="school-select" prop="schoolId"> <el-form-item class="school-select" prop="schoolId">
<label class="label school"></label> <label class="label school"></label>
<el-select v-model="form.schoolId" clearable filterable placeholder="请选择学校"> <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-option v-for="(item, i) in schoolList" :key="i" :label="item.schoolName" :value="item.schoolId"></el-option>
</el-select> </el-select>
</el-form-item> <div class="default-check">
<el-checkbox v-model="setDefault">设置为默认学校</el-checkbox> <el-checkbox v-model="setDefault">设置为默认学校</el-checkbox>
</div> </div>
</el-form-item>
<div class="items"> <div class="items">
<el-form-item prop="type" style="width: 35%;margin-right: 15px"> <el-form-item prop="type" style="width: 35%;margin-right: 15px">
<label class="label workNumber"></label> <label class="label workNumber"></label>
@ -28,25 +28,37 @@
</el-form-item> </el-form-item>
<el-form-item prop="workNumber"> <el-form-item prop="workNumber">
<label class="label account"></label> <label class="label account"></label>
<el-input v-model.trim="form.workNumber" :placeholder="'请输入' + (form.type ? '学生学号' : '老师工号')"></el-input> <el-input v-model.trim="form.workNumber" :placeholder="'请输入' + (form.type ? '学生学号' : '老师工号')" @keyup.enter.native="submit"></el-input>
</el-form-item> </el-form-item>
</div> </div>
</div> </div>
<!-- 手机号登录 --> <!-- 手机号登录 -->
<el-form-item v-show="form.distinguish === 1" prop="account"> <el-form-item v-show="form.distinguish === 1" prop="account">
<label class="label account"></label> <label class="label account"></label>
<el-input v-model.trim="form.account" placeholder="请输入账号"></el-input> <el-input v-model.trim="form.account" placeholder="请输入账号" @keyup.enter.native="submit"></el-input>
</el-form-item> </el-form-item>
<el-form-item v-show="form.distinguish === 2" prop="account"> <template v-if="form.distinguish === 2">
<el-form-item prop="account">
<label class="label account"></label> <label class="label account"></label>
<el-input v-model.trim="form.account" placeholder="请输入手机号"></el-input> <el-input v-model.trim="form.account" placeholder="请输入手机号/邮箱" @keyup.enter.native="submit"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="code">
<label class="label code"></label>
<div class="flex">
<el-input v-model="form.code" placeholder="请输入验证码" maxlength="6" @keyup.enter.native="submit"></el-input>
<el-button style="margin-left: 10px" type="text" @click="sendPhoneCodeLogin" :disabled="phoneDisabledLogin">{{ phoneBtnTextLogin }}
</el-button>
</div>
</el-form-item>
</template>
<template v-if="form.distinguish !== 2">
<el-form-item prop="password"> <el-form-item prop="password">
<label class="password label"></label> <label class="password label"></label>
<el-input <el-input
type="password" type="password"
placeholder="请输入密码" placeholder="请输入密码"
v-model.trim="form.password" v-model.trim="form.password"
@keyup.enter.native="submit"
> >
</el-input> </el-input>
</el-form-item> </el-form-item>
@ -60,6 +72,7 @@
</el-input> </el-input>
<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>
<el-button class="submit" type="primary" @click="submit">登录</el-button> <el-button class="submit" type="primary" @click="submit">登录</el-button>
</el-form> </el-form>
</div> </div>
@ -75,8 +88,7 @@
<el-form-item label="验证码"> <el-form-item label="验证码">
<div style="display: flex;"> <div style="display: flex;">
<el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input> <el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input>
<el-button style="margin-left: 10px" type="text" @click="sendPhoneCode" <el-button style="margin-left: 10px" type="text" @click="sendPhoneCode" :disabled="phoneDisabled">{{ phoneBtnText }}
:disabled="phoneDisabled">{{ phoneBtnText }}
</el-button> </el-button>
</div> </div>
</el-form-item> </el-form-item>
@ -101,16 +113,8 @@
<el-dialog title="请选择您要登录的用户" :visible.sync="userVisible" :close-on-click-modal="false" custom-class="user-dia" width="500px"> <el-dialog title="请选择您要登录的用户" :visible.sync="userVisible" :close-on-click-modal="false" custom-class="user-dia" width="500px">
<p class="tips">该手机号已绑定以下用户信息</p> <p class="tips">该手机号已绑定以下用户信息</p>
<ul class="users"> <ul class="users">
<li> <li v-for="(user, i) in users" :key="i" @click="chooseUser(user)">
<span>中山大学孙逸仙工号8814</span> <span>{{ user.schoolName }}{{ user.userName }}{{ user.workNumber }}</span>
<i class="el-icon-right"></i>
</li>
<li>
<span>中山大学孙逸仙工号8814</span>
<i class="el-icon-right"></i>
</li>
<li>
<span>中山大学孙逸仙工号8814</span>
<i class="el-icon-right"></i> <i class="el-icon-right"></i>
</li> </li>
</ul> </ul>
@ -140,37 +144,42 @@ export default {
label: '手机号/邮箱' label: '手机号/邮箱'
} }
], ],
setDefault: !!util.local.get('schoolId'), setDefault: !!util.local.get('schoolId'), // id
verificationIMG: "", verificationIMG: '',
schoolList: [], schoolList: [],
form: { form: {
schoolId: '', schoolId: '',
workNumber: '', workNumber: '',
account: '', account: '',
password: "", password: '',
code: "", // code: '', //
random: "", // random: '', //
distinguish: 0, // ,1,2 distinguish: 0, // ,1,2
type: 1, // 0-> 1-> 2-> type: 1, // 0-> 1-> 2->
platform: Setting.platformId platform: Setting.platformId
}, },
loginRules: { rules: {
schoolId: [{ required: true, message: "请选择学校", trigger: "change" }], 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" }]
}, },
phoneDisabledLogin: false,
phoneTimerLogin: null,
phoneBtnTextLogin: '发送验证码',
phoneVisible: false, phoneVisible: false,
phone: "", phone: '',
phoneCode: "", phoneCode: '',
phoneDisabled: false, phoneDisabled: false,
phoneTimer: null, phoneTimer: null,
phoneBtnText: "发送验证码", phoneBtnText: '发送验证码',
selectVisible: false, selectVisible: false,
selectedRole: '', selectedRole: '',
token: '', token: '',
userVisible: false userVisible: false,
users: []
}; };
}, },
components: { components: {
@ -181,8 +190,10 @@ export default {
this.getSchool() this.getSchool()
// //
this.$once("hook:beforeDestroy", function() { this.$once("hook:beforeDestroy", function() {
clearInterval(this.phoneTimer); clearInterval(this.phoneTimer)
this.phoneTimer = null; clearInterval(this.phoneTimerLogin)
this.phoneTimer = null
this.phoneTimerLogin = null
}); });
}, },
methods: { methods: {
@ -198,6 +209,7 @@ export default {
cityId: '' cityId: ''
}).then(res => { }).then(res => {
this.schoolList = res.list this.schoolList = res.list
// id
const schoolId = util.local.get('schoolId') const schoolId = util.local.get('schoolId')
if (schoolId) this.form.schoolId = schoolId if (schoolId) this.form.schoolId = schoolId
}).catch(res => {}) }).catch(res => {})
@ -210,22 +222,31 @@ export default {
typeClick(tab) { typeClick(tab) {
const { id } = tab const { id } = tab
const form = this.form const form = this.form
// //
form.account = '' this.form = {
form.workNumber = '' schoolId: form.schoolId,
form.schoolId = '' workNumber: '',
form.type = 1 account: '',
form.distinguish = id password: '',
code: '',
random: form.random,
distinguish: id,
type: 1,
platform: form.platform
}
this.$refs.form.clearValidate() this.$refs.form.clearValidate()
// //
const rules = this.loginRules const rules = this.rules
rules.account[0].required = id === 1
rules.schoolId[0].required = id === 0 rules.schoolId[0].required = id === 0
rules.workNumber[0].required = id === 0 rules.workNumber[0].required = id === 0
rules.account[0].required = !!id
this.rules.account[0].message = id === 1 ?
'请输入账号' :
'请输入手机号/邮箱'
}, },
// //
typeChange(id) { typeChange(id) {
this.loginRules.workNumber[0].message = id === 1 ? this.rules.workNumber[0].message = id === 1 ?
'请输入学生学号' : '请输入学生学号' :
'请输入老师工号' '请输入老师工号'
}, },
@ -233,6 +254,29 @@ export default {
reloadIndex() { reloadIndex() {
window.opener && window.opener.location.reload() window.opener && window.opener.location.reload()
}, },
//
chooseUser(user) {
this.$post(`${this.api.getToken}?id=${user.id}`).then(({ data }) => {
this.queryClient(data.token)
}).catch(res => {})
},
//
queryClient(token) {
this.token = token
axios.get(this.api.isClient, {
headers: {
token
}
}).then(({ data }) => {
//
if (data.customer) {
this.SET_CUSTOMERNAME(data.customerName)
this.selectVisible = true
} else {
this.setLogin()
}
}).catch(res => {})
},
// //
setLogin() { setLogin() {
util.local.set(Setting.tokenKey, this.token, Setting.tokenExpires) util.local.set(Setting.tokenKey, this.token, Setting.tokenExpires)
@ -244,8 +288,12 @@ export default {
submit() { // submit() { //
this.$refs.form.validate(valid => { this.$refs.form.validate(valid => {
if (valid) { if (valid) {
const form = this.form const form = JSON.parse(JSON.stringify(this.form))
if (!form.distinguish && this.setDefault) util.local.set('schoolId', form.schoolId) const { distinguish } = form
if (!form.distinguish && this.setDefault) util.local.set('schoolId', form.schoolId) //
if (util.local.get('schoolId') && !this.setDefault) util.local.remove('schoolId') // 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) {
@ -253,23 +301,13 @@ export default {
this.getVerImg() this.getVerImg()
form.code = '' form.code = ''
} else if (status == 200) { } else if (status == 200) {
const { token } = data //
this.token = token if (data instanceof Array) {
// this.users = data
// this.setLogin() this.userVisible = true
axios.get(this.api.isClient, {
headers: {
token
}
}).then(({ data }) => {
//
if (data.customer) {
this.SET_CUSTOMERNAME(data.customerName)
this.selectVisible = true
} else { } else {
this.setLogin() this.queryClient(data.token)
} }
}).catch(res => {})
} else { } else {
util.errorMsg(message) util.errorMsg(message)
} }
@ -297,60 +335,99 @@ export default {
`${location.origin}/admin/#/redirect?auth=${window.btoa(this.token)}` `${location.origin}/admin/#/redirect?auth=${window.btoa(this.token)}`
} }
}, },
//
verifyPhone(phone) {
if (!phone) {
util.warningMsg("请输入手机号")
return false
}
if (!/^1[3456789]\d{9}$/.test(phone) && !/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(phone)) {
util.warningMsg("请输入正确的手机号/邮箱")
return false
}
return true
},
//
phoneCountdownLogin() {
let count = 60
if (!this.phoneTimerLogin) {
this.phoneDisabledLogin = true
this.phoneTimerLogin = setInterval(() => {
if (count > 0) {
count--
this.phoneBtnTextLogin = `${count}秒后重试`
} else {
this.phoneDisabledLogin = false
clearInterval(this.phoneTimerLogin)
this.phoneTimerLogin = null
this.phoneBtnTextLogin = `发送验证码`
}
}, 1000)
}
},
//
sendPhoneCodeLogin() {
const phone = this.form.account
if (!this.verifyPhone(phone)) return false
this.$post(`${this.api.sendPhoneVerificationCode}?phoneOrEmail=${phone}`).then(({ message }) => {
util.successMsg(message)
this.phoneCountdownLogin()
}).catch(res => {})
},
//
phoneCountdown() { phoneCountdown() {
let count = 60; let count = 60
if (!this.phoneTimer) { if (!this.phoneTimer) {
this.phoneDisabled = true; this.phoneDisabled = true
this.phoneTimer = setInterval(() => { this.phoneTimer = setInterval(() => {
console.log("倒计时中");
if (count > 0) { if (count > 0) {
count--; count--
this.phoneBtnText = `${count}秒后重试`; this.phoneBtnText = `${count}秒后重试`
} else { } else {
this.phoneDisabled = false; this.phoneDisabled = false
clearInterval(this.phoneTimer); clearInterval(this.phoneTimer)
this.phoneTimer = null; this.phoneTimer = null
this.phoneBtnText = `发送验证码`; this.phoneBtnText = `发送验证码`
} }
}, 1000); }, 1000)
} }
}, },
//
sendPhoneCode() { sendPhoneCode() {
if (!this.phone) return util.warningMsg("请输入手机号"); const { phone } = this
if (!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg("请输入正确的手机号"); if (!this.verifyPhone(phone)) return false
let data = { this.$post(this.api.sendPhoneOrEmailCode, {
platform: Setting.platformId, platform: Setting.platformId,
phone: this.phone, phone,
types: 2 types: 2
}; }).then(({ message }) => {
this.$post(this.api.sendPhoneOrEmailCode, data).then(res => { if (message.opener) {
if (res.message.opener) { this.phoneCountdown()
this.phoneCountdown(); this.phoneOpener = message.opener
this.phoneOpener = res.message.opener;
} else { } else {
util.errorMsg(res.message); util.errorMsg(message)
} }
}).catch(res => {})
}).catch(res => {
});
}, },
//
phoneSubmit() { phoneSubmit() {
if (!this.phone) return util.warningMsg("请输入手机号"); const { phone, phoneCode } = this
if (!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg("请输入正确的手机号"); if (!this.verifyPhone(phone)) return false
if (!this.phoneCode) return util.warningMsg("请输入验证码"); if (!phoneCode) return util.warningMsg("请输入验证码")
let data = { this.$post(this.api.bindPhoneOrEmail, {
phone: this.phone, phone,
types: 2, types: 2,
code: this.phoneCode, code: phoneCode,
opener: this.phoneOpener, opener: this.phoneOpener,
platform: Setting.platformId, platform: Setting.platformId,
account: this.form.workNumber account: this.form.workNumber
}; }).then(({ token }) => {
this.$post(this.api.bindPhoneOrEmail, data).then(res => { util.successMsg("绑定成功")
util.successMsg("绑定成功"); this.form.phone = this.phone
this.form.phone = this.phone; this.phoneVisible = false
this.phoneVisible = false; this.token = token
this.token = res.token
this.setLogin() this.setLogin()
}).catch(res => {}) }).catch(res => {})
} }
@ -424,9 +501,10 @@ export default {
border-radius: 4px !important; border-radius: 4px !important;
} }
.school-select { .school-select {
flex: 1; // margin-bottom: 10px;
margin-right: 10px; }
margin-bottom: 0; .default-check {
text-align: right;
} }
.el-select { .el-select {
width: 100%; width: 100%;

@ -166,7 +166,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="product bg-white"> <div class="product">
<div class="inner"> <div class="inner">
<div class="pics"> <div class="pics">
<div class="text"> <div class="text">

@ -135,9 +135,8 @@
<ul class="list"> <ul class="list">
<div class="line info imp"> <div class="line info imp">
<li> <li>
<label>用户账号</label> <label>学号</label>
<el-input class="m-r-10" size="small" v-model="form.account" clearable disabled></el-input> <el-input class="m-r-10" style="width: 220px" size="small" v-model="form.workNumber" clearable disabled></el-input>
<el-button type="text" size="small" @click="openAccount">编辑</el-button>
</li> </li>
<li> <li>
<label>手机号</label> <label>手机号</label>
@ -368,14 +367,16 @@ export default {
'setAvatar','setUserName' 'setAvatar','setUserName'
]), ]),
getdata() { getdata() {
this.$get(this.api.queryUserInfoDetails).then(res => { this.$get(this.api.queryUserInfoDetails).then(({ result }) => {
let userInfo = res.result.hrUserInfo const userInfo = result.hrUserInfo
let schoolId = userInfo.schoolId const { userAccount } = result
this.form = Object.assign(userInfo, res.result.userAccountList[0]) userInfo.account = userAccount.account
this.form.schoolId = schoolId userInfo.phone = userAccount.phone
this.form.accountId = userInfo.id userInfo.email = userAccount.email
userInfo.workNumber = userAccount.workNumber
this.form = userInfo
this.originAccount = this.form.account this.originAccount = this.form.account
this.archivesList = res.result.personalFileList this.archivesList = result.personalFileList
this.$nextTick(() => { this.$nextTick(() => {
if(this.form.provinceId){ if(this.form.provinceId){
this.getCityData(1) this.getCityData(1)

Loading…
Cancel
Save