fix(register): hide or require referral from settings like other apps

Also keep exact trade grams from rial and poll colleague wait every 10s.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-09 21:03:32 +03:30
co-authored by Cursor
parent 0f6d8b37f4
commit c2f6f9d226
6 changed files with 132 additions and 19 deletions
+33 -4
View File
@@ -84,7 +84,7 @@
<BasicInput v-model:value="goldValueInput" :addon-before="weightUnit" :addon-bg-color="colors.primary"
addon-text-color="white"
:place-holder="amountFieldLabel"
size="large" type="text" inputmode="decimal" />
size="large" type="text" inputmode="decimal" @focus="startGramDraft" @blur="commitGramDraft" />
</a-form-item>
<div v-if="cashValidationMessage" class="text-red-700 text-xs font-bold mt-2">
{{ cashValidationMessage }}
@@ -289,7 +289,10 @@ import {
calcTradeTargetCash,
buildTradeConfirmBreakdown,
formatTradeGramDisplay,
tradeGramInputDisplay,
tradeGramFieldText,
tradeGramTypedDisplay,
sanitizeTradeGramTypingText,
tradeGramInputEditText,
exactGoldFromWalletPercent,
goldFromGramInputDisplay,
loadServiceFeeFromSettings,
@@ -441,13 +444,36 @@ const displayTradeGoldAmount = computed(() =>
formatTradeGramDisplay(orderGoldAmount.value)
)
const gramInputDraft = ref<string | null>(null)
function commitGramDraft() {
gramInputDraft.value = null
}
function startGramDraft() {
if (gramInputDraft.value !== null) return
gramInputDraft.value = inputLock.value === 'rial'
? tradeGramInputEditText(form.value.goldValue)
: tradeGramTypedDisplay(form.value.goldValue)
}
const goldValueInput = computed({
get() {
const display = tradeGramInputDisplay(form.value.goldValue)
const display = tradeGramFieldText(form.value.goldValue, inputLock.value, gramInputDraft.value)
return display === '' ? undefined : display
},
set(raw: string | number | null | undefined) {
const next = goldFromGramInputDisplay(raw, form.value.goldValue)
if (raw === '' || raw == null) {
gramInputDraft.value = ''
form.value.goldValue = undefined
form.value.goldCash = undefined
form.value.percentWallet = 0
inputLock.value = null
return
}
const text = sanitizeTradeGramTypingText(raw)
gramInputDraft.value = text
const next = goldFromGramInputDisplay(text, form.value.goldValue)
form.value.goldValue = next
if (next == null) {
form.value.goldCash = undefined
@@ -645,6 +671,7 @@ onMounted(() => {
})
function percentChange(val: number) {
commitGramDraft()
if (val !== 0) {
if (isBuy.value) {
form.value.goldCash = unitCashCalculator.value * val
@@ -711,6 +738,7 @@ function calculateCash(val: number) {
}
function calculateGold(val: number) {
commitGramDraft()
inputLock.value = 'rial'
const unit = unitPrice.value
if (!unit || Number.isNaN(unit)) return
@@ -748,6 +776,7 @@ function setIsBuy(val: boolean) {
form.value.goldCash = undefined
form.value.percentWallet = 0
inputLock.value = null
commitGramDraft()
// console.log(bganim.value.classList)
// bganim?.value?.classList.add(val?'right':'left')
// bganim?.value?.style.transform = `translateX(${val ? '0' : '-100'});`
+31 -7
View File
@@ -18,8 +18,18 @@
<!-- <BasicInput v-model:value="userFormState.password" size="large" place-holder="کلمه عبور"/>-->
<AInputPassword v-model:value="userFormState.password" place-holder="کلمه عبور" inputmode="decimal"/>
</a-form-item>
<a-form-item class="home_appear_fade_in_down" label="کد معرف" name="referral_id">
<BasicInput :disabled="disableForm" v-model:value="userFormState.referral_id" place-holder="کد معرف"/>
<a-form-item
v-if="settingsStore.loaded && settingsStore.isReferralFieldVisible"
:rules="referralIdRules"
class="home_appear_fade_in_down"
:label="referralIdPlaceholder"
name="referral_id"
>
<BasicInput
:disabled="disableForm"
v-model:value="userFormState.referral_id"
:place-holder="referralIdPlaceholder"
/>
</a-form-item>
<!-- <a-form-item v-if="URLUserType() === 'customer'" :rules="[required()]" class="home_appear_fade_in_down"
label="نام فروشگاه" name="shop_name">
@@ -121,7 +131,7 @@ import type { User } from '@/models/login'
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
import { loading, URLUserType } from '@/utils'
import { onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref } from 'vue'
import type { FormInstance } from 'ant-design-vue'
import { message } from 'ant-design-vue'
import registerDelayImage from '@/assets/img/registerDelay.svg'
@@ -129,8 +139,17 @@ import DialogVantOneButton from '@/components/DialogVantOneButton.vue'
import { registerCustomer } from '@/api/login'
import router from '@/router'
import logo from "@/assets/img/logo_full_.png";
import { useSettingsStore } from '@/store/settingsStore'
const settingsStore = useSettingsStore()
const referralIdRules = computed(() =>
settingsStore.isReferralRequired ? [required('کد معرف')] : [],
)
const referralIdPlaceholder = computed(() =>
settingsStore.isReferralRequired ? 'کد معرف' : 'کد معرف (اختیاری)',
)
// const stepTwoVerify = ref<boolean>(false)
const registeredInfo = ref<boolean>(false)
@@ -148,13 +167,14 @@ async function handleOnComplete(value: string) {
userFormState.token = value
registerAccount()
}*/
onMounted(() => {
onMounted(async () => {
if (!settingsStore.loaded) {
await settingsStore.fetchSettings()
}
if (router.currentRoute.value.query.id){
userFormState.referral_id = router.currentRoute.value.query.id
disableForm.value=true
}
})
function registerAccount() {
@@ -166,7 +186,11 @@ function registerAccount() {
// if (!stepTwoVerify.value) {
URLUserType() === 'single' ? userFormState.type = 2 : userFormState.type = 1
// console.log(userFormState)
if (!userFormState.referral_id || userFormState.referral_id === '') delete userFormState.referral_id
if (!settingsStore.isReferralFieldVisible && !disableForm.value) {
delete userFormState.referral_id
} else if (!userFormState.referral_id || userFormState.referral_id === '') {
delete userFormState.referral_id
}
const { id } = await registerCustomer(userFormState)
registeredInfo.value = true
// console.log(registeredInfo.value)