yujialong 1 month ago
parent fa8c6a1fb3
commit b408562376
  1. 6
      src/api/index.js
  2. 16
      src/layouts/header/index.vue
  3. 31
      src/layouts/home/index.vue
  4. 35
      src/pages/account/login/index.vue
  5. 557
      src/pages/setting/list/index.vue
  6. 475
      src/pages/setting/list/info.vue
  7. 23
      src/plugins/requests/index.js
  8. 9
      src/router/permission.js
  9. 1
      src/setting.js
  10. 19
      src/store/modules/user.js

@ -9,6 +9,12 @@ export default {
forgotPreVerification: `/users/users/user/forgotPreVerification`,
sendPhoneVerificationCode: `/users/users/user/sendPhoneVerificationCode`,
queryUserInfoDetails: `/users/users/userAccount/queryUserInfoDetails`,
updatePersonCenter: `/users/users/userAccount/updatePersonCenter`,
logout: `/users/users/user/logout`,
updateUserAvatars: `${host}/users/users/userAccount/updateUserAvatars`,
examinePassword: `/users/users/userAccount/examinePassword`,
bindPhoneOrEmail: `/users/users/userAccount/bindPhoneOrEmail`,
sendPhoneOrEmailCode: `/users/users/userAccount/sendPhoneOrEmailCode`,
getUserRolesPermissionMenu: `/users/users/user-role/getUserRolesPermissionMenu`,
getCurrentTime: `/competition/competition/management/getCurrentTime`,

@ -8,7 +8,7 @@
<span class="username">{{ userName }}</span>
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="person">个人中心</el-dropdown-item>
<el-dropdown-item command="person">个人资料</el-dropdown-item>
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@ -38,12 +38,22 @@ export default {
])
},
mounted () {
this.getUserInfo()
},
methods: {
...mapMutations("user", [
'setAvatar', 'setUserName', 'setUserId'
]),
...mapActions("user", [
'logout'
]),
async getUserInfo () {
const res = await this.$get(this.api.queryUserInfoDetails)
const { userAvatars, userName } = res.result.hrUserInfo || {}
userAvatars && this.setAvatar(userAvatars)
res.result.userAccount && localStorage.setItem('reviewAID', res.result.userAccount.id)
this.setUserName(userName)
},
//
userCommand (command) {
if (command == 'person') {
@ -110,7 +120,7 @@ export default {
.username {
margin-left: 8px;
color: #333;
color: #fff;
font-size: 14px;
}
}

@ -1,8 +1,8 @@
<template>
<div style="height: 100%">
<v-head v-if="showHeader" />
<div :class="inIframe ? 'full' : 'frame'">
<v-head v-if="inIframe" />
<div class="main">
<v-navbar class="nav" />
<v-navbar v-if="!inIframe" class="nav" />
<div class="layout">
<div class="content">
<transition name="move" mode="out-in">
@ -17,14 +17,13 @@
<script>
import Setting from '@/setting'
import Util from '@/libs/util'
import vHead from '../header/index.vue'
import vNavbar from '../navbar/index.vue'
import vFooter from '../footer'
export default {
data () {
return {
showHeader: false
inIframe: !Setting.inIframe // iframe
};
},
components: {
@ -47,27 +46,35 @@ export default {
.nav {
width: 190px;
margin-right: 24px;
}
.layout {
width: calc(100% - 190px);
width: calc(100% - 214px);
.content {
height: 100vh;
padding-left: 24px;
overflow: auto;
.view {
min-height: 100%;
}
}
}
}
&.full {
width: 100%;
.frame {
height: 100%;
}
.content {
padding-left: 0;
}
.full {
padding: 20px;
.layout {
width: 100%;
.content {
height: auto;
}
}
}

@ -119,13 +119,14 @@ export default {
phoneReg: /^1[3456789]\d{9}$/,
mailReg: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
verificationIMG: '',
platform: 4,
form: {
workNumber: '',
account: '', //
password: '',
code: '', //
random: '', //
platform: 3,
platform: 4,
distinguish: 1,
},
rules: {
@ -191,17 +192,8 @@ export default {
//
typeClick (tab) {
const { id } = tab
const form = this.form
//
this.form = {
workNumber: '',
account: '',
password: '',
code: '',
random: form.random,
distinguish: id,
platform: form.platform
}
this.form.password = ''
this.form.code = ''
this.rules.password[0].required = !id
this.active = id
this.$refs.form.clearValidate()
@ -213,15 +205,8 @@ export default {
if (valid) {
const form = JSON.parse(JSON.stringify(this.form))
this.$post(this.api.login, form).then(({ status, data, message }) => {
//
if (status == 30001) {
this.phoneVisible = true
this.getVerImg()
form.code = ''
} else if (status == 200) {
// Util.local.set(Setting.tokenKey, this.token, Setting.tokenExpires)
// localStorage.setItem('review_token', token)
// localStorage.setItem('isExpert', true)
if (status == 200) {
localStorage.setItem('expert_token', data.token)
Util.successMsg('登录成功')
this.$router.replace(`/myReview`)
@ -263,7 +248,7 @@ export default {
async sendCodePw () {
const { phoneOrEmail } = this.pwForm
if (!this.verifyPhone(phoneOrEmail)) return false
const { message } = await this.$post(`${this.api.sendPhoneVerificationCode}?phoneOrEmail=${phoneOrEmail}&loginOrBind=1&platform=${Setting.platformId}`)
const { message } = await this.$post(`${this.api.sendPhoneVerificationCode}?phoneOrEmail=${phoneOrEmail}&loginOrBind=1&platform=${this.platform}`)
Util.successMsg(message)
this.phoneCountdown()
},
@ -273,7 +258,7 @@ export default {
if (valid) {
const form = this.pwForm
if (form.password !== form.rePassword) return Util.errorMsg('两次输入的密码不一致,请重新输入!')
form.platform = Setting.platformId
form.platform = this.platform
this.$post(this.api.forgotPassword, form).then(res => {
this.resetPwVisible = false
Util.successMsg('密码重置成功!请重新登录。')
@ -292,7 +277,7 @@ export default {
}
try {
const { message } = await this.$get(`${this.api.forgotPreVerification}?phoneOrEmail=${val}&platform=${Setting.platformId}`)
const { message } = await this.$get(`${this.api.forgotPreVerification}?phoneOrEmail=${val}&platform=${this.platform}`)
const exist = message === 'success' //
this[type ? 'diaClientExist' : 'verFormEnable'] = exist
this.diaClientMsg = exist ? '' : message
@ -324,7 +309,7 @@ export default {
sendPhoneCodeLogin () {
const phone = this.form.account
if (!this.verifyPhone(phone)) return false
this.$post(`${this.api.sendPhoneVerificationCode}?phoneOrEmail=${phone}&loginOrBind=0&platform=${Setting.platformId}`).then(({ message }) => {
this.$post(`${this.api.sendPhoneVerificationCode}?phoneOrEmail=${phone}&loginOrBind=0&platform=${this.platform}`).then(({ message }) => {
Util.successMsg(message)
this.phoneCountdownLogin()
}).catch(res => { })

@ -1,131 +1,478 @@
<template>
<div class="main">
<div class="left">
<div class="inner">
<div class="text-center">
<img :src="avatar" class="avatar" />
<el-upload :action="this.api.updateUserAvatars" name="file" :data="{ userId }" :limit="10" :show-file-list="false" :headers="headers" :on-success="changeAvatar">
<el-button type="text" size="small">点击更换头像</el-button>
</el-upload>
</div>
<div class="relative" v-loading="loading">
<div class="page">
<el-page-header class="m-b-15" @back="$router.back()" content="个人资料"></el-page-header>
<ul class="menu">
<li v-for="item in typeList" :key="item.index" :class="{active: item.index == active}">
{{ item.title }}
</li>
</ul>
<div class="overflow">
<el-form class="form" ref="form" label-width="120px" label-suffix="">
<el-form-item prop="userName" label="头像" style="height: 36px;">
<div class="avatar-wrap">
<img :src="avatar" class="avatar m-r-10" />
<el-upload :action="api.updateUserAvatars" name="file" :data="{ userId }" :limit="10"
:show-file-list="false" :headers="headers" :on-success="changeAvatar">
<el-button type="text">点击更换头像</el-button>
</el-upload>
</div>
</el-form-item>
<el-form-item prop="userName" label="姓名">
<el-input v-model.trim="form.userName" placeholder="请输入姓名"></el-input>
</el-form-item>
<el-form-item prop="phone" label="手机号">
<el-input class="m-r-10" style="width: 243px;" v-model.trim="form.phone" placeholder="请输入手机号" maxlength="11"
disabled></el-input>
<el-button type="text" size="small" @click="bindPhone">更换</el-button>
</el-form-item>
<el-form-item prop="password" label="登录密码">
<el-input class="m-r-10" style="width: 243px;" type="password" value="xxxxxx" placeholder="请输入密码"
disabled></el-input>
<el-button type="text" size="small" @click="bindPassword">更换</el-button>
</el-form-item>
<el-form-item prop="email" label="电子邮箱">
<el-input v-model.trim="form.email" placeholder="请输入电子邮箱"></el-input>
</el-form-item>
<el-form-item prop="sex" label="性别">
<el-radio v-model="form.sex" :label="1"></el-radio>
<el-radio v-model="form.sex" :label="2"></el-radio>
</el-form-item>
<el-form-item prop="education" label="学历">
<el-select v-model="form.education" clearable placeholder="请选择学历">
<el-option v-for="(item, i) in educations" :key="i" :value="item.name"></el-option>
</el-select>
</el-form-item>
<el-form-item prop="academicDegree" label="学位">
<el-input v-model.trim="form.academicDegree" placeholder="请输入学位"></el-input>
</el-form-item>
<el-form-item prop="title" label="职称">
<el-input v-model.trim="form.title" placeholder="请输入职称"></el-input>
</el-form-item>
<el-form-item prop="post" label="职务">
<el-input v-model.trim="form.post" placeholder="请输入职务"></el-input>
</el-form-item>
<el-form-item prop="universityFrom" label="毕业院校">
<el-input v-model.trim="form.universityFrom" placeholder="请输入毕业院校"></el-input>
</el-form-item>
<el-form-item prop="academicSpecialties" label="学术专长">
<el-input v-model.trim="form.academicSpecialties" placeholder="请输入学术专长"></el-input>
</el-form-item>
<el-form-item prop="currentUnit" label="现所在单位">
<el-input v-model.trim="form.currentUnit" placeholder="请输入现所在单位"></el-input>
</el-form-item>
</el-form>
</div>
<div class="btns">
<el-button size="small" @click="$emit('back')">取消</el-button>
<el-button type="primary" size="small" @click="submit">更新</el-button>
</div>
</div>
<info class="flex-1" ref="info" @updateStatus="updateStatus" @back="back"></info>
<el-dialog :title="form.email ? '更换邮箱' : '绑定邮箱'" :visible.sync="emailVisible" :close-on-click-modal="false"
@close="closeEmail" width="30%">
<el-form ref="form" :model="form" label-width="60px">
<el-form-item label="邮箱">
<el-input placeholder="请输入邮箱" v-model="email"></el-input>
</el-form-item>
<el-form-item label="验证码">
<div class="flex-between">
<el-input v-model="emailCode" placeholder="请输入验证码" maxlength="6"></el-input>
<el-button style="margin-left: 10px" type="text" @click="sendEmailCode" :disabled="emailDisabled">{{
emailBtnText }}</el-button>
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="emailVisible = false"> </el-button>
<el-button type="primary" @click="emailSubmit"> </el-button>
</span>
</el-dialog>
<el-dialog :title="form.phone ? '更换手机号' : '绑定手机号'" :visible.sync="phoneVisible" :close-on-click-modal="false"
@close="closePhone" width="30%">
<el-form ref="form" :model="form" label-width="60px">
<el-form-item label="手机号">
<el-input style="width: 404px;" placeholder="请输入手机号" v-model="phone" maxlength="11"></el-input>
</el-form-item>
<el-form-item label="验证码">
<div class="flex-between">
<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>
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="phoneVisible = false"> </el-button>
<el-button type="primary" @click="phoneSubmit"> </el-button>
</span>
</el-dialog>
<el-dialog title="更换密码" :visible.sync="pwdVisible" :close-on-click-modal="false" @close="closePassword" width="30%">
<el-form ref="pwdForm" :model="form" label-width="60px">
<el-form-item label="原密码">
<el-input type="password" v-model="pwdForm.password" placeholder="请输入原密码"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="pwdForm.newPassword" placeholder="请输入新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="pwdForm.reNewPassword" placeholder="请确认新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="pwdVisible = false"> </el-button>
<el-button type="primary" @click="editPassword"> </el-button>
</span>
</el-dialog>
<el-dialog title="修改账号" :visible.sync="accountVisible" :close-on-click-modal="false" width="30%">
<el-form label-width="70px">
<el-form-item label="账号">
<el-input v-model="editUsername" placeholder="请输入账号"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="accountVisible = false"> </el-button>
<el-button size="small" type="primary" @click="confirmAccount"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import Setting from '@/setting'
import util from '@/libs/util'
import info from './info'
import Util from '@/libs/util'
import { mapState, mapMutations } from 'vuex'
export default {
data() {
return {
headers: {
token: util.local.get(Setting.tokenKey)
data () {
return {
loading: false,
accountId: localStorage.getItem('reviewAID'),
headers: {
token: localStorage.getItem('expert_token')
},
editUsername: '',
accountVisible: false,
updateTime: 0,
form: {
accountId: '',
userName: '',
phone: '',
uniqueIdentification: '',
academicDegree: '',
email: '',
academicSpecialties: '',
currentUnit: '',
education: '',
nickname: '',
title: '',
post: '',
universityFrom: '',
sex: 1,
},
emailVisible: false,
pwdVisible: false,
phoneVisible: false,
showArch: false,
pwdForm: {
password: "",
newPassword: "",
reNewPassword: ""
},
educations: [
{
id: 1,
name: '初中及以下'
},
typeList: [
{
index: '1',
title: '用户信息'
}
],
active: '1',
edited: false
};
{
id: 2,
name: '高中'
},
{
id: 3,
name: '中专/中技'
},
{
id: 4,
name: '大专'
},
{
id: 5,
name: '本科'
},
{
id: 6,
name: '硕士'
},
{
id: 7,
name: '博士'
},
],
sexList: [
{
name: "男",
value: 1
},
{
name: "女",
value: 2
}
],
email: "",
emailBtnText: "发送验证码",
emailCode: "",
emailDisabled: false,
emailTimer: null,
phone: "",
phoneBtnText: "发送验证码",
phoneCode: "",
phoneDisabled: false,
phoneTimer: null,
emailOpener: "",
phoneOpener: "",
originAccount: "",
accountReapeat: false
};
},
computed: {
...mapState("user", [
"userId", "avatar"
])
},
watch: {
// ,
form: {
handler () {
this.updateTime++
if (this.updateTime > 1) this.$emit('updateStatus', this.updateTime > 1)
},
deep: true
}
},
mounted () {
console.log(44, this.userId)
this.getData()
},
methods: {
...mapMutations('user', [
'setUserName', 'setAvatar'
]),
//
async getData () {
if (this.accountId) {
this.loading = true
const { data } = await this.$get(`${this.api.expertDetail}?accountId=${this.accountId}`)
this.form = data
this.loading = false
}
},
components: { info },
computed: {
...mapState('user', [
'avatar', 'userId'
]),
},
// ,
beforeRouteLeave(to, from, next) {
if(this.edited){
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', {
type: 'warning'
}).then(() => {
this.$refs.info.submit()
next()
}).catch(() => {
next()
})
}else{
next()
changeAvatar (res) {
this.setAvatar(res.message)
},
//
showAccount () {
this.accountVisible = true
},
//
confirmAccount () {
if (this.editUsername) {
form.username = this.editUsername
this.accountVisible = false
const { form } = this
this.$put(this.api.user, form).then(res => {
this.setUserName(form.username)
this.$message.success("提交成功!")
}).catch(res => { })
} else {
Util.errorMsg('请输入账号')
}
},
mounted() {
bindEmail () {
this.email = this.form.email
this.emailVisible = true
},
bindPhone () {
this.phoneVisible = true
},
bindPassword () {
this.pwdVisible = true
},
editPassword () {
const form = this.pwdForm
if (!form.password) return Util.warningMsg('请输入原密码')
if (!form.newPassword) return Util.warningMsg('请输入新密码')
if (!form.reNewPassword) return Util.warningMsg('请确认新密码')
if (form.newPassword.length < 6 || form.reNewPassword.length < 6) return Util.warningMsg('请输入6位数以上的密码')
if (form.newPassword !== form.reNewPassword) return Util.warningMsg('输入的新密码不一致,请重新确认')
if (form.password === form.newPassword) return Util.warningMsg('原密码跟新密码不能一致')
form.accountId = this.form.accountId
this.$post(this.api.examinePassword, form).then(res => {
Util.successMsg('更换成功')
this.pwdVisible = false
}).catch(err => { })
},
methods: {
...mapMutations('user', [
'setAvatar'
]),
changeAvatar(res) {
this.setAvatar(res.data)
},
updateStatus(status){
this.edited = status
},
//
back() {
if(this.edited){
this.edited = false
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', {
type: 'warning'
}).then(() => {
this.$refs.info.submit()
this.$router.back()
}).catch(() => {
this.$router.back()
})
}else{
this.$router.back()
closePassword () {
this.pwdForm = {
password: "",
newPassword: "",
reNewPassword: ""
}
},
submit () {
const { form } = this
this.$post(this.api.modifyExpert, form).then(res => {
this.setUserName(form.userName)
Util.successMsg('更新成功!')
}).catch(res => { })
},
emailCountdown () {
let count = 60;
if (!this.emailTimer) {
this.emailDisabled = true;
this.emailTimer = setInterval(() => {
console.log("倒计时中");
if (count > 0) {
count--;
this.emailBtnText = `${count}秒后重试`;
} else {
this.emailDisabled = false;
clearInterval(this.emailTimer);
this.emailTimer = null;
this.emailBtnText = `发送验证码`;
}
}, 1000);
}
},
phoneCountdown () {
let count = 60;
if (!this.phoneTimer) {
this.phoneDisabled = true;
this.phoneTimer = setInterval(() => {
console.log("倒计时中");
if (count > 0) {
count--;
this.phoneBtnText = `${count}秒后重试`;
} else {
this.phoneDisabled = false;
clearInterval(this.phoneTimer);
this.phoneTimer = null;
this.phoneBtnText = `发送验证码`;
}
}, 1000);
}
},
closeEmail () {
if (!this.emailDisabled) {
this.emailCode = "";
}
},
sendEmailCode () {
if (!this.email) return Util.warningMsg("请输入邮箱")
if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return Util.warningMsg("请输入正确的邮箱")
this.$post(this.api.sendPhoneOrEmailCode, {
email: this.email,
types: 1
}).then(res => {
if (res.message.opener) {
this.emailCountdown();
this.emailOpener = res.message.opener;
} else {
Util.errorMsg(res.message);
}
}).catch(res => { })
},
emailSubmit () {
if (!this.email) return Util.warningMsg("请输入邮箱")
if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return Util.warningMsg("请输入正确的邮箱")
if (!this.emailCode) return Util.warningMsg("请输入验证码")
this.$put(this.api.bindPhoneOrEmail, {
userId: this.userId,
email: this.email,
types: 1,
code: this.emailCode,
opener: this.emailOpener
}).then(res => {
Util.successMsg("绑定成功")
this.form.email = this.email
this.emailVisible = false
}).catch(res => { })
},
closePhone () {
if (!this.emailDisabled) {
this.emailCode = "";
}
},
sendPhoneCode () {
if (!this.phone) return Util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return Util.warningMsg("请输入正确的手机号");
let data = {
userId: this.userId,
phone: this.phone,
types: 2
};
this.$post(this.api.sendPhoneOrEmailCode, data).then(res => {
if (res.message.opener) {
this.phoneCountdown();
this.phoneOpener = res.message.opener;
} else {
Util.errorMsg(res.message);
}
}).catch(res => {
});
},
phoneSubmit () {
if (!this.phone) return Util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return Util.warningMsg("请输入正确的手机号");
if (!this.phoneCode) return Util.warningMsg("请输入验证码");
let data = {
userId: this.userId,
phone: this.phone,
types: 2,
code: this.phoneCode,
opener: this.phoneOpener
};
this.$post(this.api.bindPhoneOrEmail, data).then(res => {
Util.successMsg("绑定成功");
this.form.phone = this.phone;
this.phoneVisible = false;
}).catch(res => {
});
}
}
};
</script>
<style lang="scss" scoped>
.main{
display: flex;
margin: 0 auto;
.left{
margin-right: 12px;
background-color: #fff;
box-shadow: 2px 0px 6px 0px #EEEEEE;
.inner{
width: 170px;
padding: 20px 0;
}
.avatar{
width: 80px;
height: 80px;
border-radius: 50%;
}
.menu{
margin-top: 32px;
li{
padding: 0 20px;
color: #303133;
font-size: 14px;
line-height: 38px;
cursor: pointer;
&.active{
color: #fff;
background-color: $main-color;
}
}
}
.overflow {
height: calc(100vh - 254px);
margin-bottom: 40px;
overflow: auto;
.form {
width: 400px;
}
.avatar-wrap {
display: inline-flex;
align-items: center;
}
.avatar {
width: 36px;
height: 36px;
border-radius: 50%;
}
}
.btn-wrap {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 12px 0;
text-align: center;
background-color: #fff;
.el-button {
width: 80px;
}
}
</style>

@ -1,475 +0,0 @@
<template>
<div class="relative" v-loading="loading">
<div class="page">
<h6 class="l-title"><img src="@/assets/images/info1.png" alt=""> 基本信息</h6>
<div class="page-content">
<ul class="list">
<li>
<label>姓名</label>
<el-input placeholder="请输入姓名" type="text" v-model="form.realName" />
</li>
<li>
<label>性别</label>
<el-select size="small" v-model="form.sex">
<el-option v-for="item in sexList" :key="item.value" :label="item.name" :value="item.value"></el-option>
</el-select>
</li>
<li>
<label>账号</label>
<el-input class="m-r-10" type="text" size="small" v-model="form.username"></el-input>
<!-- <el-button type="text" size="small" @click="showAccount">修改</el-button> -->
</li>
<li>
<label>工号</label>
<el-input size="small" v-model="form.jobNumber" clearable></el-input>
</li>
<li>
<label>邮箱</label>
<el-input class="m-r-10" size="small" v-model="form.email"></el-input>
<!-- <el-button v-if="form.email" type="text" size="small" @click="bindEmail">更换</el-button>
<el-button v-else type="text" size="small" @click="bindEmail">添加</el-button> -->
</li>
<li>
<label>手机号</label>
<el-input class="m-r-10" type="text" size="small" maxlength="11" v-model="form.phone"></el-input>
<!-- <el-button type="text" size="small" @click="bindPhone">{{ form.phone ? '更换' : '绑定' }}</el-button>
<el-button v-if="form.phone" type="text" size="small" @click="unbind">解绑</el-button> -->
</li>
<li>
<label>密码</label>
<el-input class="m-r-10" size="small" value="******" disabled></el-input>
<el-button type="text" size="small" @click="bindPassword">修改</el-button>
</li>
</ul>
</div>
<div class="btn-wrap">
<el-button size="small" v-throttle @click="$emit('back')">取消</el-button>
<el-button type="primary" size="small" v-throttle @click="submit">更新</el-button>
</div>
</div>
<el-dialog :title="form.email ? '更换邮箱' : '绑定邮箱'" :visible.sync="emailVisible" :close-on-click-modal="false"
@close="closeEmail" width="30%">
<el-form ref="form" :model="form" label-width="60px">
<el-form-item label="邮箱">
<el-input placeholder="请输入邮箱" v-model="email"></el-input>
</el-form-item>
<el-form-item label="验证码">
<div class="flex-between">
<el-input v-model="emailCode" placeholder="请输入验证码" maxlength="6"></el-input>
<el-button style="margin-left: 10px" type="text" @click="sendEmailCode" :disabled="emailDisabled">{{
emailBtnText }}</el-button>
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="emailVisible = false"> </el-button>
<el-button type="primary" @click="emailSubmit"> </el-button>
</span>
</el-dialog>
<el-dialog :title="form.phone ? '更换手机号' : '绑定手机号'" :visible.sync="phoneVisible" :close-on-click-modal="false"
@close="closePhone" width="30%">
<el-form ref="form" :model="form" label-width="60px">
<el-form-item label="手机号">
<el-input style="width: 404px;" placeholder="请输入手机号" v-model="phone" maxlength="11"></el-input>
</el-form-item>
<el-form-item label="验证码">
<div class="flex-between">
<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>
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="phoneVisible = false"> </el-button>
<el-button type="primary" @click="phoneSubmit"> </el-button>
</span>
</el-dialog>
<el-dialog title="更换密码" :visible.sync="pwdVisible" :close-on-click-modal="false" @close="closePassword" width="30%">
<el-form ref="pwdForm" :model="form" label-width="60px">
<el-form-item label="原密码">
<el-input type="password" v-model="pwdForm.password" placeholder="请输入原密码"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="pwdForm.newPassword" placeholder="请输入新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="pwdForm.reNewPassword" placeholder="请确认新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="pwdVisible = false"> </el-button>
<el-button type="primary" @click="editPassword"> </el-button>
</span>
</el-dialog>
<el-dialog title="修改账号" :visible.sync="accountVisible" :close-on-click-modal="false" width="30%">
<el-form label-width="70px">
<el-form-item label="账号">
<el-input v-model="editUsername" placeholder="请输入账号"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="accountVisible = false"> </el-button>
<el-button size="small" type="primary" @click="confirmAccount"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import Setting from '@/setting'
import util from '@/libs/util'
import { mapState, mapMutations } from 'vuex'
export default {
data () {
return {
loading: false,
editUsername: '',
accountVisible: false,
updateTime: 0,
token: util.local.get(Setting.tokenKey),
form: {
userName: "",
name: "",
jobNumber: "",
password: "",
phone: "",
email: "",
sex: 1,
},
emailVisible: false,
pwdVisible: false,
phoneVisible: false,
showArch: false,
pwdForm: {
password: "",
newPassword: "",
reNewPassword: ""
},
sexList: [
{
name: "男",
value: 1
},
{
name: "女",
value: 2
}
],
email: "",
emailBtnText: "发送验证码",
emailCode: "",
emailDisabled: false,
emailTimer: null,
phone: "",
phoneBtnText: "发送验证码",
phoneCode: "",
phoneDisabled: false,
phoneTimer: null,
emailOpener: "",
phoneOpener: "",
originAccount: "",
accountReapeat: false
};
},
computed: {
...mapState("user", [
"userId", "avatar"
])
},
watch: {
// ,
form: {
handler () {
this.updateTime++
if (this.updateTime > 1) this.$emit('updateStatus', this.updateTime > 1)
},
deep: true
}
},
mounted () {
// this.getData()
},
methods: {
...mapMutations('user', [
'setUserName'
]),
//
getData () {
this.loading = true
this.$get(this.api.queryUserInfoDetails).then(({ data }) => {
this.form = data
this.loading = false
}).catch(err => { })
},
//
showAccount () {
this.accountVisible = true
},
//
confirmAccount () {
if (this.editUsername) {
form.username = this.editUsername
this.accountVisible = false
const { form } = this
this.$put(this.api.user, form).then(res => {
this.setUserName(form.username)
this.$message.success("提交成功!")
}).catch(res => { })
} else {
util.errorMsg('请输入账号')
}
},
bindEmail () {
this.email = this.form.email
this.emailVisible = true
},
bindPhone () {
this.phone = this.form.phone
this.phoneVisible = true
},
//
unbind () {
this.$confirm('确定要解绑该手机号吗?', '提示', {
type: 'warning'
}).then(() => {
this.$get(this.api.unbindMobilePhone).then(res => {
this.$message.success('解绑成功')
this.getData()
}).catch(res => { })
}).catch(() => { })
},
bindPassword () {
this.pwdVisible = true
},
editPassword () {
const data = this.pwdForm
if (!data.password) return util.warningMsg("请输入原密码")
if (!data.newPassword) return util.warningMsg("请输入新密码")
if (!data.reNewPassword) return util.warningMsg("请确认新密码")
if (data.newPassword.length < 6 || data.reNewPassword.length < 6) return util.warningMsg("请输入6位数以上的密码")
if (data.newPassword !== data.reNewPassword) return util.warningMsg("输入的新密码不一致,请重新确认")
if (data.password === data.newPassword) return util.warningMsg("原密码跟新密码不能一致")
this.$put(this.api.pwd, {
id: this.form.id,
oldPwd: data.password,
newPwd: data.newPassword
}).then(res => {
util.successMsg("更换成功")
this.pwdVisible = false
}).catch(err => { })
},
closePassword () {
this.pwdForm = {
password: "",
newPassword: "",
reNewPassword: ""
}
},
submit () {
const { form } = this
this.$put(this.api.user, {
id: form.id,
jobNumber: form.jobNumber,
phone: form.phone,
realName: form.realName,
username: form.username,
email: form.email,
sex: form.sex,
}).then(res => {
this.$emit('updateStatus', false)
this.setUserName(form.realName)
this.$message.success("提交成功!")
}).catch(res => { })
},
emailCountdown () {
let count = 60;
if (!this.emailTimer) {
this.emailDisabled = true;
this.emailTimer = setInterval(() => {
console.log("倒计时中");
if (count > 0) {
count--;
this.emailBtnText = `${count}秒后重试`;
} else {
this.emailDisabled = false;
clearInterval(this.emailTimer);
this.emailTimer = null;
this.emailBtnText = `发送验证码`;
}
}, 1000);
}
},
phoneCountdown () {
let count = 60;
if (!this.phoneTimer) {
this.phoneDisabled = true;
this.phoneTimer = setInterval(() => {
console.log("倒计时中");
if (count > 0) {
count--;
this.phoneBtnText = `${count}秒后重试`;
} else {
this.phoneDisabled = false;
clearInterval(this.phoneTimer);
this.phoneTimer = null;
this.phoneBtnText = `发送验证码`;
}
}, 1000);
}
},
closeEmail () {
if (!this.emailDisabled) {
this.emailCode = "";
}
},
sendEmailCode () {
if (!this.email) return util.warningMsg("请输入邮箱")
if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return util.warningMsg("请输入正确的邮箱")
this.$post(this.api.sendPhoneOrEmailCode, {
email: this.email,
types: 1
}).then(res => {
if (res.message.opener) {
this.emailCountdown();
this.emailOpener = res.message.opener;
} else {
util.errorMsg(res.message);
}
}).catch(res => { })
},
emailSubmit () {
if (!this.email) return util.warningMsg("请输入邮箱")
if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return util.warningMsg("请输入正确的邮箱")
if (!this.emailCode) return util.warningMsg("请输入验证码")
this.$put(this.api.bindPhoneOrEmail, {
userId: this.userId,
email: this.email,
types: 1,
code: this.emailCode,
opener: this.emailOpener
}).then(res => {
util.successMsg("绑定成功")
this.form.email = this.email
this.emailVisible = false
}).catch(res => { })
},
closePhone () {
if (!this.emailDisabled) {
this.emailCode = "";
}
},
sendPhoneCode () {
if (!this.phone) return util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg("请输入正确的手机号");
let data = {
userId: this.userId,
phone: this.phone,
types: 2
};
this.$post(this.api.sendPhoneOrEmailCode, data).then(res => {
if (res.message.opener) {
this.phoneCountdown();
this.phoneOpener = res.message.opener;
} else {
util.errorMsg(res.message);
}
}).catch(res => {
});
},
phoneSubmit () {
if (!this.phone) return util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg("请输入正确的手机号");
if (!this.phoneCode) return util.warningMsg("请输入验证码");
let data = {
userId: this.userId,
phone: this.phone,
types: 2,
code: this.phoneCode,
opener: this.phoneOpener
};
this.$post(this.api.bindPhoneOrEmail, data).then(res => {
util.successMsg("绑定成功");
this.form.phone = this.phone;
this.phoneVisible = false;
}).catch(res => {
});
}
}
};
</script>
<style lang="scss" scoped>
.page {
min-height: 100%;
}
.l-title {
display: flex;
align-items: center;
margin-bottom: 12px;
font-size: 14px;
color: #333;
img {
margin-right: 5px;
}
}
.list {
.line {
display: flex;
margin-bottom: 24px;
}
.el-input,
.el-select {
width: 220px;
.el-input__inner {
border-color: #CACFDB;
}
}
li {
display: flex;
align-items: center;
margin-bottom: 20px;
&>label {
width: 100px;
margin-right: 5px;
text-align: right;
font-size: 14px;
color: #4c4c4c;
white-space: nowrap;
}
.el-select .el-input.is-disabled .el-input__inner {
border-color: #ddd;
}
.val {
margin-right: 15px;
color: #606266;
font-size: 14px;
}
}
}
.btn-wrap {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 12px 0;
text-align: center;
background-color: #fff;
.el-button {
width: 80px;
}
}
</style>

@ -4,6 +4,7 @@ import router from "@/router/index";
import Setting from "@/setting";
import store from '@/store'
const { inIframe } = Setting
const service = axios.create({
baseURL: Setting.apiBaseURL,
timeout: 10000000
@ -13,7 +14,7 @@ service.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8"
// 请求拦截器
service.interceptors.request.use(config => {
let token = localStorage.getItem('review_token')
let token = localStorage.getItem(inIframe ? 'review_token' : 'expert_token')
if (token) config.headers.token = token
return config
}, err => {
@ -37,14 +38,14 @@ service.interceptors.response.use(
// 账号互踢
if (!logouted) {
Util.local.remove(Setting.storeKey)
localStorage.removeItem('review_token')
localStorage.removeItem(inIframe ? 'review_token' : 'expert_token')
window.top.exitSystem && window.top.exitSystem()
Util.errorMsg(res.msg.includes('顶') ? '您的账号已在其他设备登录,您已被迫下线!' : '登录过期,请重新登录!')
localStorage.removeItem('reviewPath')
setTimeout(() => {
// store.dispatch('user/logout')
inIframe || store.dispatch('user/logout')
logouted = 0
}, 5000)
}, 1500)
logouted = 1
}
} else if (!res.status) {
@ -59,20 +60,6 @@ service.interceptors.response.use(
error => {
if (error.response.status) {
switch (error.response.status) {
// 401: 未登录
// 未登录则跳转登录页面,并携带当前页面的路径
// 在登录成功后返回当前页面,这一步需要在登录页操作。
case 401:
if (!logouted) {
Util.local.remove(Setting.storeKey);
Util.local.remove(Setting.tokenKey);
Util.errorMsg("登录过期,请重新登录");
setTimeout(() => {
store.dispatch('user/logout')
}, 1000);
logouted = 1
}
break;
case 500:
Util.errorMsg("网络错误");
break;

@ -3,6 +3,11 @@ import Setting from '@/setting'
router.beforeEach((to, from, next) => {
document.title = Setting.titleSuffix
next()
to.path !== '/theoryReview' && localStorage.setItem('reviewPath', to.fullPath)
if (!Setting.inIframe && !localStorage.getItem('expert_token') && to.path !== '/login') {
next('/login')
} else {
next()
to.path !== '/theoryReview' && localStorage.setItem('reviewPath', to.fullPath)
}
})

@ -25,6 +25,7 @@ const Setting = {
tokenExpires: 1296000000, // token在localStorage的时间(毫秒)
isDev,
isPro,
inIframe: window !== window.top, // 当前平台是否处于嵌入到iframe里
/**
* 路由白名单
* */

@ -1,5 +1,7 @@
import Setting from '@/setting'
import util from '@/libs/util'
import Util from '@/libs/util'
import { post } from '@/plugins/requests/index.js'
import api from '@/api'
/**
* 用户信息
@ -19,9 +21,11 @@ export default {
state.avatar = avatar
},
setUserId: (state, userId) => {
console.log("🚀 ~ userId:", userId)
state.userId = userId
},
setUserName: (state, userName) => {
console.log("🚀 ~ userName:", userName)
state.userName = userName
},
setCrumbs: (state, crumbs) => {
@ -34,10 +38,15 @@ export default {
actions: {
logout ({ commit, state, dispatch }) {
return new Promise((resolve, reject) => {
util.local.remove(Setting.storeKey)
util.local.remove(Setting.tokenKey)
location.reload()
resolve()
post(api.logout).then(() => {
Util.local.remove(Setting.storeKey)
localStorage.removeItem('expert_token')
localStorage.removeItem('review_token')
location.reload()
resolve()
}).catch(error => {
reject(error)
})
})
}
}

Loading…
Cancel
Save