|
@@ -1,25 +1,27 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <el-steps :active="active" process-status="finish" style="margin: 20px">
|
|
|
- <el-step title="验证原手机"></el-step>
|
|
|
- <el-step title="绑定新手机"></el-step>
|
|
|
- </el-steps>
|
|
|
+ <el-steps :active="active" process-status="finish" style="margin: 20px">
|
|
|
+ <el-step title="验证原手机"></el-step>
|
|
|
+ <el-step title="绑定新手机"></el-step>
|
|
|
+ </el-steps>
|
|
|
|
|
|
- <el-form label-width="80px" style="with:400px;">
|
|
|
- <el-form-item label="原手机号" v-if="active===0">
|
|
|
- <span v-model="phoneBindingForm.phone">{{this.user.mobile}}</span>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="新手机号" v-if="active===1">
|
|
|
- <el-input v-model="phoneBindingForm.phone"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="验证码">
|
|
|
- <el-input placeholder="验证码内容" v-model="phoneBindingForm.verifyCode" class="input-with-select">
|
|
|
- <el-button slot="append" @click="getVerifyCode">{{hasVerifyCode ? codeTime : '获取验证码'}}</el-button>
|
|
|
- </el-input>
|
|
|
- <span v-if="hasVerifyCode">验证码已发送到您手机上</span>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <el-button type="primary" plain style="margin-left: 80px" @click="reBindingMobile">{{this.active===0 ? '下一步':'完成绑定'}}</el-button>
|
|
|
+ <el-form label-width="80px" style="width:400px;">
|
|
|
+ <el-form-item label="原手机号" v-if="active===0">
|
|
|
+ <span v-model="phoneBindingForm.phone">{{this.user.mobile}}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="新手机号" v-if="active===1">
|
|
|
+ <el-input v-model="phoneBindingForm.phone"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="验证码">
|
|
|
+ <el-input placeholder="验证码内容" v-model="phoneBindingForm.verifyCode" class="input-with-select">
|
|
|
+ <el-button slot="append" @click="getVerifyCode">{{hasVerifyCode ? codeTime : '获取验证码'}}</el-button>
|
|
|
+ </el-input>
|
|
|
+ <span v-if="hasVerifyCode">验证码已发送到您手机上</span>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <el-button type="primary" plain style="margin-left: 80px" @click="reBindingMobile">{{this.active===0 ?
|
|
|
+ '下一步':'完成绑定'}}
|
|
|
+ </el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
@@ -29,79 +31,82 @@
|
|
|
import Http from '@/js/http.js'
|
|
|
import {storageGet} from '@/js/index'
|
|
|
import {notify} from '@/constants/index'
|
|
|
+
|
|
|
export default {
|
|
|
name: "ReBindingMobile",
|
|
|
- data(){
|
|
|
- return{
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
active: 0,
|
|
|
- user:{},
|
|
|
+ user: {},
|
|
|
phoneBindingForm: {
|
|
|
phone: '',
|
|
|
verifyCode: ''
|
|
|
},
|
|
|
- hasVerifyCode:false,
|
|
|
- codeTime:10,
|
|
|
+ hasVerifyCode: false,
|
|
|
+ codeTime: 10,
|
|
|
}
|
|
|
},
|
|
|
- methods:{
|
|
|
+ methods: {
|
|
|
setUserInfo() {
|
|
|
- let userId = storageGet('user')&&storageGet('user').userVO.id;
|
|
|
- Http.get(`/api/user/${userId}`).then(res=>{
|
|
|
+ let userId = storageGet('user') && storageGet('user').userVO.id;
|
|
|
+ Http.get(`/api/user/${userId}`).then(res => {
|
|
|
this.user = res.userVO
|
|
|
})
|
|
|
},
|
|
|
- reBindingMobile(){
|
|
|
- if(this.active === 0){
|
|
|
- //1.验证原手机
|
|
|
- let params = {
|
|
|
- "id": this.user.id,
|
|
|
- "mobile": this.user.mobile,
|
|
|
- "verifyCode":this.phoneBindingForm.verifyCode
|
|
|
- }
|
|
|
- Http.put('/api/verify/old/mobile',params).then(res=>{
|
|
|
- if(res.code === 20000){
|
|
|
- notify('success', '验证成功');
|
|
|
- this.active = 0;
|
|
|
- this.setUserInfo();
|
|
|
- }
|
|
|
- }).catch(err=> {
|
|
|
- notify('error', '验证原手机失败:' + err.data);
|
|
|
- })
|
|
|
- }else{
|
|
|
- let params = {
|
|
|
- "id": this.user.id,
|
|
|
- "mobile": this.phoneBindingForm.phone,
|
|
|
- "verifyCode": this.phoneBindingForm.verifyCode
|
|
|
- };
|
|
|
- Http.put('/api/user/mobile',params).then(res=>{
|
|
|
- if(res.code === 20000){
|
|
|
- notify('success', '重新绑定成功');
|
|
|
- this.$router.push({path:'/personal/phoneBinding'});
|
|
|
- }
|
|
|
- }).catch(err=> {
|
|
|
- notify('error', '重新绑定失败:' + err.data);
|
|
|
- })
|
|
|
+ reBindingMobile() {
|
|
|
+ if (this.active === 0) {
|
|
|
+ //1.验证原手机
|
|
|
+ let params = {
|
|
|
+ "id": this.user.id,
|
|
|
+ "mobile": this.user.mobile,
|
|
|
+ "verifyCode": this.phoneBindingForm.verifyCode
|
|
|
}
|
|
|
+ Http.put('/api/verify/old/mobile', params).then(res => {
|
|
|
+ if (res.code === 20000) {
|
|
|
+ notify('success', '验证成功');
|
|
|
+ this.active = 0;
|
|
|
+ this.setUserInfo();
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ notify('error', '验证原手机失败:' + err.data);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let params = {
|
|
|
+ "id": this.user.id,
|
|
|
+ "mobile": this.phoneBindingForm.phone,
|
|
|
+ "verifyCode": this.phoneBindingForm.verifyCode
|
|
|
+ };
|
|
|
+ Http.put('/api/user/mobile', params).then(res => {
|
|
|
+ if (res.msg == "ERROR") {
|
|
|
+ notify('error', '重新绑定失败:' + res.data);
|
|
|
+ } else {
|
|
|
+ notify('success', '重新绑定成功');
|
|
|
+ this.$router.push({path: '/personal/phoneBinding'});
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ notify('error', '重新绑定失败:' + err.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
- getVerifyCode(){
|
|
|
+ getVerifyCode() {
|
|
|
let params = {
|
|
|
- id:this.user.id,
|
|
|
- mobile:this.phoneBindingForm.phone
|
|
|
+ id: this.user.id,
|
|
|
+ mobile: this.phoneBindingForm.phone
|
|
|
}
|
|
|
- Http.put('/api/verify/mobile',params).then((res)=>{
|
|
|
+ Http.put('/api/verify/mobile', params).then((res) => {
|
|
|
this.hasVerifyCode = true;
|
|
|
let _this = this;
|
|
|
let codeTimer = setInterval(function () {
|
|
|
- if(_this.codeTime > 0 ){
|
|
|
+ if (_this.codeTime > 0) {
|
|
|
_this.codeTime--;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
clearInterval(codeTimer);
|
|
|
_this.hasVerifyCode = false;
|
|
|
this.codeTime = 10;
|
|
|
}
|
|
|
- },1000)
|
|
|
- }).catch(err=> {
|
|
|
+ }, 1000)
|
|
|
+ }).catch(err => {
|
|
|
notify('error', '获取验证码失败:' + err.data);
|
|
|
})
|
|
|
}
|