wepy2 小程序 密码弹框 验证码弹框 模拟聚焦

本文介绍如何在微信小程序中实现密码弹框和验证码弹窗,并自动弹出数字键盘,展示带有光标闪烁效果的输入验证码组件。通过在父组件中隐藏一个数字输入框来达到模拟聚焦的效果。
摘要由CSDN通过智能技术生成

需求:小程序中手机获取验证码后,自动弹出数字键盘,弹出输入验证码弹窗并且有光标闪烁效果

验证码弹窗组件:

<template>
<van-popup custom-style="border-radius:4px;height:460rpx;top:30%" show="{
  {showPayPwdInput}}" close-on-click-overlay="{
  {false}}" closeable bind:close="closeFn">
  <div class="code">
    <div class="input_main">
      <div class="input_tip">
        <p class="input_tip_tit">输入短信验证码</p>
        <span class="input_tip_content">验证码已发送至{
  {phoneNumber}}</span>
      </div>
      <div class="input_row" @tap="$emit('payFocus')">
        <div class="pwd_item" v-for="(item,index) in 4" :key="index" :class="{'get_focus':(value_length == index) && payFocus}">
          <div v-if="(value_length == index) && payFocus" class="cursor"></div>
          <div v-if="(value_length >= index-1)">{
  {val_arr[index]}}</div>
        </div>
      </div>
      <p v-if="isSendCode" class="input_code">{
  {time}}s后可重新获取</p>
        <p v-else class="forget_pwd" @tap="$emit('resend')">重新发送</p>
      
    </div>
  </div>
</van-popup>

</template>
<config>
{
  "navigationBarTitleText": "授权登录",
  "usingComponents": {
    "van-popup": "~@vant/popup/index",
  }
}
</config>>
<script>
import wepy from '@wepy/core';

wepy.component({
  props: {
    payFocus: {
      type: Boolean,
      default: () => {
        return []
      }
    },
    val_arr: {
      type: Array,
      default: () => {
        return []
      }
    },
    value_length: {
      type: String
    },
    showPayPwdInput: {
      type: Boolean,
      default: false
    },
    phoneNumber: {
      type: Number
    },
    countDown: {
      type: Number,
      default: 60
    }
  },
  data: {
    timeout: null,
    time: 60,
    isSendCode: true // 是否已经发送验证码
  },
  watch: {
    countDown(val) {
      if (val > 0) this.isSendCode = true
      if (val === 60) {
        this.timeDown(val)
      }
    }
  },
  methods: {
    closeFn() {
      this.$emit('closeFn', this.isSendCode ? this.time : null);
    },
    // 倒计时
    timeDown(time) {
      this.timeout = setInter
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值