index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
  3. mask-background-color="rgba(255, 255, 255, 0.6);" class="ezy-popup-width-all">
  4. <view>
  5. <!-- 手机号输入框 -->
  6. <view class="phone-input-box">
  7. <view class="phone-prefix">+86</view>
  8. <input class="phone-input" type="text" v-model="indexData.phoneNumber" placeholder="请输入手机号"
  9. maxlength="11" @input="clearTelInput" />
  10. <view class="close-btn" v-if="indexData.clearTelIcon" @click="clearTel"></view>
  11. </view>
  12. <!-- 协议勾选框和按钮 -->
  13. <view class="agreement-checkbox-box">
  14. <checkbox-group @change="handleAgreementChange">
  15. <checkbox class="agreement-checkbox-input" color="#FFFFFF" value="agree"
  16. :checked="indexData.isAgreed" />
  17. </checkbox-group>
  18. <view class="agreement-text-box">
  19. 我已阅读并同意<view class="agreement-text" @click="agreeBtn('yhxy')">《用户协议》</view>和<view
  20. @click="agreeBtn('ystk')" class="agreement-text">《隐私政策》</view>
  21. </view>
  22. <ezyActiveVue class="ezy-btn-active login-btn" @aclick="getYzmBtn" :class="indexData.telStatus">发送验证码
  23. </ezyActiveVue>
  24. </view>
  25. </view>
  26. </uni-popup>
  27. <yanzhengmaVue ref="yanzhengmaRef"></yanzhengmaVue>
  28. <agree-dialog ref="agreeDialogRef" @confirm-btn="confirmBtn"></agree-dialog>
  29. <agreeContentDialogVue ref="agreeContentDialogRef" :agreeType="agreeType"></agreeContentDialogVue>
  30. </template>
  31. <script setup>
  32. import {
  33. ref,
  34. reactive
  35. } from "vue";
  36. import yanzhengmaVue from "./yanzhengma.vue";
  37. import agreeContentDialogVue from "@/pages/login/agreeContentDialog.vue";
  38. import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
  39. import {
  40. toast
  41. } from "@/utils/common";
  42. import agreeDialog from "@/pages/login/agreeDialog.vue";
  43. const popupRef = ref(null)
  44. const yanzhengmaRef = ref(null)
  45. const agreeType = ref(null);
  46. const agreeContentDialogRef = ref(null);
  47. const agreeDialogRef = ref(null)
  48. let indexData = reactive({
  49. phoneNumber: null,
  50. clearTelIcon: false,
  51. telStatus: 'login-btn-disabled',
  52. isAgreed: false,
  53. sliderObj: {},
  54. })
  55. function showPopup() {
  56. popupRef.value.open()
  57. }
  58. function closePopup() {
  59. popupRef.value.close()
  60. }
  61. const clearTelInput = (event) => {
  62. if (event.detail.value.length > 0) {
  63. indexData.clearTelIcon = true;
  64. validatePhoneNumber(event.detail.value);
  65. } else {
  66. indexData.clearTelIcon = false;
  67. }
  68. }
  69. // 手机号校验规则
  70. const validatePhoneNumber = (value) => {
  71. const phoneRegex = /^1[3-9]\d{9}$/;
  72. if (phoneRegex.test(value)) {
  73. indexData.telStatus = 'login-btn-normal';
  74. } else {
  75. indexData.telStatus = 'login-btn-disabled';
  76. }
  77. }
  78. const handleAgreementChange = (event) => {
  79. if (event.detail.value[0] === 'agree') {
  80. indexData.isAgreed = true;
  81. } else {
  82. indexData.isAgreed = false;
  83. }
  84. }
  85. // 用户协议同意
  86. const confirmBtn = () => {
  87. indexData.isAgreed = true;
  88. getYzmBtn();
  89. }
  90. const getYzmBtn = () => {
  91. if (indexData.telStatus === 'login-btn-normal') {
  92. // 手机号完整
  93. if (indexData.isAgreed === true) {
  94. console.log('获取验证码')
  95. // 同意协议
  96. // yanzhengmaRef.value.
  97. } else {
  98. // 不同意协议
  99. agreeDialogRef.value.handleShow();
  100. }
  101. } else {
  102. toast('请输入合法手机号')
  103. }
  104. }
  105. const agreeBtn = (data) => {
  106. if (data === 'yhxy') {
  107. agreeType.value = 'yhxy'
  108. } else {
  109. agreeType.value = 'ystk'
  110. }
  111. agreeContentDialogRef.value.handleShow();
  112. };
  113. defineExpose({
  114. showPopup
  115. })
  116. </script>
  117. <style lang="scss" scoped>
  118. </style>