passwordPage.vue 2.8 KB

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