passwordPage.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <v-form ref="passwordForm" @submit.prevent>
  3. <v-text-field v-model="loginData.phone" counter="11" :disabled="props.phoneDisabled" :placeholder="$t('login.mobileNumberPlaceholder')" color="primary" variant="outlined" density="compact" :rules="phoneRules" validate-on="input">
  4. <template v-slot:prepend-inner>
  5. <span class="d-flex">
  6. <v-icon icon="mdi-cellphone" size="20"></v-icon>
  7. <span class="d-flex" id="menu-activator">
  8. <span class="phone-number">{{ currentArea }}</span>
  9. <v-icon size="20">mdi-chevron-down</v-icon>
  10. </span>
  11. <v-menu activator="#menu-activator">
  12. <v-list>
  13. <v-list-item v-for="(item, index) in items" :key="index" :value="index" @click="handleChangeCurrentArea(item)">
  14. <v-list-item-title>{{ item.label }}</v-list-item-title>
  15. </v-list-item>
  16. </v-list>
  17. </v-menu>
  18. </span>
  19. </template>
  20. </v-text-field>
  21. <v-text-field
  22. v-model="loginData.password"
  23. :placeholder="$t('login.enterPassword')"
  24. variant="outlined"
  25. density="compact"
  26. color="primary"
  27. prepend-inner-icon="mdi-lock-outline"
  28. :append-inner-icon="passwordType ? 'mdi-eye-outline' : 'mdi-eye-off-outline'"
  29. :type="passwordType ? 'text' : 'password'"
  30. :rules="[v=> !!v || $t('login.enterPassword')]"
  31. @click:append-inner="passwordType = !passwordType"
  32. @keyup.enter="handleEnter"
  33. ></v-text-field>
  34. </v-form>
  35. </template>
  36. <script setup name="passwordPage">
  37. import { ref, reactive } from 'vue'
  38. defineOptions({ name: 'password-form' })
  39. import { useI18n } from '@/hooks/web/useI18n'
  40. const { t } = useI18n()
  41. const props = defineProps({ phoneDisabled: Boolean })
  42. const passwordType = ref(false)
  43. const emits = defineEmits(['handleEnter'])
  44. const phoneRules = ref([
  45. value => {
  46. if (value) return true
  47. return t('login.mobileNumberPlaceholder')
  48. },
  49. value => {
  50. if (value?.length <= 11 && /^1[3456789]\d{9}$/.test(value)) return true
  51. return t('login.correctPhoneNumber')
  52. }
  53. ])
  54. // 手机号区域
  55. const currentArea = ref('0086')
  56. const items = [
  57. { label: '中国大陆-0086', value: '0086' }
  58. ]
  59. const handleChangeCurrentArea = (e) => {
  60. currentArea.value = e.value
  61. }
  62. const loginUserPhone = localStorage.getItem('loginUserPhone') || ''
  63. const loginData = reactive({
  64. phone: loginUserPhone, // 13229740091
  65. password: '' // 1111
  66. })
  67. // 设置默认账号密码便于开发快捷登录
  68. if (window.location.hostname === 'localhost' || window.location.hostname === '192.168.3.152') {
  69. loginData.phone = '13229740091'
  70. loginData.password = 'Citu123'
  71. }
  72. const passwordForm = ref()
  73. const handleEnter = () => {
  74. emits('handleEnter')
  75. }
  76. defineExpose({
  77. loginData,
  78. passwordForm
  79. })
  80. </script>