input-password.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="page">
  3. <view>
  4. <view class="pay-title">
  5. <text>{{$t('enter.b3')}}</text>
  6. </view>
  7. <view class="pay-password">
  8. <view class="list" v-for="item in 6">
  9. <text v-show="passwordArr.length >= item">●</text>
  10. </view>
  11. </view>
  12. <navigator url="/pages/user/set/transaction">
  13. <view class="hint">
  14. <text>{{$t('login.b8')}}</text>
  15. </view>
  16. </navigator>
  17. </view>
  18. <cc-defineKeyboard ref="CodeKeyboard" passwrdType="pay" @KeyInfo="KeyInfo" :viewShow="true"></cc-defineKeyboard>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. passwordArr: []
  26. };
  27. },
  28. mounted() {
  29. this.$refs.CodeKeyboard.show();
  30. },
  31. // 关闭循环
  32. methods: {
  33. // 点击触发支付事件
  34. KeyInfo(val) {
  35. console.log(val);
  36. let arr = this.passwordArr;
  37. if (val.index >= 6) {
  38. return;
  39. }
  40. // 判断是否输入的是删除键
  41. if (val.keyCode === 8) {
  42. // 删除最后一位
  43. arr.splice(val.index + 1, 1)
  44. }
  45. // 判断是否输入的是取消案件
  46. else if (val.keyCode == 190) {
  47. this.$emit('colse')
  48. } else {
  49. arr.push(val.key);
  50. }
  51. // 开始交易
  52. if (arr.length == 6) {
  53. this.$emit('commit',this.passwordArr.join(''))
  54. //初始化对象
  55. this.passwordArr = [];
  56. }
  57. },
  58. },
  59. };
  60. </script>
  61. <style lang="scss">
  62. $base: orangered; // 基础颜色
  63. .page {
  64. width: 100%;
  65. background-color: #FFFFFF;
  66. .pay-title {
  67. display: flex;
  68. align-items: center;
  69. justify-content: center;
  70. width: 100%;
  71. height: 200rpx;
  72. text {
  73. font-size: 28rpx;
  74. color: #555555;
  75. }
  76. }
  77. .pay-password {
  78. display: flex;
  79. align-items: center;
  80. width: 90%;
  81. height: 80rpx;
  82. margin: 20rpx auto;
  83. border: 2rpx solid $base;
  84. .list {
  85. color: #555555;
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. width: 16.666%;
  90. height: 100%;
  91. border-right: 2rpx solid #EEEEEE;
  92. text {
  93. font-size: 32rpx;
  94. }
  95. }
  96. .list:nth-child(6) {
  97. border-right: none;
  98. }
  99. }
  100. .hint {
  101. display: flex;
  102. align-items: center;
  103. justify-content: center;
  104. width: 100%;
  105. height: 100rpx;
  106. text {
  107. font-size: 28rpx;
  108. color: $base;
  109. }
  110. }
  111. }
  112. </style>