code.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="wrap">
  3. <view class="key-input">
  4. <view class="title">输入验证码</view>
  5. <view class="tips">验证码已发送至 +150****9320</view>
  6. <u-message-input :focus="true" :value="value" @change="change" @finish="finish" mode="bottomLine" :maxlength="maxlength"></u-message-input>
  7. <text :class="{ error: error }">验证码错误,请重新输入</text>
  8. <view class="captcha">
  9. <text :class="{ noCaptcha: show }" @tap="noCaptcha">收不到验证码点这里</text>
  10. <text :class="{ regain: !show }">{{ second }}秒后重新获取验证码</text>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. maxlength: 4,
  20. value: '',
  21. second: 3,
  22. show: false,
  23. error: false
  24. };
  25. },
  26. computed: {},
  27. onLoad() {
  28. // this.getCaptcha()
  29. let interval = setInterval(() => {
  30. this.second--;
  31. if (this.second <= 0) {
  32. this.show = true;
  33. if (this.value.lenth != 4) {
  34. this.error = true;
  35. }
  36. clearInterval(interval);
  37. }
  38. }, 1000);
  39. },
  40. methods: {
  41. // 收不到验证码选择时的选择
  42. noCaptcha() {
  43. uni.showActionSheet({
  44. itemList: ['重新获取验证码', '接听语音验证码'],
  45. success: function(res) {
  46. },
  47. fail: function(res) {
  48. }
  49. });
  50. },
  51. // change事件侦听
  52. change(value) {
  53. // console.log('change', value);
  54. },
  55. // 输入完验证码最后一位执行
  56. finish(value) {
  57. // console.log('finish', value);
  58. }
  59. }
  60. };
  61. </script>
  62. <style lang="scss" scoped>
  63. .wrap {
  64. padding: 80rpx;
  65. }
  66. .box {
  67. margin: 30rpx 0;
  68. font-size: 30rpx;
  69. color: 555;
  70. }
  71. .key-input {
  72. padding: 30rpx 0;
  73. text {
  74. display: none;
  75. }
  76. .error {
  77. display: block;
  78. color: red;
  79. font-size: 30rpx;
  80. margin: 20rpx 0;
  81. }
  82. }
  83. .title {
  84. font-size: 50rpx;
  85. color: #333;
  86. }
  87. .key-input .tips {
  88. font-size: 30rpx;
  89. color: #333;
  90. margin-top: 20rpx;
  91. margin-bottom: 60rpx;
  92. }
  93. .captcha {
  94. color: $u-type-warning;
  95. font-size: 30rpx;
  96. margin-top: 40rpx;
  97. .noCaptcha {
  98. display: block;
  99. }
  100. .regain {
  101. display: block;
  102. }
  103. }
  104. </style>