index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view class="ezy-login-page">
  3. <view class="ezy-login-wrap" >
  4. <!-- 手机号 -->
  5. <view class="login-body-box">
  6. <view class="index-title-img"></view>
  7. <view class="phone-input-box">
  8. <view class="phone-prefix">+86</view>
  9. <input class="phone-input" type="text" v-model="indexData.phoneNumber" placeholder="请输入手机号"
  10. maxlength="11" @input="clearTelInput" />
  11. <view class="close-btn" v-if="indexData.clearTelIcon" @click="clearTel"></view>
  12. </view>
  13. <!-- 协议勾选框和按钮 -->
  14. <view class="agreement-checkbox-box">
  15. <checkbox-group @change="handleAgreementChange">
  16. <checkbox class="agreement-checkbox-input" color="#FFFFFF" value="agree" :checked="indexData.isAgreed"/>
  17. </checkbox-group>
  18. <view class="agreement-text-box">
  19. 我已阅读并同意<view class="agreement-text" @click="agreeBtn">《用户协议》</view>和<view @click="agreeBtn" class="agreement-text">《隐私政策》</view>
  20. </view>
  21. </view>
  22. <view class="login-btn" @click="getYzmBtn" :class="indexData.telStatus"></view>
  23. </view>
  24. <view class="bottom-btn-box">
  25. <view class="wx-btn"></view>
  26. <view class="yk-btn" @click="ykBtn"></view>
  27. </view>
  28. </view>
  29. <agree-content-dialog ref="agreeContentDialogRef"></agree-content-dialog>
  30. <agree-dialog ref="agreeDialogRef" @confirm-btn="confirmBtn"></agree-dialog>
  31. </view>
  32. </template>
  33. <script setup>
  34. import {ref,reactive} from "vue"
  35. import { onLoad,onReady } from '@dcloudio/uni-app';
  36. import agreeContentDialog from './agreeContentDialog.vue';
  37. import agreeDialog from './agreeDialog.vue'
  38. let indexData = reactive({
  39. phoneNumber: null,
  40. clearTelIcon: false,
  41. telStatus:'tel-btn-disabled',
  42. isAgreed: false,
  43. sliderObj:{},
  44. })
  45. const agreeContentDialogRef = ref(null);
  46. const agreeDialogRef = ref(null);
  47. onLoad((options) => {})
  48. const getYzmBtn = () => {
  49. if(indexData.telStatus === 'tel-btn-normal'){
  50. if(indexData.isAgreed === true){
  51. uni.navigateTo({
  52. url: `/pages/login/login?telNum=${indexData.phoneNumber}`
  53. })
  54. }else{
  55. agreeDialogRef.value.handleShow();
  56. }
  57. }
  58. }
  59. // 用户协议同意
  60. const confirmBtn = () => {
  61. indexData.isAgreed = true;
  62. getYzmBtn();
  63. }
  64. // 手机号校验规则
  65. const validatePhoneNumber = (value) => {
  66. const phoneRegex = /^1[3-9]\d{9}$/;
  67. if (phoneRegex.test(value)) {
  68. indexData.telStatus = 'tel-btn-normal';
  69. } else {
  70. indexData.telStatus = 'tel-btn-disabled';
  71. }
  72. }
  73. const clearTelInput = (event) => {
  74. if (event.detail.value.length > 0) {
  75. indexData.clearTelIcon = true;
  76. validatePhoneNumber(event.detail.value);
  77. } else {
  78. indexData.clearTelIcon = false;
  79. }
  80. }
  81. const clearTel = () => {
  82. indexData.phoneNumber = '';
  83. indexData.telStatus = 'tel-btn-disabled';
  84. indexData.clearTelIcon = false;
  85. }
  86. const agreeBtn = () => {
  87. agreeContentDialogRef.value.handleShow();
  88. };
  89. const handleAgreementChange= (event) => {
  90. if(event.detail.value[0]==='agree'){
  91. indexData.isAgreed = true;
  92. }else{
  93. indexData.isAgreed = false;
  94. }
  95. }
  96. // 游客登录
  97. const ykBtn = () => {
  98. }
  99. </script>