login1.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view>
  3. <fs-gutter bgColor="#fff" height="100rpx"></fs-gutter>
  4. <view class="layout-box" v-if="pageIndex === 0">
  5. <view class="title bold" style="font-size: 27px;">验证手机号</view>
  6. <view style="color: #999999;font-size: 14px;">请输入园区预留手机号,验证您的园区人员身份</view>
  7. <fs-gutter bgColor="#fff" height="100rpx"></fs-gutter>
  8. <fs-form-item>
  9. <fs-field type="number" placeholder="请输入手机号" v-model="phone"></fs-field>
  10. </fs-form-item>
  11. </view>
  12. <view class="layout-box" v-else>
  13. <view class="title bold" style="font-size: 27px;">输入验证码</view>
  14. <view style="color: #999999;">已将验证码发至手机号:{{phone}}</view>
  15. <fs-gutter bgColor="#fff" height="100rpx"></fs-gutter>
  16. <view class="fs-captcha">
  17. <view
  18. class="fs-captcha-item"
  19. :class="{'fs-captcha-item-active': curIndex === index}"
  20. v-for="(item, index) in captchaNo"
  21. :key="index"
  22. @click="handleInput(index)">
  23. {{item}}
  24. </view>
  25. </view>
  26. <fs-keyboard mode="number" v-model="keyboardNum" @change="handleChange"></fs-keyboard>
  27. </view>
  28. <fs-gutter bgColor="#fff" height="100rpx"></fs-gutter>
  29. <fs-captcha
  30. block
  31. :plain="false"
  32. :mobile="phone"
  33. @start="handleNext">
  34. </fs-captcha>
  35. </view>
  36. </template>
  37. <script setup>
  38. import { ref, reactive } from 'vue'
  39. import { useStore } from 'vuex'
  40. const store = useStore()
  41. let pageIndex = ref(0)
  42. let phone = ref('')
  43. const handleNext = () => {
  44. pageIndex.value = 1
  45. }
  46. const captchaNo = ref(new Array(4))
  47. let keyboardNum = ref(true)
  48. let curIndex = ref(0)
  49. const handleChange = (item) => {
  50. const length = captchaNo.value.filter(item => item).length
  51. if (item === 'del') {
  52. if (length >= 1) {
  53. curIndex.value--
  54. captchaNo.value[curIndex.value] = ''
  55. }
  56. } else{
  57. if (length <= captchaNo.value.length - 1) {
  58. captchaNo.value[curIndex.value] = item
  59. curIndex.value++
  60. }
  61. }
  62. if (captchaNo.value.filter(item => item).length === 4) {
  63. store.dispatch('login', {
  64. phone,
  65. code: captchaNo
  66. }).then(res => {
  67. uni.navigateBack()
  68. })
  69. }
  70. }
  71. const handleInput = (index) => {
  72. curIndex.value = index
  73. }
  74. </script>
  75. <style>
  76. page{
  77. background-color: #fff;
  78. }
  79. </style>
  80. <style lang="scss" scoped>
  81. .fs-captcha{
  82. display: flex;
  83. justify-content: center;
  84. align-items: center;
  85. &-item{
  86. width: 120rpx;
  87. height: 80rpx;
  88. line-height: 80rpx;
  89. border-bottom: 2rpx solid #CBCBCB;
  90. text-align: center;
  91. font-size: 18px;
  92. & + &{
  93. margin-left: 40rpx;
  94. }
  95. &-active{
  96. border-color: var(--primary);
  97. }
  98. }
  99. }
  100. </style>