|
|
@@ -5,8 +5,24 @@
|
|
|
</template>
|
|
|
<Form ref="formRef" class="g-form__container" @submit="formSubmit">
|
|
|
<CellGroup inset>
|
|
|
- <Field v-model="formData.mobile" type="tel" name="mobile" :label="$t('user.forget.mobile')"
|
|
|
- :placeholder="$t('common.pleaseenter')" autocomplete="off" :rules="formRules.mobile" />
|
|
|
+ <Field v-model="formData.mobile" type="tel" name="mobile"
|
|
|
+ :placeholder="$t('common.pleaseenter')" autocomplete="off" :rules="formRules.mobile" >
|
|
|
+ <template #label>
|
|
|
+ <span>{{ $t('user.forget.mobile') }}</span>
|
|
|
+ <span style="margin-left: 10px;" @click="show = true">
|
|
|
+ {{ countryCode }}
|
|
|
+ </span>
|
|
|
+ <Popup v-model:show="show" position="bottom" teleport="body" round>
|
|
|
+ <Picker :columns="datalist" @cancel="onCancel" @confirm="onConfirm" :confirm-button-text="$t('operation.confirm')" :cancel-button-text="$t('operation.cancel')">
|
|
|
+ <template #option="{ text, index }">
|
|
|
+ <slot name="option" :row="datalist[index]" :index="index">
|
|
|
+ {{ text }}
|
|
|
+ </slot>
|
|
|
+ </template>
|
|
|
+ </Picker>
|
|
|
+ </Popup>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
<Field v-model="formData.vcode" type="digit" name="vcode" :label="$t('user.forget.vcode')"
|
|
|
:placeholder="$t('common.pleaseenter')" autocomplete="off" :rules="formRules.vcode">
|
|
|
<template #button>
|
|
|
@@ -32,8 +48,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { reactive, ref, computed } from 'vue'
|
|
|
-import { CellGroup, Button, Field, Form, FormInstance, showFailToast, FieldRule } from 'vant'
|
|
|
+import { reactive, ref, computed, shallowRef } from 'vue'
|
|
|
+import { CellGroup, Button, Field, Form, FormInstance, showFailToast, FieldRule, Popup, Picker, PickerConfirmEventParams } from 'vant'
|
|
|
import { useCountDown } from '@vant/use'
|
|
|
import { fullloading, dialog } from '@/utils/vant'
|
|
|
import { getEncryptMobile } from '@/filters'
|
|
|
@@ -43,6 +59,23 @@ import { queryLoginId } from '@/services/api/account'
|
|
|
import { resetPassword, sendResetVerifyCode } from '@/services/api/common'
|
|
|
import cryptojs from 'crypto-js'
|
|
|
import { i18n, useUserStore } from '@/stores'
|
|
|
+import { getCountryCodeList } from '@/constants/unit'
|
|
|
+
|
|
|
+const show = shallowRef(false) // 是否弹出选择器
|
|
|
+const datalist = computed(() => {
|
|
|
+ return getCountryCodeList().map(e => {
|
|
|
+ return { text: e.value, value: e.value }
|
|
|
+ })
|
|
|
+})
|
|
|
+const countryCode = ref(datalist.value[0].value.toString())
|
|
|
+const onCancel = () => {
|
|
|
+ show.value = false
|
|
|
+}
|
|
|
+
|
|
|
+const onConfirm = ({ selectedValues: [value] }: PickerConfirmEventParams) => {
|
|
|
+ show.value = false
|
|
|
+ countryCode.value = value.toString()
|
|
|
+}
|
|
|
|
|
|
const { router } = useNavigation()
|
|
|
const formRef = ref<FormInstance>()
|
|
|
@@ -129,7 +162,7 @@ const sendVerifyCode = () => {
|
|
|
loading.value = true
|
|
|
sendResetVerifyCode({
|
|
|
data: {
|
|
|
- mobile: getEncryptMobile(formData.mobile),
|
|
|
+ mobile: getEncryptMobile(countryCode.value+formData.mobile),
|
|
|
businessType: 1
|
|
|
}
|
|
|
}).then(() => {
|
|
|
@@ -146,18 +179,19 @@ const formSubmit = () => {
|
|
|
fullloading((hideLoading) => {
|
|
|
queryLoginId({
|
|
|
data: {
|
|
|
- username: formData.mobile
|
|
|
+ username: countryCode.value+formData.mobile
|
|
|
}
|
|
|
}).then((res) => {
|
|
|
const { mobile, password, vcode } = formData
|
|
|
const logincode = res.data
|
|
|
const encryptedData = cryptojs.SHA256(logincode + password).toString()
|
|
|
const encryptedHex = cryptojs.enc.Hex.parse(encryptedData).toString().toLocaleLowerCase()
|
|
|
+ formData.mobile = countryCode.value+formData.mobile
|
|
|
|
|
|
resetPassword({
|
|
|
data: {
|
|
|
logincode,
|
|
|
- mobile: getEncryptMobile(mobile),
|
|
|
+ mobile: getEncryptMobile(mobile),
|
|
|
password: encryptedHex,
|
|
|
vcode,
|
|
|
}
|