180 lines
3.3 KiB
Vue
180 lines
3.3 KiB
Vue
<template>
|
|
<view class="form">
|
|
<view class="box">
|
|
<view class="formItem">
|
|
<view class="label">新手机号</view>
|
|
<view class="ipt">
|
|
<input class="uni-input" type="phone" @input="changePhone" placeholder="请输入手机号"
|
|
:value="inputValue" />
|
|
</view>
|
|
</view>
|
|
<view class="formItem">
|
|
<view class="label">验证码</view>
|
|
<view class="ipt">
|
|
<input class="uni-input" type="text" @input="changeCode" placeholder="请输入验证码" :value="code" />
|
|
</view>
|
|
<view class="getCodeBtn" @click="getCode">{{btnText}}</view>
|
|
</view>
|
|
</view>
|
|
<button class="onname" :style="{'background':dbled?'#999':'#08d89b'}" :disabled="dbled" type="primary"
|
|
@click="upPhone()">确认修改</button>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
inputValue: "",
|
|
isUp: false,
|
|
btnText: "获取验证码",
|
|
interV: null,
|
|
time: 60,
|
|
isGetCode: false,
|
|
code: ""
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
this.inputValue = options.mobile
|
|
},
|
|
methods: {
|
|
changePhone(e) {
|
|
this.inputValue = e.detail.value
|
|
},
|
|
changeCode(e) {
|
|
this.code = e.detail.value;
|
|
},
|
|
|
|
upPhone() {
|
|
let that = this;
|
|
if (!/^1[3456789]\d{9}$/.test(that.inputValue)) {
|
|
uni.showToast({
|
|
title: "手机号有误"
|
|
})
|
|
return
|
|
}
|
|
if (!that.isUp) {
|
|
that.isUp = true;
|
|
that.$httpRequest({
|
|
url: "/api/user/changemobile",
|
|
method: "POST",
|
|
data: {
|
|
mobile: that.inputValue,
|
|
captcha: this.captcha
|
|
}
|
|
}).then(res => {
|
|
if (res.code == 1) {
|
|
uni.showToast({
|
|
title: "修改成功",
|
|
icon: "none",
|
|
duration: 1500
|
|
});
|
|
}
|
|
})
|
|
} else {
|
|
uni.showToast({
|
|
title: "请勿频繁提交"
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
getCode() {
|
|
if (!this.isGetCode) {
|
|
this.isGetCode = true;
|
|
console.log(this.inputValue);
|
|
|
|
if (/^1[3456789]\d{9}$/.test(this.inputValue)) {
|
|
this.interV = setInterval(() => {
|
|
this.time--;
|
|
this.btnText = this.time + '秒后重新获取'
|
|
if (this.time <= 0) {
|
|
this.isGetCode = false;
|
|
this.btnText == "获取验证码";
|
|
this.time = 60;
|
|
}
|
|
}, 1000)
|
|
|
|
uni.request({
|
|
url: this.configs.webUrl + '/api/sms/index',
|
|
data: {
|
|
phone: this.inputValue
|
|
},
|
|
success() {
|
|
uni.showToast({
|
|
title: "发送成功",
|
|
icon: "none",
|
|
duration: 1500
|
|
})
|
|
},
|
|
fail() {
|
|
|
|
}
|
|
})
|
|
|
|
} else {
|
|
uni.showToast({
|
|
title: "手机号有误",
|
|
icon: "none",
|
|
duration: 1500
|
|
})
|
|
this.isGetCode = false;
|
|
}
|
|
} else {}
|
|
},
|
|
|
|
|
|
|
|
|
|
},
|
|
beforeDestroy() {
|
|
clearInterval(this.interV)
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.form {
|
|
margin: 20rpx;
|
|
|
|
}
|
|
|
|
.formItem {
|
|
display: flex;
|
|
height: 120rpx;
|
|
align-items: center;
|
|
border: 2rpx solid #F8F8F8;
|
|
}
|
|
|
|
.label {
|
|
width: 260rpx;
|
|
font-size: 32rpx;
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
margin-left: 36rpx;
|
|
}
|
|
|
|
.ipt {
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
.ipt input {
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
font-size: 30rpx;
|
|
}
|
|
|
|
.getCodeBtn {
|
|
font-size: 26rpx;
|
|
padding: 15rpx 0;
|
|
min-width: 220rpx;
|
|
text-align: center;
|
|
|
|
border-radius: 15rpx;
|
|
}
|
|
|
|
.onname {
|
|
margin-top: 50rpx;
|
|
}
|
|
</style> |