|
@@ -5,12 +5,12 @@
|
|
|
<el-step title="绑定新手机"></el-step>
|
|
|
</el-steps>
|
|
|
|
|
|
- <el-form label-width="80px" style="width:400px;" :rules="rules">
|
|
|
+ <el-form label-width="80px" style="width:400px;" :rules="rules" :model="phoneBindingForm">
|
|
|
<el-form-item label="原手机号" v-if="active===0" prop="phone">
|
|
|
<span v-model="phoneBindingForm.phone">{{this.user.mobile}}</span>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="新手机号" v-if="active===1" prop="phone">
|
|
|
- <el-input v-model="phoneBindingForm.phone"></el-input>
|
|
|
+ <el-form-item label="新手机号" v-if="active===1" prop="newPhone">
|
|
|
+ <el-input v-model="phoneBindingForm.newPhone"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="验证码" prop="verifyCode">
|
|
|
<el-input placeholder="验证码内容" v-model="phoneBindingForm.verifyCode" class="input-with-select">
|
|
@@ -41,17 +41,23 @@
|
|
|
user: {},
|
|
|
phoneBindingForm: {
|
|
|
phone: '',
|
|
|
- verifyCode: ''
|
|
|
+ verifyCode: '',
|
|
|
+ newPhone:'',
|
|
|
},
|
|
|
hasVerifyCode: false,
|
|
|
codeTime: 60,
|
|
|
rules: {
|
|
|
verifyCode: [
|
|
|
{required: true, message: '请输入验证码', trigger: 'blur'},
|
|
|
+ {min: 6, max: 6, message: '验证码长度为6个字符', trigger: 'blur'}
|
|
|
],
|
|
|
phone: [
|
|
|
{required: true, message: '请输入手机号', trigger: 'blur'},
|
|
|
],
|
|
|
+ newPhone: [
|
|
|
+ {required: true, message: '请输入手机号', trigger: 'blur'},
|
|
|
+ {min: 11, max: 11, message: '手机号不合法', trigger: 'blur'}
|
|
|
+ ],
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -78,6 +84,8 @@
|
|
|
this.phoneBindingForm.phone = '';
|
|
|
this.phoneBindingForm.verifyCode = '';
|
|
|
this.setUserInfo();
|
|
|
+ }else{
|
|
|
+ notify('error', '验证原手机失败:' + res.data);
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
notify('error', '验证原手机失败:' + err.data);
|
|
@@ -85,7 +93,7 @@
|
|
|
} else {
|
|
|
let params = {
|
|
|
"id": this.user.id,
|
|
|
- "mobile": this.phoneBindingForm.phone,
|
|
|
+ "mobile": this.phoneBindingForm.newPhone,
|
|
|
"verifyCode": this.phoneBindingForm.verifyCode
|
|
|
};
|
|
|
Http.put('/api/user/mobile', params).then(res => {
|
|
@@ -102,26 +110,53 @@
|
|
|
|
|
|
},
|
|
|
getVerifyCode() {
|
|
|
- let params = {
|
|
|
- id: this.user.id,
|
|
|
- mobile: this.phoneBindingForm.phone
|
|
|
- }
|
|
|
- Http.put('/api/verify/mobile', params).then((res) => {
|
|
|
- this.hasVerifyCode = true;
|
|
|
- let _this = this;
|
|
|
- let codeTimer = setInterval(function () {
|
|
|
- if (_this.codeTime > 0) {
|
|
|
- _this.codeTime--;
|
|
|
- } else {
|
|
|
- clearInterval(codeTimer);
|
|
|
- _this.hasVerifyCode = false;
|
|
|
- this.codeTime = 10;
|
|
|
- }
|
|
|
- }, 1000)
|
|
|
- }).catch(err => {
|
|
|
- notify('error', '获取验证码失败:' + err.data);
|
|
|
- })
|
|
|
+ if (this.active === 0) {
|
|
|
+ //1.验证原手机
|
|
|
+ let params = {
|
|
|
+ id: this.user.id,
|
|
|
+ mobile: this.phoneBindingForm.phone
|
|
|
+ }
|
|
|
+ Http.put('/api/verify/mobile', params).then((res) => {
|
|
|
+ this.hasVerifyCode = true;
|
|
|
+ let _this = this;
|
|
|
+ let codeTimer = setInterval(function () {
|
|
|
+ if (_this.codeTime > 0) {
|
|
|
+ _this.codeTime--;
|
|
|
+ } else {
|
|
|
+ clearInterval(codeTimer);
|
|
|
+ _this.hasVerifyCode = false;
|
|
|
+ this.codeTime = 10;
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ }).catch(err => {
|
|
|
+ notify('error', '获取验证码失败:' + err.data);
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ //2.验证新手机
|
|
|
+ let params = {
|
|
|
+ id: this.user.id,
|
|
|
+ mobile: this.phoneBindingForm.newPhone
|
|
|
+ }
|
|
|
+ console.log("手机号:" + this.phoneBindingForm.newPhone);
|
|
|
+ notify("手机号:" + this.phoneBindingForm.newPhone);
|
|
|
+ Http.put('/api/verify/mobile', params).then((res) => {
|
|
|
+ this.hasVerifyCode = true;
|
|
|
+ let _this = this;
|
|
|
+ let codeTimer = setInterval(function () {
|
|
|
+ if (_this.codeTime > 0) {
|
|
|
+ _this.codeTime--;
|
|
|
+ } else {
|
|
|
+ clearInterval(codeTimer);
|
|
|
+ _this.hasVerifyCode = false;
|
|
|
+ this.codeTime = 10;
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ }).catch(err => {
|
|
|
+ notify('error', '获取验证码失败:' + err.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
mounted() {
|
|
|
this.setUserInfo();
|