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.

140 lines
2.6 KiB

<template>
<view class="checkCode">
<view class="back-btn" @click="closeModal">
<image src="@/static/icons/left_back@3x.png"></image>
</view>
<view class="wrapper">
<view class="tips">
<view class="tips_title">{{tips.title}}</view>
<view class="tips_text">{{tips.text}} {{data.area}} {{data.mobile}}</view>
</view>
<view class="numBox">
<uni-code-input v-model="data.mobileCheckCode" mode="line" :space="12" :focus="true" borderColor="rgba(0, 0, 0, 0.1)"
hairline :maxlength="6" @finish="finish"></uni-code-input>
</view>
<view class="cutdownBox">
<view v-if="time>0" class="time">{{time}}s</view>
<view v-else @click="regetCode" class="regetBtn"></view>
</view>
</view>
</view>
</template>
<script>
// import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import uniCodeInput from '@/components/uni-code-input/uni-code-input.vue';
export default {
name: 'CheckCode',
components: {
uniCodeInput
// uniLoadMore
},
data() {
return {
tips: {
title: '输入验证码',
text: '验证码已发送至'
},
time: 60,
resetTime: 60,
timer: null,
}
},
props: {
data: {
default: () => {},
type: Object,
}
},
mounted() {
this.cutdown()
},
destroyed() {
this.timer && clearInterval(this.timer)
},
methods: {
closeModal() {
this.$emit('closeModal', 'code');
},
cutdown() {
this.timer && clearInterval(this.timer)
this.timer = setInterval(
() => {
this.time--
}, 1000)
},
regetCode() {
// 调用接口
this.time = this.resetTime
this.cutdown()
this.$emit('regetCode')
},
finish(e) {
console.log('输入结束,当前值为:' + e);
this.$emit('login', this.data)
}
}
}
</script>
<style lang="scss" scoped>
.checkCode {
width: 100vw;
height: 100vh;
position: relative;
.back-btn {
position: absolute;
left: 40upx;
padding-top: var(--status-bar-height);
top: 40upx;
font-size: 40upx;
color: $font-color-dark;
z-index: 9;
image {
width: 40rpx;
height: 40rpx;
}
}
.wrapper {
position: relative;
padding-top: 200upx;
.tips {
width: 100%;
height: 136upx;
padding: 0 48rpx;
.tips_title {
font-size: 64upx;
margin-bottom: 26upx;
}
.tips_text {
font-size: 28upx;
}
}
.numBox {
height: 80rpx;
margin: 80rpx 0 0;
display: flex;
justify-content: center;
}
.cutdownBox {
height: 40rpx;
padding: 48rpx;
color: rgba(0, 0, 0, .95);
.time {
color: rgba(0, 0, 0, .4)
}
}
}
}
</style>