216 lines
5.2 KiB
Vue
216 lines
5.2 KiB
Vue
<template>
|
||
<view class="Box">
|
||
<!-- <view class="Box_one">设置新手机</view>
|
||
<view class="Box_T">设置新手机号需要通过短信验证</view>
|
||
<view class="Box_there">当前手机号:{{ form.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2') }}</view> -->
|
||
<view class="Box_consitem">
|
||
<view class="Box_box flex-start">
|
||
<text class="top_box_one_text">中国大陆+86</text>
|
||
<input type="number" class="top_box_one_textinput" v-model="form.phone" style="font-size: 24rpx;" placeholder="请输入手机号" maxlength="11" data-key="mobile" />
|
||
</view>
|
||
<view class="Box_box flex-between"
|
||
style="padding: 14rpx 0;border-top: 1rpx solid #efefef;border-bottom: 1rpx solid #efefef; margin-top: 0;">
|
||
<text class="top_box_one_text" style="border-right:none;">验证码</text>
|
||
<input type="number" style="font-size: 24rpx;" v-model="form.code" placeholder="请输入短信验证码"
|
||
data-key="mobile" />
|
||
<text class="top_box_one_texts">
|
||
<view v-if="showText == true" class="yzm" @click="CodeRegister">{{ Recapture }}</view>
|
||
<view v-else style="color: #ccc; background-color: #f9f9f9; border-radius:16px; padding: 10rpx;">
|
||
{{ second }}s重新发送
|
||
</view>
|
||
</text>
|
||
</view>
|
||
<view class="flex-colum">
|
||
<view class="Box_bottom" @click="userInfochangePhone">确定</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
form: {
|
||
phone: '',
|
||
code: '',
|
||
oldPhone: '',
|
||
password: ''
|
||
},
|
||
// 注册定时器 初始值
|
||
second: 60,
|
||
showText: true,
|
||
Recapture: '发送验证码'
|
||
};
|
||
},
|
||
onLoad() {},
|
||
computed: {},
|
||
methods: {
|
||
async CodeRegister() {
|
||
//发起验证码
|
||
if (this.form.phone == null || this.form.phone == '') {
|
||
uni.showToast({
|
||
title: '请输入电话号码',
|
||
icon: 'none'
|
||
});
|
||
return false;
|
||
}
|
||
const res = await this.api.verifyPhoneIsExist({
|
||
// post 手机验证码
|
||
phone: this.form.phone
|
||
});
|
||
console.log(res);
|
||
if (res.code == 200) {
|
||
uni.showToast({
|
||
title: '验证码获取成功',
|
||
icon: 'none'
|
||
});
|
||
// 定时器
|
||
this.showText = false;
|
||
this.Recapture = '重新获取';
|
||
var interval = setInterval(() => {
|
||
let times = --this.second;
|
||
this.second = times < 10 ? '0' + times : times; //小于10秒补 0
|
||
}, 1000);
|
||
setTimeout(() => {
|
||
clearInterval(interval);
|
||
this.second = 60;
|
||
this.showText = true;
|
||
}, 60000);
|
||
}
|
||
},
|
||
async userInfochangePhone() {
|
||
if (this.form.phone == null || this.form.phone == '') {
|
||
uni.showToast({
|
||
title: '请输入新电话号码',
|
||
icon: 'none'
|
||
});
|
||
return false;
|
||
}
|
||
if (this.form.password == null || this.form.password == '') {
|
||
uni.showToast({
|
||
title: '请输入登录密码',
|
||
icon: 'none'
|
||
});
|
||
return false;
|
||
}
|
||
if (this.form.code == null || this.form.code == '') {
|
||
uni.showToast({
|
||
title: '请输入验证码',
|
||
icon: 'none'
|
||
});
|
||
return false;
|
||
}
|
||
let res = await this.api.userInfochangePhone({
|
||
code: this.form.code,
|
||
password: this.form.password,
|
||
oldPhone: this.$store.state.czguserInfo.phone,
|
||
phone: this.form.phone
|
||
});
|
||
console.log(res)
|
||
if (res.code == 200) {
|
||
uni.showToast({
|
||
title: '修改成功请重新登录',
|
||
icon: 'none'
|
||
});
|
||
setTimeout(() => {
|
||
uni.removeStorageSync("token");
|
||
uni.removeStorageSync("userId");
|
||
uni.removeStorageSync('myLoginName')
|
||
uni.reLaunch({
|
||
url: '../../../pages/login/login'
|
||
});
|
||
}, 2000);
|
||
}
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
page {
|
||
background: #F9F9F9;
|
||
}
|
||
|
||
.Box {
|
||
padding: 0 28rpx;
|
||
|
||
.Box_one {
|
||
padding-top: 38rpx;
|
||
font-size: 40rpx;
|
||
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
||
font-weight: 400;
|
||
color: #333333;
|
||
}
|
||
|
||
.Box_T {
|
||
margin-top: 2rpx;
|
||
font-size: 24rpx;
|
||
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
||
font-weight: 400;
|
||
color: #999999;
|
||
}
|
||
|
||
.Box_there {
|
||
margin-top: 70rpx;
|
||
font-size: 24rpx;
|
||
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
||
font-weight: 400;
|
||
color: #333333;
|
||
}
|
||
|
||
.Box_consitem {
|
||
background: #ffffff;
|
||
padding: 32rpx;
|
||
border-radius: 24rpx;
|
||
margin-top: 22rpx;
|
||
|
||
.Box_box {
|
||
padding: 18rpx 0;
|
||
.top_box_one_text {
|
||
width: auto;
|
||
padding: 0 20rpx;
|
||
font-size: 32rpx;
|
||
font-family: PingFang SC-Regular, PingFang SC;
|
||
font-weight: 400;
|
||
color: #333333;
|
||
border-right: 1rpx solid #ccc;
|
||
}
|
||
.top_box_one_textinput{
|
||
margin-left: 20rpx;
|
||
}
|
||
input {
|
||
width: auto;
|
||
}
|
||
|
||
.top_box_one_texts {
|
||
font-size: 28rpx;
|
||
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
||
font-weight: 400;
|
||
color: #5082fd;
|
||
}
|
||
}
|
||
|
||
.flex-colum {
|
||
width: 100%;
|
||
margin-top: 64rpx;
|
||
|
||
.Box_bottom {
|
||
width: 558rpx;
|
||
height: 72rpx;
|
||
background: linear-gradient(115deg, #7E81A5 0%, #4D4E64 100%);
|
||
border-radius: 50rpx;
|
||
font-size: 36rpx;
|
||
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
||
font-weight: 400;
|
||
color: #ffffff;
|
||
line-height: 72rpx;
|
||
text-align: center;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
</style> |