|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div style="margin-top: 20px">
|
|
|
- <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="手机号码" prop="phone">
|
|
|
<el-input v-model="phoneBindingForm.phone"></el-input>
|
|
|
</el-form-item>
|
|
@@ -11,7 +11,7 @@
|
|
|
<span v-if="hasVerifyCode">验证码已发送到您手机上</span>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" plain @click="bindingMobile">完成绑定</el-button>
|
|
|
+ <el-button type="primary" plain @click="bindingMobile">完成绑定</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
@@ -19,81 +19,94 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import Http from '@/js/http.js'
|
|
|
- import {storageGet} from '@/js/index'
|
|
|
- import {notify} from '@/constants/index'
|
|
|
- export default {
|
|
|
- name: "BindingMobile",
|
|
|
- data(){
|
|
|
- return{
|
|
|
- phoneBindingForm:{
|
|
|
- phone:'',
|
|
|
- verifyCode:''
|
|
|
+ import Http from '@/js/http.js'
|
|
|
+ import {storageGet} from '@/js/index'
|
|
|
+ import {notify} from '@/constants/index'
|
|
|
+
|
|
|
+ export default {
|
|
|
+ name: "BindingMobile",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ phoneBindingForm: {
|
|
|
+ phone: '',
|
|
|
+ verifyCode: ''
|
|
|
+ },
|
|
|
+ hasVerifyCode: false,
|
|
|
+ codeTime: 60,
|
|
|
+ user: {},
|
|
|
+ rules: {
|
|
|
+ verifyCode: [
|
|
|
+ {required: true, message: '请输入验证码', trigger: 'blur'},
|
|
|
+ {min: 6, max: 6, message: '验证码长度为6个字符', trigger: 'blur'}
|
|
|
+ ],
|
|
|
+ phone: [
|
|
|
+ {required: true, message: '请输入手机号', trigger: 'blur'},
|
|
|
+ {min: 11, max: 11, message: '手机号长度为11个字符', trigger: 'blur'}
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
- hasVerifyCode:false,
|
|
|
- codeTime:60,
|
|
|
- user:{},
|
|
|
- rules: {
|
|
|
- verifyCode: [
|
|
|
- {required: true, message: '请输入验证码', trigger: 'blur'},
|
|
|
- ],
|
|
|
- phone: [
|
|
|
- {required: true, message: '请输入手机号', trigger: 'blur'},
|
|
|
- ],
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- methods:{
|
|
|
- setUserInfo() {
|
|
|
- let userId = storageGet('user')&&storageGet('user').userVO.id;
|
|
|
- Http.get(`/api/user/${userId}`).then(res=>{
|
|
|
- this.user = res.userVO
|
|
|
- })
|
|
|
- },
|
|
|
- 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;
|
|
|
+ methods: {
|
|
|
+ setUserInfo() {
|
|
|
+ let userId = storageGet('user') && storageGet('user').userVO.id;
|
|
|
+ Http.get(`/api/user/${userId}`).then(res => {
|
|
|
+ this.user = res.userVO
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getVerifyCode() {
|
|
|
+ let params = {
|
|
|
+ id: this.user.id,
|
|
|
+ mobile: this.phoneBindingForm.phone
|
|
|
+ }
|
|
|
+ Http.put('/api/verify/mobile', params).then((res) => {
|
|
|
+ if (res.msg == "ERROR") {
|
|
|
+ notify('error', res.data);
|
|
|
+ } else {
|
|
|
+ notify('success', res.data);
|
|
|
+ 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);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ bindingMobile() {
|
|
|
+ // this.$refs['phoneBindingForm'].validate(valid => {
|
|
|
+ // if (valid) {
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ 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);
|
|
|
+ })
|
|
|
}
|
|
|
- },1000)
|
|
|
- }).catch(err=> {
|
|
|
- notify('error', '绑定手机失败:' + err.data);
|
|
|
- })
|
|
|
- },
|
|
|
- bindingMobile(){
|
|
|
- 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);
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- this.setUserInfo()
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.setUserInfo()
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|