فهرست منبع

发送验证码增加区号

Handy_Cao 1 سال پیش
والد
کامیت
de7ca1863e

+ 1 - 0
src/business/login/index.ts

@@ -179,6 +179,7 @@ export function useLogin(persist = false) {
         logining,
         remember,
         formData,
+        loadBaseData,
         initBaseData,
         userLogin,
         userLogout,

+ 41 - 7
src/packages/mobile/views/user/forget/Index.vue

@@ -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,
                 }

+ 40 - 6
src/packages/mobile/views/user/register/Index.vue

@@ -5,8 +5,23 @@
     </template>
     <Form ref="formRef" class="g-form__container register__form" @submit="formSubmit">
       <CellGroup inset>
-        <Field v-model="formData.mobilephone" type="digit" name="mobilephone" :label="$t('user.register.mobile')"
-          :placeholder="$t('common.required')" :rules="formRules.mobilephone" />
+        <Field v-model="formData.mobilephone" type="digit" name="mobilephone" :placeholder="$t('common.required')" :rules="formRules.mobilephone">
+          <template #label>
+            <span>{{ $t('user.register.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.register.vcode')"
           :placeholder="$t('common.required')" :rules="formRules.vcode">
           <template #button>
@@ -61,14 +76,15 @@
 </template>
 
 <script lang="ts" setup>
-import { reactive, ref, computed, onMounted } from 'vue'
-import { CellGroup, Cell, Button, Field, Form, FormInstance, Checkbox, showFailToast, showToast, FieldRule } from 'vant'
+import { reactive, shallowRef, ref, computed, onMounted } from 'vue'
+import { CellGroup, Cell, Button, Field, Form, FormInstance, Checkbox, showFailToast, showToast, FieldRule, Popup, Picker, PickerConfirmEventParams } from 'vant'
 import { useCountDown } from '@vant/use'
 import { fullloading, dialog } from '@/utils/vant'
 import { validateRules } from '@/constants/regex'
 import { useNavigation } from '@mobile/router/navigation'
 import { userRegister, sendRegisterVerifyCode, queryMyRegisterMoney } from '@/services/api/common'
 import { i18n, useGlobalStore, useUserStore } from '@/stores'
+import { getCountryCodeList } from '@/constants/unit'
 import cryptojs from 'crypto-js'
 import plus from '@/utils/h5plus'
 import AppReward from '@mobile/components/modules/reward/index.vue'
@@ -81,6 +97,22 @@ defineProps({
   }
 })
 
+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, routerTo } = useNavigation()
 const globalStore = useGlobalStore()
 const registrationCodeRule = globalStore.getSystemInfo('registrationCodeRule')
@@ -190,7 +222,7 @@ const sendVerifyCode = () => {
     loading.value = true
     sendRegisterVerifyCode({
       data: {
-        phonenumber: formData.mobilephone
+        phonenumber: countryCode.value+formData.mobilephone
       }
     }).then(() => {
       isCountdown.value = true
@@ -235,11 +267,13 @@ const formSubmit = () => {
       // 密码需进行两次base64加密
       const passwordData = Base64.stringify(Utf8.parse(formData.loginpwd))
       const loginpwd = Base64.stringify(Utf8.parse(passwordData))
+      const mobilephone = countryCode.value+formData.mobilephone
 
       userRegister({
         data: {
           ...formData,
-          loginpwd
+          loginpwd,
+          mobilephone
         }
       }).then((res) => {
         if (res.code === 0) {

+ 23 - 4
src/packages/pc/views/auth/forget/index.vue

@@ -1,7 +1,13 @@
 <template>
     <el-form ref="formRef" :model="formData" :rules="formRules">
         <el-form-item prop="mobile">
-            <el-input :placeholder="t('user.forget.tips1')" type="number" v-model="formData.mobile" :rules="formRules.mobile" />
+            <el-input :placeholder="t('user.forget.tips1')" type="number" v-model="formData.mobile" :rules="formRules.mobile">
+                <template #prepend v-if="countryCode != ''">
+                    <el-select v-model="countryCode" style="width: 80px">
+                        <el-option v-for="item in getCountryCodeList()" :key="item.value" :label="item.value" :value="item.value" />
+                    </el-select>
+                </template>
+            </el-input>
         </el-form-item>
         <el-form-item prop="vcode">
             <el-input :placeholder="t('user.forget.tips2')" type="number" v-model="formData.vcode" :rules="formRules.vcode">
@@ -35,8 +41,10 @@ import { validateRules } from '@/constants/regex'
 import { queryLoginId } from '@/services/api/account'
 import { resetPassword, sendResetVerifyCode } from '@/services/api/common'
 import { i18n, useUserStore } from '@/stores'
+import { useLogin } from '@/business/login'
 import cryptojs from 'crypto-js'
 import service from '@/services'
+import { getCountryCodeList } from '@/constants/unit'
 
 const emit = defineEmits(['close'])
 const formRef = ref<FormInstance>()
@@ -47,6 +55,17 @@ const { t } = i18n.global
 const { getSystemParamValue } = useUserStore()
 const system_1010 = shallowRef(getSystemParamValue('1010') ?? '1')
 
+const { loadBaseData } = useLogin()
+const datalist = ref()
+const countryCode = ref('')
+// 获取枚举数据
+loadBaseData().then(() => {
+    datalist.value = getCountryCodeList()
+    if (datalist.value.length != 0) {
+        countryCode.value = datalist.value[0].value
+    }
+})
+
 // 表单数据
 const formData = reactive<Model.ResetPasswordReq & { confirmpassword: string }>({
     logincode: '',
@@ -107,7 +126,7 @@ const sendVerifyCode = () => {
             service.onReady().then(() => {
                 sendResetVerifyCode({
                     data: {
-                        mobile: getEncryptMobile(formData.mobile),
+                        mobile: getEncryptMobile(countryCode.value+formData.mobile),
                         businessType: 1
                     }
                 }).then(() => {
@@ -135,7 +154,7 @@ const formSubmit = () => {
         if (valid) {
             queryLoginId({
                 data: {
-                    username: formData.mobile
+                    username: countryCode.value+formData.mobile+formData.mobile
                 }
             }).then((res) => {
                 const { mobile, password, vcode } = formData
@@ -146,7 +165,7 @@ const formSubmit = () => {
                 resetPassword({
                     data: {
                         logincode,
-                        mobile: getEncryptMobile(mobile),
+                        mobile: countryCode.value+getEncryptMobile(mobile),
                         password: encryptedHex,
                         vcode,
                     }