当前位置:   article > 正文

uni-app 实现6位数字密码键盘页面_uni-app6位支付密码输入框

uni-app6位支付密码输入框

HTML 代码: 

  1. <template>
  2. <view class="password-set-page">
  3. <cu-custom is-back></cu-custom>
  4. <view class="margin text-xl text-right">
  5. <text>跳过</text>
  6. </view>
  7. <view class="text-xxl text-center text-bold margin-top-xl">设置支付密码</view>
  8. <view class="text-df text-center text-gray margin-tb">请设置支付密码,保障您的账户安全</view>
  9. <view class="code flex align-center justify-center" style="margin-top: 10vh;">
  10. <view class="flex align-center justify-center">
  11. <view v-for="(item, index) in 6" :key="index">{{ password[index] && '●' || '' }}</view>
  12. </view>
  13. </view>
  14. <view class="keyboard flex flex-wrap">
  15. <button v-for="(item, index) in 9" :key="index" @click="key(index + 1)">
  16. <text>{{ index + 1 }}</text>
  17. </button>
  18. <button class="hide"></button>
  19. <button @click="key(0)">
  20. <text>0</text>
  21. </button>
  22. <button @click="del()">
  23. <image src="/static/images/icon/icon-keyboard-delete.png" mode="aspectFill"></image>
  24. </button>
  25. </view>
  26. </view>
  27. </template>

JS 代码:

  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. password: ''
  6. }
  7. },
  8. methods: {
  9. key(key) {
  10. if (this.password.length < 6) {
  11. this.password += key
  12. if (this.password.length === 6) {
  13. // 密码验证操作
  14. }
  15. }
  16. },
  17. del() {
  18. if (this.password.length > 0) {
  19. this.password = this.password.substring(0, this.password.length - 1)
  20. }
  21. }
  22. }
  23. }
  24. </script>

SCSS 代码

  1. <style lang="scss">
  2. page {
  3. background: #FFFFFF;
  4. }
  5. .password-set-page {
  6. .code {
  7. >view {
  8. border: 1px solid #DDDDDD;
  9. border-radius: 8rpx;
  10. overflow: hidden;
  11. view {
  12. display: flex;
  13. align-items: center;
  14. justify-content: center;
  15. width: 100rpx;
  16. height: 100rpx;
  17. background: #FAFAFA;
  18. font-size: 60rpx;
  19. &:not(:last-child) {
  20. border-right: 1px solid #DDDDDD;
  21. }
  22. }
  23. }
  24. }
  25. .keyboard {
  26. position: fixed;
  27. bottom: 0;
  28. width: 100%;
  29. background: #EEEEEE;
  30. button {
  31. display: flex;
  32. align-items: center;
  33. justify-content: center;
  34. width: calc(100vw / 3 - 1px);
  35. background: #FFFFFF;
  36. border-radius: 0;
  37. margin-top: 1px;
  38. font-size: 50rpx;
  39. height: 120rpx;
  40. &.button-hover:not(.hide) {
  41. background: #EEEEEE;
  42. }
  43. image {
  44. width: 52rpx;
  45. height: 38rpx;
  46. }
  47. }
  48. }
  49. }
  50. </style>

 

版权属于:瞭月

本文链接:uni-app 实现6位数字密码键盘页面 - 瞭月

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/887939
推荐阅读
相关标签
  

闽ICP备14008679号