|
|
@@ -2,11 +2,11 @@
|
|
|
<div class="tab">
|
|
|
<h1 class="title">个人信息设置 <span class="tag">教师</span></h1>
|
|
|
<div class="sub-title">修改姓名</div>
|
|
|
- <c-input placeholder="姓名" class="mb-16" v-model="newName"></c-input>
|
|
|
+ <c-input :placeholder="'目前资料中的姓名:' + userInfo.name" class="mb-16" v-model="newName"></c-input>
|
|
|
<c-button class="warning full-width mb-32" @click="handleModifyName">确认修改姓名</c-button>
|
|
|
<div class="sub-title">修改密码</div>
|
|
|
<div class="verified-code-wrapper">
|
|
|
- <c-input placeholder="邮箱验证码" type="number"></c-input>
|
|
|
+ <c-input placeholder="邮箱验证码" type="number" v-model="code"></c-input>
|
|
|
<c-button class="secondary" :disabled="typeof this.emailButtonContent === typeof 0"
|
|
|
@click="handleSendEmailCode">{{ emailButtonContent }}
|
|
|
</c-button>
|
|
|
@@ -23,26 +23,39 @@ import CButton from '@/components/CButton'
|
|
|
import CInput from '@/components/CInput'
|
|
|
import { sendEmailCode } from '@/server/code'
|
|
|
import { logout, modifyUser, resetPasswordByEmail } from '@/server/user'
|
|
|
+import { mapState } from 'vuex'
|
|
|
|
|
|
export default {
|
|
|
components: { CInput, CButton },
|
|
|
data () {
|
|
|
return {
|
|
|
- email: '',
|
|
|
emailButtonContent: '发送验证码',
|
|
|
newName: '',
|
|
|
+ code: '',
|
|
|
password: '',
|
|
|
passwordEnsure: ''
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapState({
|
|
|
+ userInfo: state => state.main.userInfo
|
|
|
+ }),
|
|
|
+ email () {
|
|
|
+ return this.userInfo.email
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
handleSendEmailCode () {
|
|
|
- this.$showMessage({ message: '正在尝试发送验证码', type: 'info' })
|
|
|
+ this.$setInfoMessage('正在尝试发送验证码')
|
|
|
if (this.email.match(/.+@(nju.edu.cn|smail.nju.edu.cn)/)) {
|
|
|
this.setEmailCodeCd()
|
|
|
- sendEmailCode({ email: this.email })
|
|
|
+ sendEmailCode({ email: this.email }).then(res => {
|
|
|
+ this.$setSuccessMessage('邮箱验证码发送成功')
|
|
|
+ }).catch(err => {
|
|
|
+ this.$setErrorMessage(err.response.data.msg)
|
|
|
+ })
|
|
|
} else {
|
|
|
- this.$showMessage({ message: '本邮箱不符合南京大学校邮格式', type: 'error' })
|
|
|
+ this.$setErrorMessage('本邮箱不符合南京大学校邮格式')
|
|
|
}
|
|
|
},
|
|
|
setEmailCodeCd () {
|
|
|
@@ -58,6 +71,7 @@ export default {
|
|
|
},
|
|
|
handleLogout () {
|
|
|
logout()
|
|
|
+ this.$setSuccessMessage('您已退出登录')
|
|
|
this.$router.push({ name: 'login' })
|
|
|
},
|
|
|
handleModifyPassword () {
|
|
|
@@ -67,7 +81,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
resetPasswordByEmail({ email: this.email, code: this.code, password: this.password }).then(res => {
|
|
|
- this.$setInfoMessage('密码修改成功')
|
|
|
+ this.$setSuccessMessage('密码修改成功')
|
|
|
}).catch(err => {
|
|
|
this.$setErrorMessage(err.response.data.msg)
|
|
|
})
|