原生微信小程序-两次设置支付密码校验,密码设置二次确认

效果

在这里插入图片描述

具体代码

1、wxml

<view style="{{themeColor}}">
  <view class='container'>
    <view class="password_content">
      <view wx:if='{{type == 1}}'>
        <view class="title">
          <view class="main_title">设置支付密码</view>
          <view class="sub_title">请设置支付密码,用于支付验证</view>
        </view>
        <input bindinput="getCode" class="input-number" type="number" focus="{{isFocus}}" maxlength="6" />
      </view>
      <view wx:if='{{type == 2}}'>
        <view class="title">
          <view class="main_title">设置支付密码</view>
          <view class="sub_title">请再次设置支付密码,用于支付验证</view>
        </view>
        <input bindinput="getCode" class="input-number" type="number" focus="{{isFocus}}" maxlength="6" />
      </view>
      <view class="code-box" bindtap="getFocus">
        <view class="input-box">{{code[0]}}</view>
        <view class="input-box">{{code[1]}}</view>
        <view class="input-box">{{code[2]}}</view>
        <view class="input-box">{{code[3]}}</view>
        <view class="input-box">{{code[4]}}</view>
        <view class="input-box">{{code[5]}}</view>
      </view>
    </view>
  </view>
</view>

2、js


import request from '../../../utils/request'
const app = getApp()
Page({
  data: {
    type: 1, //默认第一次输入密码
    onePassdWord: '', //请输入密码
    twoPassdWord: '', //再次输入密码
    themeColor: app.globalData.themeColor
  },

  onLoad(query) {
  },

  onShow() {
    wx.setNavigationBarColor({
      backgroundColor: app.globalData.color,
      frontColor: '#ffffff'
    })
  },
  getFocus() {
    console.log('this.data.type--getFocus', this.data.type);
    this.setData({
      isFocus: true,
    });
  },
  // 获取输入数字
  getCode(e) {
    const type = this.data.type;
    const passdWord = e.detail.value; //获取到的密码
    this.setData({
      code: e.detail.value
    });
    console.log('获取输入数字', this.data.code)
    // 获取输入框值的长度
    let value_length = e.detail.value.length;
    if (value_length == 6) {
      console.log(666, passdWord, type);
      if (type == 1) {
        console.log(5555, type);
        this.setData({
          type: 2,
          code: '',
          isFocus: true,
          onePassdWord: passdWord,
        })
      } else {
        console.log(888, type);
        this.setData({
          twoPassdWord: passdWord,
        })
      }
      // console.log(999, this.data.onePassdWord, this.data.twoPassdWord);
      if (this.data.onePassdWord.length == 6 && this.data.twoPassdWord.length == 6) {
        if (this.data.onePassdWord === this.data.twoPassdWord) {
          this.upPaymentPassword()
          // console.log('两次密码一样');
        } else {
          wx.showToast({
            title: '两次密码不一致,请重新设置。',
            icon: 'error',
            duration: 2000
          })
          this.setData({
            type: 1,
            code: '',
            onePassdWord: '',
            twoPassdWord: '',
            isFocus: true,
          })
        }
      }
    }
  },
  async upPaymentPassword() {
    const res = await request('******', 'POST', { password: this.data.twoPassdWord })
    if (res.success) {
      wx.showToast({
        title: '密码设置成功',
        icon: 'success',
        duration: 2000
      })
      wx.redirectTo({ url: `/subpackages/withdraw/index` });
    }
  }
});

3、wxss

page {
  box-sizing: border-box;
  height: 100%;
  background-color: #f7f8fa;
}

.container {
  width: 100%;
  height: 100%;
  color: #000;
}

.container .password_content {
  text-align: center;
  margin-top: 160rpx;
}

.container .password_content .title {
  text-align: center;
}

.password_content .title .main_title {
  font-size: 40rpx;
  text-align: center;
  font-weight: bold;
  margin-bottom: 20rpx;
}

.password_content .title .sub_title {
  font-size: 30rpx;
  text-align: center;
  font-weight: bold;
  margin-bottom: 60rpx;
}

.container .sub-title .btn {
  margin-left: 20rpx;
  color: var(--themeColor);
}

.container .code-box {
  width: 510rpx;
  height: 80rpx;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  justify-content: space-between;
  margin-top: 80rpx;
}

.container .code-box .input-box {
  height: 80rpx;
  width: 80rpx;
  box-sizing: border-box;
  background-color: #e7e7e7;
  text-align: center;
  line-height: 80rpx;
  font-size: 34rpx;
}

.container .input-number {
  opacity: 0;
  position: absolute;
  z-index: -1;
  height: 0rpx;
  width: 0rpx;
}

.container .time-box {
  margin-top: 50rpx;
  text-align: center;
  font-size: 30rpx;
  font-weight: bold;
  color: #000;
}

.container .time-box .regain {
  color: var(--themeColor);
}

.container .time-box .regain-info .time {
  color: var(--themeColor);
}

相关文章

基于ElementUi再次封装基础组件文档


基于ant-design-vue再次封装基础组件文档


vue3+ts基于Element-plus再次封装基础组件文档


http://www.niftyadmin.cn/n/5318099.html

相关文章

树状结构查询 - 华为OD统一考试

OD统一考试 分值&#xff1a; 200分 题解&#xff1a; Java / Python / C 题目描述 通常使用多行的节点、父节点表示一棵树&#xff0c;比如&#xff1a; 西安 陕西 陕西 中国 江西 中国 中国 亚洲 泰国 亚洲 输入一个节点之后&#xff0c;请打印出来树中他的所有下层节点。 …

查询速度提升15倍!银联商务基于 Apache Doris 的数据平台升级实践

本文导读&#xff1a; 在长期服务广大规模商户的过程中&#xff0c;银联商务已沉淀了庞大、真实、优质的数据资产数据&#xff0c;这些数据不仅是银联商务开启新增长曲线的基础&#xff0c;更是进一步服务好商户的关键支撑。为更好提供数据服务&#xff0c;银联商务实现了从 H…

探索媒体查询的世界:适应多种设备的技巧与实践(上)

&#x1f90d; 前端开发工程师&#xff08;主业&#xff09;、技术博主&#xff08;副业&#xff09;、已过CET6 &#x1f368; 阿珊和她的猫_CSDN个人主页 &#x1f560; 牛客高级专题作者、在牛客打造高质量专栏《前端面试必备》 &#x1f35a; 蓝桥云课签约作者、已在蓝桥云…

论文阅读:TinyGPT-V 论文阅读及源码梳理对应

TODO 有待更新 QFormer作用&#xff1f; QFormer来自论文BCLI2工作中&#xff0c;用来弥补Frozen Image encoder和Frozen LLM之间的gap。 基于Bert作为初始化的。 推理结构图 #mermaid-svg-5qFxDUGSPd77On5n {font-family:"trebuchet ms",verdana,arial,sans-ser…

代码随想录 Leetcode707. 设计链表

题目&#xff1a; 代码(首刷看解析 2024年1月11日&#xff09;&#xff1a; class MyLinkedList { private:struct ListNode{int val;ListNode* next;ListNode(int val):val(val),next(nullptr){}};int size;ListNode* dummyHead; public:MyLinkedList() {dummyHead new List…

在Maven中设置JVM系统参数及Java应用调试实例

在Maven中设置JVM系统参数及Java应用调试实例 在进行Java应用程序开发时&#xff0c;我们通常需要配置Maven构建过程中Java虚拟机&#xff08;JVM&#xff09;的额外系统参数&#xff0c;以便进行性能优化、日志配置或远程调试等操作。本文将详细介绍如何在Maven中设置JVM系统…

一个完整的流程表单流转

1.写在前面 一个完整的流程表单审批&#xff08;起表单-->各环节审批-->回退-->重新审批-->完成&#xff09;&#xff0c;前端由Vue2jsElement UI升级为Vue3tsElement Plus&#xff0c;后端流程框架使用Flowable&#xff0c;项目参考了ruoyi-vue-pro(https://gite…

一体机旅游景区污水处理设备工艺说明

一体机旅游景区污水处理设备工艺说明 原水浓度&#xff1a;COD≤500mg/L&#xff0c;BOD≤300mg/L&#xff0c;NH3-N≤40mg/L&#xff0c;超过以上浓度需另行设计。 出水标准&#xff1a;COD≤60mg/L&#xff0c;BOD≤20mg/L&#xff0c;NH3-N≤15mg/L&#xff0c;出水要求如更…