|
|
@@ -15,13 +15,12 @@
|
|
|
title="修改昵称"
|
|
|
:visible.sync="nameDialogVisible"
|
|
|
width="30%">
|
|
|
- <el-input ref="name" v-model="newName" placeholder="请输入昵称, 长度为1-10个字符" maxlength="10" class="login-card__item" oninput="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\ ]/g,'')" autofocus></el-input>
|
|
|
+ <el-input ref="name" v-model="newName" placeholder="请输入昵称, 长度为1-10个字符" maxlength="10" oninput="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\ ]/g,'')" autofocus></el-input>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
<el-button @click="nameDialogVisible = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="saveName">确 定</el-button>
|
|
|
+ <el-button type="primary" @click="saveName" :loading="loading">确 定</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
-
|
|
|
</div>
|
|
|
<div class="main-card__info-item">
|
|
|
<div class="main-card__info-item__head">
|
|
|
@@ -29,13 +28,35 @@
|
|
|
<a class="main-card__info-item__modify" @click="emailDialogVisible = true">修改</a>
|
|
|
</div>
|
|
|
<div class="main-card__info-item__value">{{email}}</div>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="更换邮箱"
|
|
|
+ :visible.sync="emailDialogVisible"
|
|
|
+ width="30%">
|
|
|
+ <el-input ref="name" v-model="newEmail" placeholder="请输入邮箱" maxlength="255" autofocus></el-input>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="emailDialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="saveEmail" :loading="loading">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
<div class="main-card__info-item">
|
|
|
<div class="main-card__info-item__head">
|
|
|
<p class="main-card__info-item__name">个性签名</p>
|
|
|
- <a class="main-card__info-item__modify" @click="signatueDialogVisible = true">修改</a>
|
|
|
+ <a class="main-card__info-item__modify" @click="signatureDialogVisible = true">修改</a>
|
|
|
</div>
|
|
|
<div class="main-card__info-item__value">{{signature}}</div>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="修改个性签名"
|
|
|
+ :visible.sync="signatureDialogVisible"
|
|
|
+ width="30%">
|
|
|
+ <el-input ref="name" v-model="newSignature" placeholder="请输入个性签名,长度1-20个字符" maxlength="20" autofocus></el-input>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="signatureDialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="saveSignature" :loading="loading">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -55,7 +76,8 @@
|
|
|
newSignature: '',
|
|
|
nameDialogVisible: false,
|
|
|
emailDialogVisible: false,
|
|
|
- signatureDialogVisible: false
|
|
|
+ signatureDialogVisible: false,
|
|
|
+ loading: false
|
|
|
}
|
|
|
},
|
|
|
mounted(){
|
|
|
@@ -83,12 +105,32 @@
|
|
|
});
|
|
|
},
|
|
|
saveName(){
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ if(this.newName.length === 0){
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: '昵称不得为空',
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(this.newName === this.name){
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: '新昵称不得与原昵称相同',
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.$api.$post('/user/saveName', {
|
|
|
- name: this.newName
|
|
|
+ newName: this.newName
|
|
|
}).then((res) =>
|
|
|
{
|
|
|
if(res.code === 0){
|
|
|
- let user = this.$store.state.user;
|
|
|
+ let user = JSON.parse(JSON.stringify(this.$store.state.user));
|
|
|
user.name = this.newName;
|
|
|
this.$store.commit("saveUser", user);
|
|
|
this.name = this.newName;
|
|
|
@@ -109,11 +151,100 @@
|
|
|
).catch((e)=>{
|
|
|
console.log(e);
|
|
|
});
|
|
|
+
|
|
|
+ this.loading = false;
|
|
|
},
|
|
|
saveEmail(){
|
|
|
+ this.loading = true;
|
|
|
+ if(this.newEmail.length === 0){
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: '邮箱不得为空',
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$api.$post('/user/saveEmail', {
|
|
|
+ newEmail: this.newEmail
|
|
|
+ }).then((res) =>
|
|
|
+ {
|
|
|
+ if(res.code === 0){
|
|
|
+ let user = JSON.parse(JSON.stringify(this.$store.state.user));
|
|
|
+ user.email = this.newEmail;
|
|
|
+ this.$store.commit("saveUser", user);
|
|
|
+ this.email = this.newEmail;
|
|
|
+ this.emailDialogVisible = false;
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: "修改成功",
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: res.message,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ).catch((e)=>{
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+
|
|
|
+ this.loading = false;
|
|
|
|
|
|
},
|
|
|
saveSignature(){
|
|
|
+ this.loading = true;
|
|
|
+ if(this.newSignature.length === 0){
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: '个性签名不得为空',
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(this.newSignature.length > 20){
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: '个性签名过长',
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$api.$post('/user/saveSignature', {
|
|
|
+ newSignature: this.newSignature
|
|
|
+ }).then((res) =>
|
|
|
+ {
|
|
|
+ if(res.code === 0){
|
|
|
+ let user = JSON.parse(JSON.stringify(this.$store.state.user));
|
|
|
+ user.signature = this.newSignature;
|
|
|
+ this.$store.commit("saveUser", user);
|
|
|
+ this.signature = this.newSignature;
|
|
|
+ this.signatureDialogVisible = false;
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: "修改成功",
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ this.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: res.message,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ).catch((e)=>{
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+
|
|
|
+ this.loading = false;
|
|
|
|
|
|
}
|
|
|
}
|