Files
appointment_weapp/pages/my/setup/phone.vue
2024-03-21 15:43:18 +08:00

249 lines
5.9 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="Box">
<!-- <view class="Box_one">设置新手机</view>
<view class="Box_T">设置新手机号需要通过短信验证</view>
<view class="Box_there">当前手机号{{ form.mobile.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.mobile" 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="请输入短信验证码" />
<view 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>
</view>
</view>
<view class="agreement flex-start">
<u-checkbox-group><u-checkbox shape="circle" @change="radioChange"
size="12"></u-checkbox></u-checkbox-group>
<text>阅读并同意银收客预约</text>
<view class="agreement-Item" @click="Privacy(1)">用户协议</view>
<view class="agreement-Item" @click="Privacy(2)">隐私政策</view>
</view>
<view class="flex-colum">
<view class="Box_bottom" @click="userInfochangePhone">确定</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
radioChangeItem: false, //单选框
form: {
mobile: '',
code: '',
oldPhone: '',
password: ''
},
// 注册定时器 初始值
second: 60,
showText: true,
Recapture: '发送验证码'
};
},
onLoad() {},
computed: {},
methods: {
async CodeRegister() {
//发起验证码
if (this.form.mobile == null || this.form.mobile == '') {
uni.showToast({
title: '请输入电话号码',
icon: 'none'
});
return false;
}
const res = await this.api.smssend({
// post 手机验证码
mobile: this.form.mobile,
event: 'binding'
});
console.log(res);
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);
},
radioChange(n) {
//是否同意
this.radioChangeItem = n;
},
async Privacy(e) {
let res = await this.api.useruserpolicy();
if (e == 1) {
//用户协议
uni.pro.navigateTo('webview/html', {
src: res.agreement
});
} else {
uni.pro.navigateTo('webview/html', {
src: res.policy
});
}
},
async userInfochangePhone() {
if (this.form.mobile == null || this.form.mobile == '') {
uni.showToast({
title: '请输入电话号码',
icon: 'none'
});
return false;
}
if (this.form.code == null || this.form.code == '') {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return false;
}
if (this.radioChangeItem == false) {
uni.showToast({
icon: 'none',
title: '请先阅读《用户协议》和《隐私政策》'
});
return;
}
let res = await this.api.userbindingphone({
captcha: this.form.code,
mobile: this.form.mobile,
event: 'binding'
});
if (res) {
uni.showToast({
title: '成功',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack()
}, 1000);
}
}
}
};
</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;
}
}
.agreement {
margin-top: 14rpx;
font-size: 20rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN;
font-weight: 500;
color: #7c8e97;
.agreement-Item {
color: #4ca1fc;
}
}
.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>