fix sql
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
:size="props.size"
|
||||
:type="props.type"
|
||||
class=""
|
||||
@input="handlerChange"
|
||||
@change="handlerChange"
|
||||
/>
|
||||
<a-input
|
||||
@@ -27,6 +28,7 @@
|
||||
:inputmode="props.inputmode"
|
||||
:pattern="props.pattern"
|
||||
class=""
|
||||
@input="handlerChange"
|
||||
@change="handlerChange"
|
||||
/>
|
||||
</div>
|
||||
@@ -89,8 +91,9 @@ function normalizeValue(value: unknown) {
|
||||
return normalized
|
||||
}
|
||||
|
||||
const handlerChange = (e: any) => {
|
||||
const normalized = normalizeValue(e.target.value)
|
||||
const handlerChange = (e: Event | string) => {
|
||||
const raw = typeof e === 'string' ? e : (e.target as HTMLInputElement | null)?.value
|
||||
const normalized = normalizeValue(raw)
|
||||
emits('update:value', normalized)
|
||||
emits('onchange', normalized)
|
||||
}
|
||||
|
||||
+30
-16
@@ -38,6 +38,7 @@ import { persianToEnglishDigits } from '@/utils/persianDigits'
|
||||
export const mobileValidation = (title?: string): Rule => {
|
||||
const label = title ?? 'شماره تلفن'
|
||||
return {
|
||||
transform: (value) => persianToEnglishDigits(String(value ?? '').trim()),
|
||||
validator: (_rule, value) => {
|
||||
const normalized = persianToEnglishDigits(String(value ?? '').trim())
|
||||
if (!normalized) {
|
||||
@@ -94,14 +95,20 @@ const isValidNationalCode = (code) => {
|
||||
return +chars[9] === lastDigit
|
||||
}
|
||||
export const requireNationalCode = (code?: string) => {
|
||||
return {required: true, validator: validateNCode, trigger: 'change'}
|
||||
return {
|
||||
required: true,
|
||||
transform: (value) => persianToEnglishDigits(String(value ?? '').trim()),
|
||||
validator: validateNCode,
|
||||
trigger: 'change',
|
||||
}
|
||||
}
|
||||
|
||||
async function validateNCode(rule: Rule, value: any) {
|
||||
if (!value) {
|
||||
const normalized = persianToEnglishDigits(String(value ?? '').trim())
|
||||
if (!normalized) {
|
||||
return Promise.reject('وارد کردن کد ملی الزامیست')
|
||||
}
|
||||
if (isValidNationalCode(value)) return Promise.resolve()
|
||||
if (isValidNationalCode(normalized)) return Promise.resolve()
|
||||
else return Promise.reject('کد ملی وارد شده نامعتبر است')
|
||||
}
|
||||
|
||||
@@ -153,13 +160,16 @@ let isBuyP=true
|
||||
let NumP=0
|
||||
let groupTypeP: string | undefined
|
||||
let meltedBalanceP = 0
|
||||
const checkNumber = async (_rule: Rule, value: number) => {
|
||||
|
||||
|
||||
if (!value) {
|
||||
const checkNumber = async (_rule: Rule, value: number | string) => {
|
||||
const normalizedRaw = persianToEnglishDigits(String(value ?? '').trim())
|
||||
if (!normalizedRaw) {
|
||||
return Promise.reject('تعداد محصول را مشخص کنید');
|
||||
}
|
||||
if (value % 1 !== 0) {
|
||||
const numericValue = Number(normalizedRaw)
|
||||
if (!Number.isFinite(numericValue)) {
|
||||
return Promise.reject('تعداد محصول را مشخص کنید');
|
||||
}
|
||||
if (numericValue % 1 !== 0) {
|
||||
return Promise.reject('استفاده از اعداد اعشاری مجاز نمی باشد')
|
||||
}
|
||||
if (isBuyP){
|
||||
@@ -170,14 +180,14 @@ if (isBuyP){
|
||||
if (!meltedBalanceP && isMainMetalWalletDealMethod(methodP)){
|
||||
return Promise.reject(getInsufficientGoldWalletMessage(groupTypeP, methodP))
|
||||
}
|
||||
if (priceP * value > availableCash && isCashLikeDealMethod(methodP))
|
||||
if (priceP * numericValue > availableCash && isCashLikeDealMethod(methodP))
|
||||
return Promise.reject(getInsufficientCashWalletMessage(groupTypeP))
|
||||
if (amountP * value > meltedBalanceP && isMainMetalWalletDealMethod(methodP))
|
||||
if (amountP * numericValue > meltedBalanceP && isMainMetalWalletDealMethod(methodP))
|
||||
return Promise.reject(getInsufficientGoldWalletMessage(groupTypeP, methodP))
|
||||
else
|
||||
return Promise.resolve();
|
||||
}else {
|
||||
if (value > NumP)
|
||||
if (numericValue > NumP)
|
||||
return Promise.reject('موجودی محصول ناکافی است')
|
||||
else
|
||||
return Promise.resolve();
|
||||
@@ -200,6 +210,7 @@ export const justNumber2 = (
|
||||
meltedBalanceP = meltedBalance ?? 0
|
||||
return {
|
||||
required: true,
|
||||
transform: (value) => persianToEnglishDigits(String(value ?? '').trim()),
|
||||
validator: checkNumber,
|
||||
trigger: 'change'
|
||||
}
|
||||
@@ -211,6 +222,7 @@ export const justNumber3 = (price: number, Num?:number ,isBuy?:boolean) => {
|
||||
isBuyP=isBuy
|
||||
return {
|
||||
required: true,
|
||||
transform: (value) => persianToEnglishDigits(String(value ?? '').trim()),
|
||||
validator: checkNumber,
|
||||
trigger: 'change'
|
||||
}
|
||||
@@ -233,14 +245,16 @@ export const guideTypePassword = ref<{}>({
|
||||
export const passwordRules = () => {
|
||||
return [
|
||||
{
|
||||
transform: (value) => persianToEnglishDigits(String(value ?? '')),
|
||||
validator: (rule: Rule, value: any) => {
|
||||
if (value.length < 6) {
|
||||
const normalized = persianToEnglishDigits(String(value ?? ''))
|
||||
if (normalized.length < 6) {
|
||||
return Promise.reject('رمز عبور حداقل 6 رقم')
|
||||
}
|
||||
const lengthCriteria = value.length >= 8
|
||||
const letterCriteria = /[A-Za-z]/.test(value)
|
||||
const numberCriteria = /\d/.test(value)
|
||||
const specialCharacterCriteria = /[@$!%*#?&]/.test(value)
|
||||
const lengthCriteria = normalized.length >= 8
|
||||
const letterCriteria = /[A-Za-z]/.test(normalized)
|
||||
const numberCriteria = /\d/.test(normalized)
|
||||
const specialCharacterCriteria = /[@$!%*#?&]/.test(normalized)
|
||||
const criteriaMet = [
|
||||
lengthCriteria,
|
||||
letterCriteria,
|
||||
|
||||
@@ -19,11 +19,33 @@ export function shouldNormalizeInputDigits(options: {
|
||||
inputmode?: string
|
||||
}): boolean {
|
||||
if (options.isPassword) {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
if (options.type === 'price' || options.type === 'number') {
|
||||
const type = String(options.type ?? '').trim().toLowerCase()
|
||||
if (type === 'price' || type === 'number' || type === 'tel') {
|
||||
return true
|
||||
}
|
||||
const mode = String(options.inputmode ?? '').trim().toLowerCase()
|
||||
return mode === 'numeric' || mode === 'decimal' || mode === 'number'
|
||||
}
|
||||
|
||||
/** تبدیل ارقام فارسی/عربی در فیلدهای عددی فرمهای احراز هویت و پروفایل */
|
||||
export function normalizeAuthFormFields(fields: {
|
||||
mobile?: string | null
|
||||
password?: string | null
|
||||
token?: string | null
|
||||
n_code?: string | number | null
|
||||
}) {
|
||||
if (fields.mobile != null && fields.mobile !== '') {
|
||||
fields.mobile = persianToEnglishDigits(String(fields.mobile).trim())
|
||||
}
|
||||
if (fields.password != null && fields.password !== '') {
|
||||
fields.password = persianToEnglishDigits(String(fields.password))
|
||||
}
|
||||
if (fields.token != null && fields.token !== '') {
|
||||
fields.token = persianToEnglishDigits(String(fields.token).trim())
|
||||
}
|
||||
if (fields.n_code != null && fields.n_code !== '') {
|
||||
fields.n_code = persianToEnglishDigits(String(fields.n_code).trim())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
<a-form-item :rules="[requireNationalCode()]" label="شماره ملی" name="n_code">
|
||||
<BasicInput
|
||||
v-model:value="userFormState.n_code"
|
||||
type="number"
|
||||
type="text"
|
||||
inputmode="numeric"
|
||||
:disabled="userFormState.is_legal == 1 || userFormState.is_legal == 2"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
@@ -16,6 +16,7 @@ import { getUserAvatarUrl } from '@/utils/file'
|
||||
import { useConfigStore } from '@/store/configStore'
|
||||
import { getConfigApp, isBoursecuProject, getBoursecuActionIconSrc } from '@/utils/config'
|
||||
import { getReferralShareText, getReferralShareTitle, shareReferralText } from '@/utils/referralShare'
|
||||
import { normalizeAuthFormFields } from '@/utils/persianDigits'
|
||||
|
||||
export interface UserMenuAction {
|
||||
id: string
|
||||
@@ -207,6 +208,7 @@ export function useUserPage() {
|
||||
formRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
normalizeAuthFormFields(userFormState.value)
|
||||
await updateMe(userFormState.value)
|
||||
await userStore.getMyInfo()
|
||||
localAvatarUrl.value = getUserAvatarUrl(userStore.userInfo)
|
||||
@@ -224,6 +226,7 @@ export function useUserPage() {
|
||||
formPassRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
normalizeAuthFormFields(userPassForm.value)
|
||||
await updatePass(userPassForm.value)
|
||||
await userStore.getMyInfo()
|
||||
editPassVisible.value = false
|
||||
|
||||
@@ -103,7 +103,12 @@
|
||||
<a-form-item v-if="!isSMS" :rules="[required('کلمه عبور')]" class="home_appear_fade_in_down" label="کلمه عبور"
|
||||
name="password">
|
||||
<!-- <BasicInput v-model:value="userFormState.password" size="large" place-holder="کلمه عبور"/>-->
|
||||
<AInputPassword v-model:value="userFormState.password" place-holder="کلمه عبور" size="large"/>
|
||||
<BasicInput
|
||||
v-model:value="userFormState.password"
|
||||
is-password
|
||||
place-holder="کلمه عبور"
|
||||
size="large"
|
||||
/>
|
||||
</a-form-item>
|
||||
<div v-else-if="!stepTwoVerify" :class="variant === 'desktop' ? 'h-0' : 'h-[90px]'" />
|
||||
<div v-else>
|
||||
@@ -387,6 +392,7 @@ import {
|
||||
isTWA
|
||||
} from "@/utils/config";
|
||||
import BasicActionSheet from "@/components/BasicPacks/BasicActionSheet.vue";
|
||||
import { normalizeAuthFormFields } from '@/utils/persianDigits'
|
||||
import {getConfig} from "@/api/config";
|
||||
import shareAppleIcon from '@/assets/img/share-apple.png'
|
||||
import addToHomeScreenIcon from '@/assets/img/Add-to-homeScreen.png'
|
||||
@@ -433,6 +439,7 @@ async function reSendCode() {
|
||||
userFormState.token = undefined
|
||||
// refOtpInput.value?.clearInput()
|
||||
enableSendAgainCode.value = false
|
||||
normalizeAuthFormFields(userFormState)
|
||||
await loginCustomer(userFormState)
|
||||
reset()
|
||||
}
|
||||
@@ -472,11 +479,13 @@ function useStyle() {
|
||||
|
||||
function handleOnChange(value: string) {
|
||||
userFormState.token = value
|
||||
normalizeAuthFormFields(userFormState)
|
||||
// formRef.value?.validateFields()
|
||||
}
|
||||
|
||||
async function handleOnComplete(value: string) {
|
||||
userFormState.token = value
|
||||
normalizeAuthFormFields(userFormState)
|
||||
phoneVerification()
|
||||
}
|
||||
|
||||
@@ -501,6 +510,7 @@ function phoneVerification() {
|
||||
formRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
normalizeAuthFormFields(userFormState)
|
||||
if (isSMS.value) {
|
||||
if (!stepTwoVerify.value) {
|
||||
userFormState.token = undefined
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="font-bold text-center text-xl">ورود / ثبت نام</div>
|
||||
<a-form :model="userFormState" name="basic" @finish="phoneVerification" class="!mt-5">
|
||||
<a-form-item label="شماره تلفن همراه" name="mobile" :rules="[required,mobileValidation('شماره تلفن همراه')]">
|
||||
<BasicInput v-model:value="userFormState.mobile" type="tel" size="large" place-holder="شماره تلفن همراه"/>
|
||||
<BasicInput v-model:value="userFormState.mobile" type="tel" inputmode="numeric" size="large" place-holder="شماره تلفن همراه"/>
|
||||
<div class="text-xs mt-1 text-gray-400">مالکیت شماره باید به نام خودتان باشد</div>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
v-model:value="userFormState.mobile"
|
||||
:place-holder="variant === 'desktop' ? '۰۹۱۲۳۴۵۶۷۸۹' : 'شماره تلفن'"
|
||||
:size="variant === 'desktop' ? 'large' : undefined"
|
||||
type="tel"
|
||||
inputmode="numeric"
|
||||
/>
|
||||
</a-form-item>
|
||||
@@ -73,8 +74,9 @@
|
||||
label="کلمه عبور"
|
||||
name="password"
|
||||
>
|
||||
<AInputPassword
|
||||
<BasicInput
|
||||
v-model:value="userFormState.password"
|
||||
is-password
|
||||
place-holder="کلمه عبور"
|
||||
:size="variant === 'desktop' ? 'large' : undefined"
|
||||
/>
|
||||
@@ -236,6 +238,7 @@ import router from '@/router'
|
||||
import {useConfigStore} from "@/store/configStore";
|
||||
import {useSettingsStore} from '@/store/settingsStore'
|
||||
import {getProjectLoginLogo, getProjectLoginTaglineLines, hasCustomLoginLogoLayout} from "@/utils/config";
|
||||
import { normalizeAuthFormFields } from '@/utils/persianDigits'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
@@ -288,6 +291,7 @@ function registerAccount() {
|
||||
URLUserType() === 'single' ? userFormState.type = 2 : userFormState.type = 1
|
||||
// console.log(userFormState)
|
||||
if (!userFormState.referral_id || userFormState.referral_id === '') delete userFormState.referral_id
|
||||
normalizeAuthFormFields(userFormState)
|
||||
const { id } = await registerCustomer(userFormState)
|
||||
registeredInfo.value = true
|
||||
// console.log(registeredInfo.value)
|
||||
|
||||
@@ -17,6 +17,7 @@ import { useWalletStore } from '@/store/walletStore'
|
||||
import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { setTruth } from '@/app/authBoot'
|
||||
import { completeLoginNavigation } from '@/layouts/composables/useMobileScrollReset'
|
||||
import { normalizeAuthFormFields } from '@/utils/persianDigits'
|
||||
|
||||
export function useLoginForm() {
|
||||
const { time, onFinish, reset } = useCountdownTimer('00:02:00', 'mm:ss')
|
||||
@@ -41,6 +42,7 @@ export function useLoginForm() {
|
||||
async function reSendCode() {
|
||||
userFormState.token = undefined
|
||||
enableSendAgainCode.value = false
|
||||
normalizeAuthFormFields(userFormState)
|
||||
await loginCustomer(userFormState)
|
||||
reset()
|
||||
}
|
||||
@@ -64,10 +66,12 @@ export function useLoginForm() {
|
||||
|
||||
function handleOnChange(value: string) {
|
||||
userFormState.token = value
|
||||
normalizeAuthFormFields(userFormState)
|
||||
}
|
||||
|
||||
async function handleOnComplete(value: string) {
|
||||
userFormState.token = value
|
||||
normalizeAuthFormFields(userFormState)
|
||||
phoneVerification()
|
||||
}
|
||||
|
||||
@@ -103,6 +107,7 @@ export function useLoginForm() {
|
||||
formRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
normalizeAuthFormFields(userFormState)
|
||||
if (isSMS.value) {
|
||||
if (!stepTwoVerify.value) {
|
||||
userFormState.token = undefined
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { User } from '@/models/login'
|
||||
import { loading, URLUserType } from '@/utils'
|
||||
import { registerCustomer } from '@/api/login'
|
||||
import router from '@/router'
|
||||
import { normalizeAuthFormFields } from '@/utils/persianDigits'
|
||||
|
||||
export function useRegisterForm() {
|
||||
const registeredInfo = ref(false)
|
||||
@@ -31,6 +32,7 @@ export function useRegisterForm() {
|
||||
if (!userFormState.referral_id || userFormState.referral_id === '') {
|
||||
delete userFormState.referral_id
|
||||
}
|
||||
normalizeAuthFormFields(userFormState)
|
||||
await registerCustomer(userFormState)
|
||||
registeredInfo.value = true
|
||||
} catch (e: any) {
|
||||
|
||||
@@ -107,8 +107,9 @@ function goToAboutUs() {
|
||||
label="کلمه عبور"
|
||||
name="password"
|
||||
>
|
||||
<AInputPassword
|
||||
<BasicInput
|
||||
v-model:value="userFormState.password"
|
||||
is-password
|
||||
place-holder="کلمه عبور"
|
||||
size="large"
|
||||
/>
|
||||
|
||||
@@ -82,13 +82,15 @@ function handleSuccessDismiss() {
|
||||
v-model:value="userFormState.mobile"
|
||||
place-holder="۰۹۱۲۳۴۵۶۷۸۹"
|
||||
size="large"
|
||||
type="tel"
|
||||
inputmode="numeric"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item :rules="[required()]" label="کلمه عبور" name="password">
|
||||
<AInputPassword
|
||||
<BasicInput
|
||||
v-model:value="userFormState.password"
|
||||
is-password
|
||||
place-holder="کلمه عبور"
|
||||
size="large"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user