• 微信小程序(四十五)登入界面-简易版


    注释很详细,直接上代码

    上一篇

    此文使用了vant组件库,没有安装配置的可以参考此篇vant组件的安装与配置

    新增内容:
    1.基础组件的组合
    2.验证码倒计时的逻辑处理

    源码:

    app.json

    {
      "usingComponents": {
        "van-field": "@vant/weapp/field/index",
        "van-count-down": "@vant/weapp/count-down/index",
        "van-button": "@vant/weapp/button/index"
      },
      "pages": [
        "pages/index/index"
      ],
      "window": {
        "navigationBarTextStyle": "black",
        "navigationBarTitleText": "Weixin",
        "navigationBarBackgroundColor": "#ffffff"
      },
      "componentFramework": "glass-easel",
      "sitemapLocation": "sitemap.json",
      "lazyCodeLoading": "requiredComponents"
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    index.wxml

    <view class="login-header">
      <view class="label">用户登入view>
    view>
    <view class="login-form">
      <van-cell-group>
      
        <van-field placeholder="请输入手机号码" type="number" maxlength="{{11}}" use-slot placeholder-style="color: #999999;">
          
          <view wx:if="{{!countDownVisble}}" slot="button">
            <van-button size="small" type="primary" bind:tap="sendCode">
              发送验证码
            van-button>
          view>
          
          <view slot="right-icon" wx:else style="margin-top: -20rpx;">
            
            
            <van-count-down use-slot time="{{60*1000}}" bind:change="countDownChange">
              <text style="color: #999999; ">
                {{timeData.seconds}}秒后重新获取
              text>
            van-count-down>
          view>
        van-field>
    
        <van-field placeholder="请输入6位数验证码" maxlength="{{6}}" placeholder-style="color:#999999" />
      van-cell-group>
    
      <view class="login-tip">未注册的手机号验证后将自动注册view>
    view>
    
    
    <button size="mini" style="margin:30rpx 0 0 300rpx; background-color: palegreen; padding: 0 50rpx;">登入button>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40

    index.wxss

    .label{
      font: 1em SimHei;
      font-size: 50rpx;
      margin: 60rpx 0 50rpx 30rpx;
    }
    
    .login-tip{
      margin: 20rpx 0 90rpx 30rpx;
      color: #dadada;
      font-size: 27rpx;
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    index.js

    Page({
      data:{
        countDownVisble:false,//是否显示倒计时
        timeData: {}//时间数据
      },
      //发送验证码
      sendCode(){
        this.setData({
          countDownVisble:true
        })
      },
      //倒计时变化
      countDownChange(ev){
        //console.log(ev)
        this.setData({
          //倒计时组件数据
          timeData:ev.detail,
          //倒计时是否显示判断
          countDownVisble:ev.detail.minutes===1||ev.detail.seconds>0
        })
      }
    })
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    效果演示:(更加完善的会后续更新)

    在这里插入图片描述

  • 相关阅读:
    《文化相对论》:危机重重的世界,对话才能产生转机
    FFT专题:IFFT后信号如何重建
    php获取文件后缀名的几种方法
    【从零单排Golang】第六话:基于wire的kratos示例项目
    线上kafka消息堆积,consumer掉线,怎么办?
    【Unity3D日常开发】Unity3D中打包WEBGL后读取本地文件数据
    后端开发工程师开发规范
    面对网络渠道低价 品牌如何应对
    async-validator 源码学习(一):文档翻译
    STM32实现霍夫圆检测
  • 原文地址:https://blog.csdn.net/m0_73756108/article/details/136289172