金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
1.8 KiB

  1. <template>
  2. <view>
  3. <view class="action">
  4. <view class="pwd" @click="changeStatus">
  5. <view v-for="(item,index) in unit"
  6. :class="{pwd1:pwd.length>=(index+1), 'docus-border': (pwd.length == index) && inputStatus}"
  7. class="number">
  8. </view>
  9. </view>
  10. </view>
  11. <view class="input1">
  12. <input :maxlength="unit"
  13. @input="change1"
  14. v-model="pwd"
  15. v-show="true"
  16. type="number"
  17. :focus="inputStatus"
  18. @blur="inputStatus = false"
  19. @focus="inputStatus = true"
  20. />
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. props:{
  27. unit:{
  28. type:Number,
  29. default:6
  30. },
  31. focus:{
  32. type:Boolean,
  33. default:false
  34. },
  35. ontime:{
  36. type:Boolean,
  37. default:false
  38. }
  39. },
  40. data(){
  41. return {
  42. inputStatus: this.focus,
  43. pwd:"",
  44. pwd1:[]
  45. }
  46. },
  47. methods:{
  48. changeStatus(){
  49. this.inputStatus=!this.inputStatus
  50. },
  51. change1(e){
  52. this.pwd1=String(e.target.value).split('')
  53. if(this.ontime){
  54. this.$emit('change',e.target.value)
  55. }else{
  56. if(this.pwd1.length==this.unit){
  57. this.$emit('change',e.target.value)
  58. }
  59. }
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .action{
  66. width:686rpx;
  67. margin: 0 auto;
  68. .pwd{
  69. width:100%;
  70. height: 100rpx;
  71. margin: 20rpx auto;
  72. display: flex;
  73. margin-bottom: 40rpx;
  74. justify-content: space-between;
  75. .number{
  76. height: 100%;
  77. display: flex;
  78. justify-content: center;
  79. align-items: center;
  80. width: 100rpx;
  81. position: relative;
  82. border: 1rpx solid #979797;
  83. border-radius: 5rpx;
  84. }
  85. .pwd1{
  86. &::after{
  87. position: absolute;
  88. content: "";
  89. width: 20rpx;
  90. height: 20rpx;
  91. border-radius: 50%;
  92. background-color: #000;
  93. }
  94. }
  95. .docus-border{
  96. border: 4rpx solid #15716E;
  97. }
  98. }
  99. }
  100. .input1{
  101. width: 0;
  102. height: 0;
  103. overflow: hidden;
  104. }
  105. </style>