Files
app-govern/pages/user/changePhone.vue

189 lines
6.2 KiB
Vue
Raw Normal View History

2023-01-13 16:32:56 +08:00
<template>
<Cn-page :loading="loading">
<view slot="body">
<view class="index">
<template v-if="step == 1">
2023-03-20 08:51:21 +08:00
<uni-forms ref="form" :rules="rules" :modelValue="formData">
2023-01-13 16:32:56 +08:00
<uni-forms-item name="phone">
2023-03-20 08:51:21 +08:00
<uni-easyinput disabled type="text" v-model="formData.phoneShow" placeholder="请输入手机号" />
2023-01-13 16:32:56 +08:00
</uni-forms-item>
<uni-forms-item name="code">
2023-03-20 08:51:21 +08:00
<view class="login-box-input">
2023-01-13 16:32:56 +08:00
<uni-easyinput type="number" v-model="formData.code" placeholder="请输入验证码" />
<view class="ml40"
style="margin-left:40rpx;font-size: 28rpx; color: #666; width: 200rpx; text-align: center"
v-if="waitTime > 0">{{ waitTime + 's后重新获取' }}</view>
2023-03-20 08:51:21 +08:00
<button class="login-box-input-btn" v-else @click="getCode(5)" size="mini">获取验证码</button>
2023-01-13 16:32:56 +08:00
</view>
</uni-forms-item>
</uni-forms>
<button type="default" class="submit-btn" @click="firstSubmit">下一步</button>
</template>
<template v-else>
2023-03-20 08:51:21 +08:00
<uni-forms ref="form" :rules="rules" :modelValue="formData">
2023-01-13 16:32:56 +08:00
<uni-forms-item name="phone">
<uni-easyinput type="number" v-model="formData.phone2" placeholder="请输入新手机号" />
</uni-forms-item>
<uni-forms-item name="code">
2023-03-20 08:51:21 +08:00
<view class="login-box-input">
2023-01-13 16:32:56 +08:00
<uni-easyinput type="number" v-model="formData.code" placeholder="请输入验证码" />
<view class="ml40"
style="margin-left:40rpx;font-size: 28rpx; color: #666; width: 200rpx; text-align: center"
v-if="waitTime > 0">{{ waitTime + 's后重新获取' }}</view>
2023-03-20 08:51:21 +08:00
<button class="login-box-input-btn" v-else @click="getCode(4)" size="mini">获取验证码</button>
2023-01-13 16:32:56 +08:00
</view>
</uni-forms-item>
</uni-forms>
<button type="default" class="submit-btn" @click="secondSubmit">提交</button>
</template>
</view>
</view>
</Cn-page>
</template>
<script>
export default {
name: "jiaban",
data () {
return {
step: 1,
loading: false,
waitTime: 0,
// 表单数据
formData: {
2023-03-20 08:51:21 +08:00
phone: '',
phoneShow: '',
2023-01-13 16:32:56 +08:00
code: '',
phone2: '',
code2: '',
},
rules: {
phone: {
rules: [
{
required: true,
errorMessage: "请填写手机号"
}
]
},
code: {
rules: [
{
required: true,
errorMessage: "请填写验证码"
}
]
},
2023-03-20 08:51:21 +08:00
phone2: {
2023-01-13 16:32:56 +08:00
rules: [
{
required: true,
2023-03-20 08:51:21 +08:00
errorMessage: "请填写新手机号"
2023-01-13 16:32:56 +08:00
}
]
},
2023-03-20 08:51:21 +08:00
code2: {
2023-01-13 16:32:56 +08:00
rules: [
{
required: true,
2023-03-20 08:51:21 +08:00
errorMessage: "请填写验证码"
2023-01-13 16:32:56 +08:00
}
]
}
}
};
},
onLoad () {
2023-03-20 08:51:21 +08:00
this.init()
2023-01-13 16:32:56 +08:00
},
methods: {
2023-03-20 08:51:21 +08:00
getCode (type) {
if (!this.formData.phone) {
return this.$util.toast('请输入手机号!')
}
uni.showLoading({
title: '请稍等'
})
apiGetYms({
phone: this.formData.phone,
type,
}).then(res => {
uni.hideLoading()
console.log(res);
this.waitTime = 60
this.inter = setInterval(() => {
if (this.waitTime == 0) {
clearInterval(this.inter)
} else {
this.waitTime--
}
}, 1000)
}).catch(err => {
uni.hideLoading()
console.log(err);
})
},
init () {
this.formData.phone = uni.getStorageSync('userInfo').phone
// 150****0083
this.formData.phoneShow = this.formData.phone.substr(0, 3) + '****' + this.formData.phone.substr(7)
2023-01-13 16:32:56 +08:00
},
firstSubmit () {
this.step = 2
},
secondSubmit () {
uni.navigateBack({ delta: 1 })
}
}
};
</script>
<style lang="scss">
.index {
2023-02-20 14:19:28 +08:00
padding: 20rpx;
2023-01-13 16:32:56 +08:00
.submit-btn {
background: $uni-theme-blue;
color: #fff;
}
.login-box-tips {
margin-top: 60rpx;
display: flex;
justify-content: center;
font-size: 20rpx;
}
.login-box-input {
display: flex;
align-items: center;
border-bottom: 1rpx solid #f0f0f0;
.login-box-input-icon {
width: 40rpx;
margin-right: 40rpx;
}
.login-box-input-main {
font-size: 28rpx;
flex: 1;
height: 100rpx;
line-height: 100rpx;
}
.login-box-input-btn {
width: 200rpx;
margin-left: 40rpx;
background: $uni-theme-blue;
color: #fff;
}
.login-box-input-img {
margin-left: 40rpx;
background: skyblue;
height: 80rpx;
width: 200rpx;
}
}
}
</style>