调整路径

This commit is contained in:
joylink_zyy 2020-05-10 21:45:11 +08:00
parent 5e142ae5b3
commit bcfba416d3

View File

@ -1,147 +1,280 @@
<template>
<el-dialog v-dialogDrag :title="$t('global.personalDetails')" :visible.sync="visible" width="470px" :before-close="doClose" class="userInfo_box">
<div>
<div class="form_box">
<div class="title">{{ $t('global.compellation') }}:</div>
<div class="content">
<div v-show="nameShow" class="show_box">
<span>{{ userInfo.name }}</span>
<i class="el-icon-edit" @click="switcherName" />
</div>
<div v-show="!nameShow" class="flex_box">
<el-input v-model="editInfo.name" :placeholder="$t('global.enterName')" maxlength="20" size="mini" class="input_box" />
<div class="button_box">
<el-button size="mini" class="button_box" :disabled="!editInfo.name" @click="saveName">{{ $t('global.save') }}</el-button>
<el-button size="mini" class="button_box" type="text" @click="switcherName">{{ $t('global.cancel') }}</el-button>
<el-dialog
v-dialogDrag
:title="$t('global.personalDetails')"
:visible.sync="visible"
width="470px"
:before-close="doClose"
class="userInfo_box"
>
<div>
<div class="form_box">
<div class="title">{{ $t('global.compellation') }}:</div>
<div class="content">
<div v-show="nameShow" class="show_box">
<span>{{ userInfo.name }}</span>
<i class="el-icon-edit" @click="switcherName" />
</div>
<div v-show="!nameShow" class="flex_box">
<el-input
v-model="editInfo.name"
:placeholder="$t('global.enterName')"
maxlength="20"
size="mini"
class="input_box"
/>
<div class="button_box">
<el-button
size="mini"
class="button_box"
:disabled="!editInfo.name"
@click="saveName"
>{{ $t('global.save') }}</el-button>
<el-button
size="mini"
class="button_box"
type="text"
@click="switcherName"
>{{ $t('global.cancel') }}</el-button>
</div>
</div>
</div>
</div>
<div class="form_box">
<div class="title">{{ $t('global.nickName') }}:</div>
<div class="content">
<div v-show="nickNameShow" class="show_box">
<span>{{ userInfo.nickname }}</span>
<i class="el-icon-edit" @click="switcherNickname" />
</div>
<div v-show="!nickNameShow" class="flex_box">
<el-input
v-model="editInfo.nickname"
:placeholder="$t('global.enterNickname')"
maxlength="20"
size="mini"
class="input_box"
/>
<div class="button_box">
<el-button
size="mini"
class="button_box"
:disabled="!editInfo.nickname"
@click="saveNickName"
>{{ $t('global.save') }}</el-button>
<el-button
size="mini"
class="button_box"
type="text"
@click="switcherNickname"
>{{ $t('global.cancel') }}</el-button>
</div>
</div>
</div>
</div>
<div class="form_box">
<div class="title">{{ $t('global.mobile') }}:</div>
<div class="content">
<div v-show="mobileShow" class="show_box">
<span>{{ geTel(userInfo.mobile) }}</span>
<i class="el-icon-edit" @click="switcherMobile" />
</div>
<div v-show="!mobileShow" class="flex_box">
<el-input
v-model="editInfo.mobile"
:placeholder="$t('global.enterMobile')"
maxlength="11"
size="mini"
class="input_box"
/>
<el-select v-model="nationCode" size="mini" class="selectCountry">
<el-option
v-for="item in countryList"
:key="item.value"
:label="item.name"
:value="item.value"
/>
</el-select>
<el-input
v-model="mobileCode"
:placeholder="$t('global.verificationCode')"
size="mini"
class="code_box"
style="margin-top: 10px;"
/>
<el-button
size="mini"
style="margin-top: 10px; margin-right: 10px;"
:disabled="mobileCodeTime != 0"
@click="sendMobileCode"
>
{{ $t('global.sendCode') }}
<span
v-if="mobileCodeTime"
>{{ mobileCodeTime }}</span>
</el-button>
<div class="button_box" style="margin-top: 10px;">
<el-button
size="mini"
class="button_box"
:disabled="!mobileCode"
@click="saveMobile"
>{{ $t('global.save') }}</el-button>
<el-button
size="mini"
class="button_box"
type="text"
@click="switcherMobile"
>{{ $t('global.cancel') }}</el-button>
</div>
</div>
</div>
</div>
<div class="form_box">
<div class="title">{{ $t('global.email') }}:</div>
<div class="content">
<div v-show="emailShow" class="show_box">
<span>{{ userInfo.email }}</span>
<i class="el-icon-edit" @click="switcherEmail" />
</div>
<div v-show="!emailShow" class="flex_box">
<el-input
v-model="editInfo.email"
:placeholder="$t('global.enterEmail')"
size="mini"
class="input_box"
/>
<el-input
v-model="emailCode"
:placeholder="$t('global.verificationCode')"
size="mini"
class="code_box"
style="margin-top: 10px;"
/>
<el-button
size="mini"
style="margin-top: 10px; margin-right: 10px;"
:disabled="emailCodeTime != 0"
@click="sendEmailCode"
>
{{ $t('global.sendCode') }}
<span
v-if="emailCodeTime"
>{{ emailCodeTime }}</span>
</el-button>
<div class="button_box" style="margin-top: 10px;">
<el-button
size="mini"
class="button_box"
:disabled="!emailCode"
@click="saveEmail"
>{{ $t('global.save') }}</el-button>
<el-button
size="mini"
class="button_box"
type="text"
@click="switcherEmail"
>{{ $t('global.cancel') }}</el-button>
</div>
</div>
</div>
</div>
<div class="form_box">
<div class="title">{{ $t('global.passWord') }}:</div>
<div class="content">
<div v-show="passwordShow" class="show_box">
<span>******</span>
<i class="el-icon-edit" @click="switcherPassWord" />
</div>
<div v-show="!passwordShow" class="flex_box">
<div class="passWord_box">
<span>{{ $t('global.newPassWord') }}:</span>
<el-input
v-model="newPassWord1"
:placeholder="$t('global.enterPassWord')"
maxlength="20"
show-password
size="mini"
class="input_box"
/>
</div>
<div style="height: 28px; line-height: 28px; margin-bottom: 10px;">
<el-input
v-model="passWordCode"
:placeholder="$t('global.verificationCode')"
size="mini"
class="code_box"
/>
<el-button
size="mini"
style="margin-right: 10px;"
:disabled="passWordCodeTime != 0"
@click="sendPassWordCode"
>
{{ $t('global.sendMobileCode') }}
<span
v-if="passWordCodeTime"
>{{ passWordCodeTime }}</span>
</el-button>
</div>
<div class="button_box" style="width: 150px;">
<el-button
size="mini"
class="button_box"
:disabled="!passWordCode"
@click="savePassWord"
>{{ $t('global.save') }}</el-button>
<el-button
size="mini"
class="button_box"
type="text"
@click="switcherPassWord"
>{{ $t('global.cancel') }}</el-button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form_box">
<div class="title">{{ $t('global.nickName') }}:</div>
<div class="content">
<div v-show="nickNameShow" class="show_box">
<span>{{ userInfo.nickname }}</span>
<i class="el-icon-edit" @click="switcherNickname" />
</div>
<div v-show="!nickNameShow" class="flex_box">
<el-input v-model="editInfo.nickname" :placeholder="$t('global.enterNickname')" maxlength="20" size="mini" class="input_box" />
<div class="button_box">
<el-button size="mini" class="button_box" :disabled="!editInfo.nickname" @click="saveNickName">{{ $t('global.save') }}</el-button>
<el-button size="mini" class="button_box" type="text" @click="switcherNickname">{{ $t('global.cancel') }}</el-button>
</div>
</div>
</div>
</div>
<div class="form_box">
<div class="title">{{ $t('global.mobile') }}:</div>
<div class="content">
<div v-show="mobileShow" class="show_box">
<span>{{ geTel(userInfo.mobile) }}</span>
<i class="el-icon-edit" @click="switcherMobile" />
</div>
<div v-show="!mobileShow" class="flex_box">
<el-input v-model="editInfo.mobile" :placeholder="$t('global.enterMobile')" maxlength="11" size="mini" class="input_box" />
<el-select v-model="nationCode" size="mini" class="selectCountry">
<el-option
v-for="item in countryList"
:key="item.value"
:label="item.name"
:value="item.value"
/>
</el-select>
<el-input v-model="mobileCode" :placeholder="$t('global.verificationCode')" size="mini" class="code_box" style="margin-top: 10px;" />
<el-button size="mini" style="margin-top: 10px; margin-right: 10px;" :disabled="mobileCodeTime != 0" @click="sendMobileCode">
{{ $t('global.sendCode') }}
<span v-if="mobileCodeTime">{{ mobileCodeTime }}</span>
</el-button>
<div class="button_box" style="margin-top: 10px;">
<el-button size="mini" class="button_box" :disabled="!mobileCode" @click="saveMobile">{{ $t('global.save') }}</el-button>
<el-button size="mini" class="button_box" type="text" @click="switcherMobile">{{ $t('global.cancel') }}</el-button>
</div>
</div>
</div>
</div>
<div class="form_box">
<div class="title">{{ $t('global.email') }}:</div>
<div class="content">
<div v-show="emailShow" class="show_box">
<span>{{ userInfo.email }}</span>
<i class="el-icon-edit" @click="switcherEmail" />
</div>
<div v-show="!emailShow" class="flex_box">
<el-input v-model="editInfo.email" :placeholder="$t('global.enterEmail')" size="mini" class="input_box" />
<el-input v-model="emailCode" :placeholder="$t('global.verificationCode')" size="mini" class="code_box" style="margin-top: 10px;" />
<el-button size="mini" style="margin-top: 10px; margin-right: 10px;" :disabled="emailCodeTime != 0" @click="sendEmailCode">
{{ $t('global.sendCode') }}
<span v-if="emailCodeTime">{{ emailCodeTime }}</span>
</el-button>
<div class="button_box" style="margin-top: 10px;">
<el-button size="mini" class="button_box" :disabled="!emailCode" @click="saveEmail">{{ $t('global.save') }}</el-button>
<el-button size="mini" class="button_box" type="text" @click="switcherEmail">{{ $t('global.cancel') }}</el-button>
</div>
</div>
</div>
</div>
<div class="form_box">
<div class="title">{{ $t('global.passWord') }}:</div>
<div class="content">
<div v-show="passwordShow" class="show_box">
<span>******</span>
<i class="el-icon-edit" @click="switcherPassWord" />
</div>
<div v-show="!passwordShow" class="flex_box">
<div class="passWord_box">
<span>{{ $t('global.newPassWord') }}:</span>
<el-input v-model="newPassWord1" :placeholder="$t('global.enterPassWord')" maxlength="20" show-password size="mini" class="input_box" />
</div>
<div style="height: 28px; line-height: 28px; margin-bottom: 10px;">
<el-input v-model="passWordCode" :placeholder="$t('global.verificationCode')" size="mini" class="code_box" />
<el-button size="mini" style="margin-right: 10px;" :disabled="passWordCodeTime != 0" @click="sendPassWordCode">
{{ $t('global.sendMobileCode') }}
<span v-if="passWordCodeTime">{{ passWordCodeTime }}</span>
</el-button>
</div>
<div class="button_box" style="width: 150px;">
<el-button size="mini" class="button_box" :disabled="!passWordCode" @click="savePassWord">{{ $t('global.save') }}</el-button>
<el-button size="mini" class="button_box" type="text" @click="switcherPassWord">{{ $t('global.cancel') }}</el-button>
</div>
</div>
</div>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doClose">{{ $t('global.close') }}</el-button>
</span>
</el-dialog>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doClose">{{ $t('global.close') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import md5 from 'js-md5';
import { getInfo } from '@/api/login';
import { getDesignToken, getToken } from '@/utils/auth'; //
import { getUserinfoName, getUserinfoNickname, getUserinfoMobile, getUserinfoMobileCode, getUserinfoEmailCode, getUserinfoEmail, getUserinfoPassword } from '@/api/management/user';
import { setInterval, clearInterval } from 'timers';
import md5 from "js-md5";
import { getInfo } from "@/api/login";
import { getToken } from "@/utils/auth"; // getDesignToken
import {
getUserinfoName,
getUserinfoNickname,
getUserinfoMobile,
getUserinfoMobileCode,
getUserinfoEmailCode,
getUserinfoEmail,
getUserinfoPassword
} from "@/api/management/user";
import { setInterval, clearInterval } from "timers";
export default {
data() {
return {
visible: false,
userInfo: {
name: '',
nickname: '',
mobile: '',
email: '',
passWord: ''
name: "",
nickname: "",
mobile: "",
email: "",
passWord: ""
},
editInfo: {
name: '',
nickname: '',
mobile: '',
email: '',
passWord: ''
name: "",
nickname: "",
mobile: "",
email: "",
passWord: ""
},
nationCode: '86',
nationCode: "86",
nameShow: true,
nickNameShow: true,
mobileShow: true,
@ -162,17 +295,17 @@ export default {
mobileTime: null,
passWordTime: null,
countryList: [
{ name: this.$t('global.china'), value: '86' },
{ name: this.$t('global.australia'), value: '61' },
{ name: this.$t('global.england'), value: '44' },
{ name: this.$t('global.hongKong'), value: '852' },
{ name: this.$t('global.Japanese'), value: '81' },
{ name: this.$t('global.macao'), value: '853' },
{ name: this.$t('global.singapore'), value: '65' },
{ name: this.$t('global.taiwan'), value: '886' },
{ name: this.$t('global.america'), value: '1' }
{ name: this.$t("global.china"), value: "86" },
{ name: this.$t("global.australia"), value: "61" },
{ name: this.$t("global.england"), value: "44" },
{ name: this.$t("global.hongKong"), value: "852" },
{ name: this.$t("global.Japanese"), value: "81" },
{ name: this.$t("global.macao"), value: "853" },
{ name: this.$t("global.singapore"), value: "65" },
{ name: this.$t("global.taiwan"), value: "886" },
{ name: this.$t("global.america"), value: "1" }
],
nationCodeInit: '86' //
nationCodeInit: "86" //
};
},
computed: {
@ -184,29 +317,34 @@ export default {
geTel(tel) {
const reg = /^(\d{3})\d{4}(\d{4})$/;
if (tel) {
return tel.replace(reg, '$1****$2');
return tel.replace(reg, "$1****$2");
} else {
return '';
return "";
}
},
doShow() {
this.visible = true;
const token = getToken() || getDesignToken();
getInfo(token).then(response => {
const user = response.data;
this.userInfo = {
name: user.name,
nickname: user.nickname,
mobile: user.mobile,
email: user.email,
passWord: ''
};
this.oldPassWord = user.password;
this.nationCode = user.nationCode ? user.nationCode : '86';
this.nationCodeInit = user.nationCode ? user.nationCode : '86';
}).catch(error => {
console.log(error, '请求个人信息失败');
});
// const token = getToken() || getDesignToken();
const token = getToken();
getInfo(token)
.then(response => {
const user = response.data;
this.userInfo = {
name: user.name,
nickname: user.nickname,
mobile: user.mobile,
email: user.email,
passWord: ""
};
this.oldPassWord = user.password;
this.nationCode = user.nationCode ? user.nationCode : "86";
this.nationCodeInit = user.nationCode
? user.nationCode
: "86";
})
.catch(error => {
console.log(error, "请求个人信息失败");
});
},
doClose() {
this.visible = false;
@ -221,9 +359,9 @@ export default {
await getUserinfoName(this.info.id, this.editInfo.name);
this.userInfo.name = this.editInfo.name;
this.nameShow = !this.nameShow;
this.$store.commit('SET_NAME', this.editInfo.name);
this.$store.commit("SET_NAME", this.editInfo.name);
} catch (error) {
console.log(error, '错误');
console.log(error, "错误");
}
}
},
@ -235,12 +373,15 @@ export default {
async saveNickName() {
if (this.editInfo.nickname) {
try {
await getUserinfoNickname(this.info.id, this.editInfo.nickname);
await getUserinfoNickname(
this.info.id,
this.editInfo.nickname
);
this.userInfo.nickname = this.editInfo.nickname;
this.nickNameShow = !this.nickNameShow;
this.$store.commit('SET_NICKNAME', this.editInfo.nickname);
this.$store.commit("SET_NICKNAME", this.editInfo.nickname);
} catch (error) {
console.log(error, '错误');
console.log(error, "错误");
}
}
},
@ -263,12 +404,12 @@ export default {
this.mobileShow = !this.mobileShow;
this.mobileCode = null;
} catch (error) {
this.$message.info(this.$t('global.codeError'));
this.$message.info(this.$t("global.codeError"));
}
}
},
async sendMobileCode() {
const random = Math.floor((Math.random() * 10000) + 1);
const random = Math.floor(Math.random() * 10000 + 1);
const timeCount = Date.parse(new Date()) / 1000;
const pass = `${timeCount}${this.nationCode}${this.editInfo.mobile}${random}`;
const param = {
@ -290,7 +431,7 @@ export default {
}, 1000);
await getUserinfoMobileCode(param);
} catch (error) {
this.$message.info(this.$t('global.codeFaile'));
this.$message.info(this.$t("global.codeFaile"));
}
},
@ -310,7 +451,7 @@ export default {
this.emailShow = !this.emailShow;
this.emailCode = null;
} catch (error) {
this.$message.info(this.$t('global.codeError'));
this.$message.info(this.$t("global.codeError"));
}
}
},
@ -327,7 +468,7 @@ export default {
}, 1000);
await getUserinfoEmailCode(this.editInfo.email);
} catch (error) {
this.$message.info(this.$t('global.codeFaile'));
this.$message.info(this.$t("global.codeFaile"));
}
},
@ -336,7 +477,7 @@ export default {
},
async savePassWord() {
if (this.newPassWord1.length <= 5) {
this.$message.info(this.$t('global.passWordLength'));
this.$message.info(this.$t("global.passWordLength"));
} else {
this.uploadPassword();
}
@ -351,18 +492,18 @@ export default {
try {
await getUserinfoPassword(this.info.id, param);
this.passwordShow = !this.passwordShow;
this.newPassWord1 = '';
this.newPassWord1 = "";
this.passWordCode = null;
} catch (error) {
console.log(error, 11);
}
} else {
this.$message.info(this.$t('global.passWordSome'));
this.$message.info(this.$t("global.passWordSome"));
}
},
async sendPassWordCode() {
if (this.userInfo.mobile) {
const random = Math.floor((Math.random() * 10000) + 1);
const random = Math.floor(Math.random() * 10000 + 1);
const timeCount = Date.parse(new Date()) / 1000;
const pass = `${timeCount}${this.nationCodeInit}${this.userInfo.mobile}${random}`;
const param = {
@ -384,11 +525,11 @@ export default {
}, 1000);
await getUserinfoMobileCode(param);
} catch (error) {
this.$message.info(this.$t('global.codeFaile'));
this.$message.info(this.$t("global.codeFaile"));
}
} else {
this.passwordShow = !this.passwordShow;
this.$message.info(this.$t('global.enterMobileNumber'));
this.$message.info(this.$t("global.enterMobileNumber"));
}
}
}
@ -396,75 +537,74 @@ export default {
</script>
<style rel="stylesheet/scss" lang="scss" scope>
.flex_box{
display: flex;
align-items: center;
flex-wrap: wrap;
}
.form_box{
width: 100%;
overflow: hidden;
margin-bottom: 10px;
// display: flex;
// align-items: center;
// flex-wrap: wrap;
.flex_box {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.form_box {
width: 100%;
overflow: hidden;
margin-bottom: 10px;
// display: flex;
// align-items: center;
// flex-wrap: wrap;
.selectCountry{
width: 90px;
height: 28px;
line-height: 28px;
}
.title{
width: 80px;
text-align: left;
font-size: 14px;
height: 28px;
line-height: 28px;
float: left;
}
.content{
width: calc(100% - 80px);
float: left;
margin: 0;
.el-icon-edit{
cursor: pointer;
}
}
.show_box{
height: 28px;
line-height: 28px;
}
.input_box{
font-size: 14px;
width: 200px;
margin-right: 10px;
flex: none;
line-height: 0;
}
.code_box{
font-size: 14px;
width: 150px;
margin-right: 15px;
flex: none;
line-height: 0;
}
.button_box{
line-height: 0;
height: 28px;
}
.selectCountry {
width: 90px;
height: 28px;
line-height: 28px;
}
.title {
width: 80px;
text-align: left;
font-size: 14px;
height: 28px;
line-height: 28px;
float: left;
}
.content {
width: calc(100% - 80px);
float: left;
margin: 0;
.el-icon-edit {
cursor: pointer;
}
}
.show_box {
height: 28px;
line-height: 28px;
}
.input_box {
font-size: 14px;
width: 200px;
margin-right: 10px;
flex: none;
line-height: 0;
}
.code_box {
font-size: 14px;
width: 150px;
margin-right: 15px;
flex: none;
line-height: 0;
}
.button_box {
line-height: 0;
height: 28px;
}
.passWord_box{
height: 28px;
line-height: 28px;
margin-bottom: 10px;
}
}
</style>
<style rel="stylesheet/scss" lang="scss">
.userInfo_box{
.el-dialog__body{
padding: 0 20px;
}
.passWord_box {
height: 28px;
line-height: 28px;
margin-bottom: 10px;
}
}
</style>
<style rel="stylesheet/scss" lang="scss">
.userInfo_box {
.el-dialog__body {
padding: 0 20px;
}
}
</style>