vCode.vue 2.4 KB

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