fix bug of register page
This commit is contained in:
+18
-5
@@ -31,10 +31,23 @@ export function inputLenRules(len: number, title?: string) {
|
||||
import {computed, ref} from 'vue'
|
||||
import type {Rule} from 'ant-design-vue/es/form'
|
||||
import {useWalletStore} from "@/store/walletStore";
|
||||
import { isCashLikeDealMethod, getInsufficientCashWalletMessage, getInsufficientGoldWalletMessage } from '@/utils/productDealMethod'
|
||||
import { isCashLikeDealMethod, isMainMetalWalletDealMethod, getInsufficientCashWalletMessage, getInsufficientGoldWalletMessage } from '@/utils/productDealMethod'
|
||||
|
||||
export const mobileValidation = (title?: string) => {
|
||||
return {len: 11, message: `شماره همراه باید 11 رقم باشد`}
|
||||
export const mobileValidation = (title?: string): Rule => {
|
||||
const label = title ?? 'شماره تلفن'
|
||||
return {
|
||||
validator: (_rule, value) => {
|
||||
const normalized = String(value ?? '').trim()
|
||||
if (!normalized) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
if (!/^09\d{9}$/.test(normalized)) {
|
||||
return Promise.reject(`${label} باید با 09 شروع شود و 11 رقم باشد`)
|
||||
}
|
||||
return Promise.resolve()
|
||||
},
|
||||
trigger: ['change', 'blur'],
|
||||
}
|
||||
}
|
||||
|
||||
export const required = (title?: string) => {
|
||||
@@ -150,12 +163,12 @@ if (isBuyP){
|
||||
if (!walletCash?.walletInfo?.cash && isCashLikeDealMethod(methodP)){
|
||||
return Promise.reject(getInsufficientCashWalletMessage(groupTypeP))
|
||||
}
|
||||
if (!walletCash?.walletInfo?.gold && methodP == 'gold'){
|
||||
if (!walletCash?.walletInfo?.gold && isMainMetalWalletDealMethod(methodP)){
|
||||
return Promise.reject(getInsufficientGoldWalletMessage(groupTypeP))
|
||||
}
|
||||
if (priceP * value > walletCash?.walletInfo?.cash && isCashLikeDealMethod(methodP))
|
||||
return Promise.reject(getInsufficientCashWalletMessage(groupTypeP))
|
||||
if (amountP * value > walletCash?.walletInfo?.gold && methodP == 'gold')
|
||||
if (amountP * value > walletCash?.walletInfo?.gold && isMainMetalWalletDealMethod(methodP))
|
||||
return Promise.reject(getInsufficientGoldWalletMessage(groupTypeP))
|
||||
else
|
||||
return Promise.resolve();
|
||||
|
||||
Reference in New Issue
Block a user