连云港陪玩陪聊
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
3.9 KiB

2 months ago
<template>
<view class="phone">
<view class="titlle">提示</view>
<view class="tips">请输入登录APP的手机号进行认证</view>
<view class="phone-bd">
<view class="item">
<view class="txt">手机号</view>
2 months ago
<input v-model="phone" placeholder="请输入手机号" type="number" />
2 months ago
</view>
<view class="item">
<view class="txt">验证码</view>
2 months ago
<input v-model="code" placeholder="请输入短信验证码" type="number" />
<view class="code" @click="sendCode()">{{count == 60?'获取验证码': count+'s'}}</view>
2 months ago
</view>
</view>
<view class="phone-fd">
2 months ago
<view class="btn" @click="toReg()">确定</view>
2 months ago
</view>
</view>
</template>
<script>
2 months ago
let timer = null;
2 months ago
export default {
data() {
return {
2 months ago
phone: "",
code: "",
count: 60,
isClikc: true
2 months ago
};
},
methods: {
2 months ago
//发送验证码
async sendCode() {
const that = this;
if(!that.phone){
uni.showToast({
icon: "none",
position: "bottom",
title: "手机号不能为空!",
})
return
}
if(!/^1[3456789]\d{9}$/.test(that.phone)){
uni.showToast({
title: '手机号格式不能为空!',
position: "bottom",
icon: "none",
})
return ;
}
if(that.isClick == false){
return ;
}
const { code, data, msg } = await that.$api.sendSmsCode({
phone: that.phone
});
if(code == 200){
that.isClick = false;
timer = setInterval(()=>{
if(that.count == 0){
clearInterval(timer);
that.count = 60;
that.isClick = true;
}else{
that.count --
}
},1000)
uni.showToast({
icon: "none",
position: "bottom",
title: "发送成功"
})
}else{
that.isClick = true;
}
},
//去登录
async toReg() {
const that = this;
if(!that.phone){
uni.showToast({
icon: "none",
position: "bottom",
title: "手机号不能为空!",
})
return
}
if(!/^1[3456789]\d{9}$/.test(that.phone)){
uni.showToast({
title: '手机号格式不能为空!',
position: "bottom",
icon: "none",
})
return ;
}
if(!that.code){
uni.showToast({
icon: "none",
position: "bottom",
title: "验证码不能为空!",
})
return
}
const {code, data, msg} = await this.$api.phoneAuth({
userId: uni.getStorageSync("userInfo").id,
code: this.code,
phone: this.phone
})
if(code == 200){
uni.showToast({
title: "提交成功"
})
setTimeout(()=>{
uni.navigateBack({
delta: 1
})
},2000)
}else{
uni.showToast({
icon: "none",
position: "bottom",
title: msg
})
}
}
2 months ago
}
}
</script>
<style scoped lang="scss">
.phone{
padding: 25rpx;
overflow: hidden;
.title{
color: #222222;
font-weight: 500;
font-size: 30rpx;
}
.tips{
font-weight: 500;
font-size: 24rpx;
color: #999999;
margin-top: 20rpx;
}
&-fd{
width: 100%;
position: fixed;
left: 0;
bottom: 50rpx;
z-index: 22;
.btn{
width: 700rpx;
line-height: 98rpx;
background: linear-gradient(0deg, #000000, #3D3B38);
border-radius: 98rpx;
font-weight: 400;
font-size: 34rpx;
text-align: center;
color: #FFFFFF;
margin: 0 auto;
}
}
&-bd{
width: 100%;
overflow: hidden;
background: #FFFFFF;
padding: 0 30rpx;
box-sizing: border-box;
border-radius: 20rpx;
margin-top: 30rpx;
.item{
display: flex;
align-items: center;
border-top: 1px solid #EAEAEA;
padding: 50rpx 0 30rpx;
&:first-child{
border-top-color: #FFFFFF;
}
input{
flex: 1;
font-weight: 400;
font-size: 30rpx;
color: #333;
2 months ago
margin-left: 30rpx;
2 months ago
}
.code{
width: 170rpx;
line-height: 60rpx;
background: #000000;
border-radius: 60rpx;
text-align: center;
font-weight: 500;
font-size: 26rpx;
color: #FFFFFF;
}
}
}
}
</style>