login1.vue 2.5 KB

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