uniapp自定义密码输入键盘-数字键盘效果demoUI方法二(整理)

简介: uniapp自定义密码输入键盘-数字键盘效果demoUI方法二(整理)

效果图:

<template>
  <view class="paymentCodeBox">
    <!-- 自定义键盘 -->
    <view class="password-set-page">
      <view class="setPage">
        <view class="hint margin-bottom30 height110 width100Percent font-size32 color222 font-bold">
          输入支付密码
          <view class="width50 height50 imgClose" @click="closeClick()">
            <image src="../static/goods/close.png" mode="" class="width50 height50"></image>
          </view>
        </view>
        <view class="code margin-bottom30">
          <view class="numFont">
            <view v-for="(item, index) in 6" :key="index">{{ password[index] && '●' || '' }}</view>
          </view>
        </view>
        <view class="slipBox dis_f margin-left30 margin-right30 margin-bottom80">
          <view class="font-size24 colorccc">忘记支付密码或没有设置支付密码?</view>
          <view class="dis_f goto">
            <text class="margin-right10 font-size24" style="color: #F21177;">去修改支付密码</text>
            <view class="imgBox">
              <image src="../static/goods/tz2.png" mode="" class="img"></image>
            </view>
          </view>
        </view>
        <view class="keyboard">
          <button v-for="(item, index) in 9" :key="index" @click="key(index + 1)">
            <text>{{ index + 1 }}</text>
          </button>
          <button class="hide"></button>
          <button @click="key(0)">
            <text>0</text>
          </button>
          <button @click="del()">
            <!-- <image src="../static/enter/btn_xuanzhong.png" mode="aspectFill"></image> -->
            <image src="../static/goods/del1.png" mode="aspectFill"></image>
          </button>
        </view>
      </view>
    </view>
  </view>
</template>
<script>
  export default {
    components: {},
    data() {
      return {
        // pageNum: 1,
        password: '',
      }
    },
    // 页面加载
    onLoad(e) {
      uni.hideTabBar(); //不让底部显示tab选项
    },
    // 页面显示
    onShow() {
    },
    // 方法
    methods: {
      //关闭键盘
      closeClick(){
        this.password = '';
        this.KeypadShow = 0;
      },
      // 键盘
      key(key) {
        if (this.password.length < 6) {
          this.password += key
          if (this.password.length === 6) {
            // 密码验证操作
            console.log(this.password,'37')
            // this.$.open('/trait/details');
          }
        }
      },
      del() {
        if (this.password.length > 0) {
          this.password = this.password.substring(0, this.password.length - 1)
        }
      },
      //获取列表数据
      getListData() {
        this.$.ajax("POST", "/xxxxx/xxxxx", {
          page: this.pageNum,
        }, (res) => {
          if (res) {
            if (this.pageNum == 1) {
              this.list = res.data
            } else {
              this.list = this.list.concat(res.data)
              if (res.data.length === 0) {
                this.pageNum--
              }
            }
          }
          uni.stopPullDownRefresh()
        });
      }
    },
    // 计算属性
    computed: {
    },
    // 侦听器
    watch: {
    },
    // 页面隐藏
    onHide() {
    },
    // 页面卸载
    onUnload() {
    },
    // 触发下拉刷新
    onPullDownRefresh() {
      // this.pageNum = 1
      // this.getListData()
    },
    // 页面上拉触底事件的处理函数
    onReachBottom() {
      // this.pageNum++
      // this.getListData()
    },
  }
</script>
<style lang="scss" scoped>
  .paymentCodeBox {
    width: 100%;
    height: 100vh;
    background: #fff;
    .password-set-page {
      position: fixed;
      bottom: 0;
      width: 100%;
      height: 100vh;
      overflow: hidden;
      background-color: rgba(0, 0, 0, .5);
      z-index: 999999;
      .setPage{
        position: fixed;
        bottom: 0;
        background: #fff;
        border-radius: 20rpx 20rpx 0px 0px;
        .hint{
          line-height: 110rpx;
          position: relative;
          text-align: center;
          border-bottom: 1rpx solid #ECECEC;
          .imgClose{
            position: absolute;
            right: 20rpx;
            top: 26rpx;
          }
        }
      }
      .slipBox{
        display: flex;
        justify-content: space-between;
        .goto{
          align-items: center;
          .imgBox{
            width: 9rpx;
            height: 16rpx;
            .img{
              width: 9rpx;
              height: 16rpx;
            }
          }
        }
      }
      .code {
        view {
          // border: 1rpx solid #D9D9D9;
          border-radius: 8rpx;
          overflow: hidden;
          display: flex;
          width: 690rpx;
          margin: 0 auto;
          view {
            display: flex;
            align-items: center;
            justify-content: center;
            // width: 100rpx;
            height: 100rpx;
            // background: #FAFAFA;
            font-size: 60rpx;
            border: 1rpx solid #D9D9D9;
            &:not(:last-child) {
              border-right: 1rpx solid #D9D9D9;
            }
          }
        }
      }
      .keyboard {
        width: 100%;
        background: #EEEEEE;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        button {
          display: flex;
          align-items: center;
          justify-content: center;
          width: calc(100vw / 3 - 1rpx);
          background: #FFFFFF;
          border-radius: 0;
          margin-top: 1rpx;
          font-size: 50rpx;
          height: 120rpx;
          &.button-hover:not(.hide) {
            background: #EEEEEE;
          }
          image {
            width: 52rpx;
            height: 38rpx;
          }
        }
      }
    }
  }
</style>
相关文章
|
4月前
|
数据处理 开发者
【Uniapp 专栏】提升 Uniapp 开发效率的进阶方法
【5月更文挑战第17天】提升Uniapp开发效率的关键包括组件化、模板语法、数据处理和代码组织。通过封装组件如通用按钮,利用列表渲染生成多个元素,使用计算属性和方法处理复杂逻辑,以及采用预处理器如Sass编写样式。此外,良好的代码结构和使用开发者工具进行调试也是重要环节。掌握这些进阶技巧能帮助开发者更高效地构建高质量应用。
90 2
【Uniapp 专栏】提升 Uniapp 开发效率的进阶方法
|
2月前
|
安全
uniapp实战 —— 自定义顶部导航栏
uniapp实战 —— 自定义顶部导航栏
79 2
|
2月前
uniapp实战 —— 弹出层 uni-popup (含vue3子组件调父组件的方法)
uniapp实战 —— 弹出层 uni-popup (含vue3子组件调父组件的方法)
242 1
|
2月前
uniapp实战 —— 轮播图【自定义指示点】(含组件封装,自动注册全局组件,添加全局组件类型声明)
uniapp实战 —— 轮播图【自定义指示点】(含组件封装,自动注册全局组件,添加全局组件类型声明)
67 1
|
2月前
uniapp 添加自定义图标
uniapp 添加自定义图标
95 0
|
2月前
|
前端开发 JavaScript 索引
uniapp的u-album组件自定义删除功能
这样,你就可以在u-album组件中实现自定义的删除功能了。需要注意的是,这个删除操作只是在前端删除了图片项,并没有在后端删除对应的图片文件,如果你需要在后端也删除对应的图片文件,你还需要在删除操作后发送一个请求到后端,让后端删除对应的图片文件。
63 0
|
4月前
|
Web App开发 移动开发 文字识别
Uniapp或H5之ORC识别与自定义照相机
Uniapp或H5之ORC识别与自定义照相机
398 3
|
4月前
|
移动开发 小程序 API
uniapp组件库Line 线条 的适用方法
uniapp组件库Line 线条 的适用方法
202 0
|
4月前
|
移动开发 小程序 iOS开发
uniapp组件库fullScreen 压窗屏的适用方法
uniapp组件库fullScreen 压窗屏的适用方法
133 1
|
4月前
|
JavaScript API
uniapp中路由拦截方法
uniapp中路由拦截方法
304 0