diff --git a/src/api/home.ts b/src/api/home.ts index 97e784d..d230c2e 100644 --- a/src/api/home.ts +++ b/src/api/home.ts @@ -3,6 +3,7 @@ import type {Price} from "@/models/home"; export const getChart = async () => await useAxios.get>>(`/api/candle`) +/** @deprecated قیمت up داخل /api/price/last در فیلد up برمی‌گردد */ export const getPrice = async () => await useAxios.get(`/api/price/up`) export const getLastPrice = async () => await useAxios.get(`/api/price/last`) diff --git a/src/main.ts b/src/main.ts index 36e704b..b9f21dd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,6 +16,7 @@ import { getMe } from '@/api/me' import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router' import { useAuthStore } from '@/store/useAuthStore' import {applyProjectTheme, getConfigApp} from "@/utils/config"; +import { useSettingsStore } from '@/store/settingsStore' const app = createApp(App) @@ -30,6 +31,8 @@ const userStore = useUserStore() const walletStore = useWalletStore() const fundStore = useFundUserStore() const authStore = useAuthStore() +const settingsStore = useSettingsStore() +void settingsStore.fetchSettings() const isApple: boolean = isIphone() let isFirst: boolean = true let fingerPosition: boolean = false diff --git a/src/models/home.ts b/src/models/home.ts index 870c033..8ccf275 100644 --- a/src/models/home.ts +++ b/src/models/home.ts @@ -12,10 +12,21 @@ export interface Series { } */ +export interface PriceUp { + buy: number + sell: number +} + export interface Price { - sell: number - buy: number - price: number - price_last: number - goldir:number + sell: number + buy: number + price: number + price_last: number + goldir?: number + up?: PriceUp + closed?: boolean + time?: string + main_product?: number + taban_gohar?: number + montzar?: number } \ No newline at end of file diff --git a/src/models/products.ts b/src/models/products.ts index 95fca6c..d1973e8 100644 --- a/src/models/products.ts +++ b/src/models/products.ts @@ -53,6 +53,7 @@ export interface PInventory { deleted_at: any price?:number unit?: string + direct_price?: number wallet:Wallet } diff --git a/src/store/settingsStore.ts b/src/store/settingsStore.ts new file mode 100644 index 0000000..a266b9d --- /dev/null +++ b/src/store/settingsStore.ts @@ -0,0 +1,74 @@ +import { computed, ref } from 'vue' +import { defineStore } from 'pinia' +import { getSettings } from '@/api/configuration' +import { resolveMeltedGoldLabel, resolveMetalTypeLabel } from '@/utils/metalLabels' + +export interface AppSetting { + id?: number + key?: string | number + title_fa?: string + value?: string | number + description?: string + is_active?: boolean + type?: string +} + +export const useSettingsStore = defineStore('settings', () => { + const settings = ref([]) + const loaded = ref(false) + + function getSettingByKey(key: string) { + const item = settings.value.find((setting) => setting?.key === key) + return item?.value ?? null + } + + function mergeSettings(items?: AppSetting[] | null) { + if (!items?.length) { + return + } + + const merged = [...settings.value] + items.forEach((item) => { + if (!item?.key) { + return + } + + const index = merged.findIndex((setting) => setting.key === item.key) + if (index >= 0) { + merged[index] = { ...merged[index], ...item } + } else { + merged.push(item) + } + }) + + settings.value = merged + } + + async function fetchSettings() { + try { + const data = await getSettings() + if (Array.isArray(data)) { + mergeSettings(data) + } + } catch (e) { + console.log(e) + } finally { + loaded.value = true + } + } + + const metalTypeSettingValue = computed(() => getSettingByKey('metal_type')) + const metalTypeLabel = computed(() => resolveMetalTypeLabel(metalTypeSettingValue.value)) + const meltedGoldLabel = computed(() => resolveMeltedGoldLabel(metalTypeSettingValue.value)) + + return { + settings, + loaded, + fetchSettings, + mergeSettings, + getSettingByKey, + metalTypeSettingValue, + metalTypeLabel, + meltedGoldLabel, + } +}) diff --git a/src/store/userStore.ts b/src/store/userStore.ts index e4d714b..dbcdca2 100644 --- a/src/store/userStore.ts +++ b/src/store/userStore.ts @@ -4,6 +4,7 @@ import { defineStore } from 'pinia' import { getMe } from '@/api/me' import type { User } from '@/models/login' import { useWalletStore } from '@/store/walletStore' +import { useSettingsStore } from '@/store/settingsStore' import { setFingerPrint } from '@/utils' import type { PWallet } from '@/models/wallet' @@ -17,6 +18,7 @@ export const useUserStore = defineStore('user', () => { async function getMyInfo() { try { userInfo.value = await getMe() + useSettingsStore().mergeSettings(userInfo.value.settings) setFingerPrint(userInfo.value.finger_print.toString()) productWallet.value = userInfo.value.pwallet // return userInfo.value diff --git a/src/utils/inputRules.ts b/src/utils/inputRules.ts index 238f928..1e0e1b0 100644 --- a/src/utils/inputRules.ts +++ b/src/utils/inputRules.ts @@ -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(); diff --git a/src/utils/metalLabels.ts b/src/utils/metalLabels.ts new file mode 100644 index 0000000..7d03def --- /dev/null +++ b/src/utils/metalLabels.ts @@ -0,0 +1,9 @@ +export function resolveMetalTypeLabel(settingValue?: string | number | null): string { + const value = settingValue?.toString().trim() + return value ? value : 'طلا' +} + +export function resolveMeltedGoldLabel(settingValue?: string | number | null): string { + const value = settingValue?.toString().trim() + return value ? value : 'آبشده' +} diff --git a/src/utils/price.ts b/src/utils/price.ts index 1b9b0ca..88df9b3 100644 --- a/src/utils/price.ts +++ b/src/utils/price.ts @@ -1,87 +1,94 @@ -import {loading} from '@/utils/index' -import {getLastPrice, getPrice} from '@/api/home' -import {ref} from 'vue' -import type {Price} from '@/models/home' +import { getLastPrice, getPrice } from '@/api/home' +import type { Price, PriceUp } from '@/models/home' +import { ref } from 'vue' -let interval: any +let interval: ReturnType | undefined + +/** @deprecated از lastPrice استفاده کنید — برای سازگاری با کد قدیمی sync می‌شود */ export const price = ref() export const lastPrice = ref() -export const olderPrice = ref(0) +export const olderPrice = ref(0) + +/** buy/sell نمایش و معامله — همان buy/sell/price_last از /api/price/last */ +export function getTradeBuyPrice(p?: Price | null) { + return p?.buy ?? p?.price_last ?? p?.up?.buy ?? 0 +} + +export function getTradeSellPrice(p?: Price | null) { + return p?.sell ?? p?.up?.sell ?? 0 +} + +/** up جدا نگه داشته می‌شود؛ buy/sell/price_last از lastPrice سرور دست‌نخورده می‌ماند */ +export function normalizePriceResponse(data: Price): Price { + return data +} export async function setIntervalGetAllPrice() { - // console.log('salam') - try { - interval = setInterval(async () => { - await getLastPrices() - await getUpPrice() - }, 10000) - } catch (e) { - console.log(e) - } finally { - loading.value = false - } - + try { + interval = setInterval(async () => { + await getLastPrices() + }, 10000) + } catch (e) { + console.log(e) + } } export async function setIntervalGetLastPrice() { - // console.log('salam') - try { - interval = setInterval(async () => { - await getLastPrices() - // await getUpPrice() - }, 10000) - } catch (e) { - console.log(e) - } finally { - loading.value = false - } - + return setIntervalGetAllPrice() } +/** @deprecated فقط getLastPrices را صدا بزنید */ export async function getUpPrice() { - try { - // loading.value = true - const data = await getPrice() - // const dataLast = await getLastPrice() - // if (lastPrice.value?.price_last != dataLast.price_last) { - // olderPrice.value = lastPrice.value?.price_last - // } - price.value = data - // lastPrice.value = dataLast - } catch (e) { - console.log(e) - } finally { - // loading.value = false + await getLastPrices() +} + +async function fetchUpPrices(): Promise { + try { + const up = await getPrice() + if (up?.buy != null && up?.sell != null) { + return { buy: up.buy, sell: up.sell } } + } catch (e) { + console.log(e) + } } export async function getLastPrices() { - try { - // loading.value = true - // const data = await getPrice() - const dataLast = await getLastPrice() - if (lastPrice.value?.price_last != dataLast.price_last) { - olderPrice.value = lastPrice.value?.price_last - } - // price.value = data - lastPrice.value = dataLast - } catch (e) { - console.log(e) - } finally { - // loading.value = false + try { + let dataLast = await getLastPrice() + + if (!dataLast?.up) { + const up = await fetchUpPrices() + if (up) { + dataLast = { ...dataLast, up } + } } + + const normalized = normalizePriceResponse(dataLast) + if (lastPrice.value?.price_last != normalized.price_last) { + olderPrice.value = lastPrice.value?.price_last + } + lastPrice.value = normalized + price.value = { + ...normalized, + buy: getTradeBuyPrice(normalized), + sell: getTradeSellPrice(normalized), + } + } catch (e) { + console.log(e) + } } export function stopPriceInterval() { - // console.log('stop') - clearInterval(interval); + if (interval) { + clearInterval(interval) + interval = undefined + } } export function percentPriceChanged() { - // console.log(olderPrice.value) - // console.log(lastPrice.value?.price_last) - if (!olderPrice.value) - return 0 -return ((lastPrice.value?.price_last-olderPrice.value) *100)/olderPrice.value - - } \ No newline at end of file + if (!olderPrice.value) { + return 0 + } + return ((lastPrice.value?.price_last! - olderPrice.value) * 100) / olderPrice.value +} diff --git a/src/utils/productDealMethod.ts b/src/utils/productDealMethod.ts index b9215d0..4473f5d 100644 --- a/src/utils/productDealMethod.ts +++ b/src/utils/productDealMethod.ts @@ -1,31 +1,13 @@ import type { SelectItem } from '@/models/SelectItem' import { isBoursecuProject } from '@/utils/config' +import { useSettingsStore } from '@/store/settingsStore' +/** شناسه group_type محصول در دیتابیس — نه برچسب نمایشی */ export const BOURSECU_GROUP_MAFTOL = 'مفتول مس' export const BOURSECU_GROUP_KATOD = 'کاتد مس' export const BOURSECU_GROUP_ABSHODE = 'آبشده' -export const BOURSECU_ASSET_LABEL_KATOD = 'دارایی کاتد مس' -export const BOURSECU_ASSET_LABEL_MAFTOL = 'دارایی مفتول مس' -export const BOURSECU_ASSET_LABEL_GOLD = 'دارایی طلایی' - -const DEFAULT_TYPE_DEAL: SelectItem[] = [ - { value: 'نقدی', key: 'cash' }, - { value: 'طلایی', key: 'gold' }, -] - -const MAFTOL_TYPE_DEAL: SelectItem[] = [ - { value: BOURSECU_GROUP_KATOD, key: 'katod' }, - { value: 'نقدی', key: 'cash' }, -] - -const CASH_ONLY_TYPE_DEAL: SelectItem[] = [ - { value: 'نقدی', key: 'cash' }, -] - -const GOLD_ONLY_TYPE_DEAL: SelectItem[] = [ - { value: 'طلایی', key: 'gold' }, -] +export const BOURSECU_WALLET_LABEL_GENERIC = 'موجودی کیف' export function normalizeProductGroupType(groupType?: string | null) { return (groupType ?? '').trim() @@ -54,24 +36,150 @@ export function isGoldOnlyDealGroup(groupType?: string | null) { return normalizeProductGroupType(groupType) === BOURSECU_GROUP_ABSHODE } +export interface ProductUnitSource { + unit?: string | null + direct_price?: number | null + group_type?: string | null + amount?: number | null +} + +const COUNT_BASED_GROUP_TYPES = ['سکه', 'گوی', 'مکعب', 'شمش', 'سکه پارسیان'] + +/** مطابق ادمین: وزن «دارد» یعنی amount مقدار واقعی است؛ «ندارد» یعنی amount = 1 */ +export function hasProductUnitWeight(product?: ProductUnitSource | null) { + const amount = Number(product?.amount ?? 0) + return amount > 0 && amount !== 1 +} + +export function getProductWeightUnit(product?: ProductUnitSource | null) { + if (isBoursecuProject()) { + const group = normalizeProductGroupType(product?.group_type) + if (group === BOURSECU_GROUP_MAFTOL || group === BOURSECU_GROUP_KATOD || group === BOURSECU_GROUP_ABSHODE) { + return getWeightUnit() + } + } + + if (!isCountBasedProduct(product) || isGoldOnlyDealGroup(product?.group_type)) { + return getWeightUnit() + } + + return 'گرم' +} + +export function formatProductWeightAmount(amount?: number | null, product?: ProductUnitSource | null) { + const value = Number(amount ?? 0) + const weightUnit = getProductWeightUnit(product) + + if (weightUnit === 'گرم' && value > 0 && value < 1) { + return `${value * 1000} سوت` + } + + return `${value} ${weightUnit}` +} + +export function getProductUnitWeightLabel(product?: ProductUnitSource | null) { + if (!hasProductUnitWeight(product)) { + return null + } + + return formatProductWeightAmount(product?.amount, product) +} + +export function getProductTotalWeightLabel(count?: number | null, product?: ProductUnitSource | null) { + if (!hasProductUnitWeight(product)) { + return null + } + + const quantity = Number(count ?? 0) + return formatProductWeightAmount(quantity * Number(product?.amount ?? 0), product) +} + +export function shouldShowProductTotalWeight(product?: ProductUnitSource | null) { + if (!product) { + return false + } + + if (!isCountBasedProduct(product)) { + return true + } + + return hasProductUnitWeight(product) +} + +export function formatProductInventoryBalance(product?: (ProductUnitSource & { wallet?: { gold?: number | null } }) | null) { + const count = product?.wallet?.gold ?? 0 + const quantityPart = `${count} ${getProductQuantityUnit(product)}` + const unitWeight = getProductUnitWeightLabel(product) + + if (!unitWeight) { + return quantityPart + } + + return `${quantityPart} · هر عدد ${unitWeight}` +} + +/** محصول تعدادی: موجودی wallet.gold = تعداد قلم، نه وزن */ +export function isCountBasedProduct(product?: ProductUnitSource | null) { + if (!product) { + return false + } + + if (product.direct_price != null && product.direct_price !== 0) { + return true + } + + const group = normalizeProductGroupType(product.group_type) + if (group === BOURSECU_GROUP_MAFTOL || group === BOURSECU_GROUP_KATOD) { + return true + } + + return COUNT_BASED_GROUP_TYPES.includes(group) +} + +export function getProductQuantityUnit(product?: ProductUnitSource | null) { + if (isCountBasedProduct(product)) { + return 'عدد' + } + + const unit = product?.unit?.trim() + if (unit) { + return unit + } + + return getWeightUnit() +} + +function getDefaultTypeDealOptions(): SelectItem[] { + const settingsStore = useSettingsStore() + return [ + { value: 'نقدی', key: 'cash' }, + { value: settingsStore.metalTypeLabel, key: 'gold' }, + ] +} + export function getProductDealMethodOptions(groupType?: string | null): SelectItem[] { + const settingsStore = useSettingsStore() + if (!isBoursecuProject()) { - return DEFAULT_TYPE_DEAL + return getDefaultTypeDealOptions() } if (isMaftolMesGroup(groupType)) { - return MAFTOL_TYPE_DEAL + return [ + { value: settingsStore.metalTypeLabel, key: 'katod' }, + { value: 'نقدی', key: 'cash' }, + ] } if (isKatodMesGroup(groupType)) { - return CASH_ONLY_TYPE_DEAL + return [{ value: 'نقدی', key: 'cash' }] } if (isGoldOnlyDealGroup(groupType)) { - return GOLD_ONLY_TYPE_DEAL + return [{ value: settingsStore.meltedGoldLabel, key: 'gold' }] } - return DEFAULT_TYPE_DEAL + return getDefaultTypeDealOptions() } export function getDefaultProductDealMethod(groupType?: string | null) { @@ -79,30 +187,66 @@ export function getDefaultProductDealMethod(groupType?: string | null) { } export function isCashLikeDealMethod(method?: string | null) { - return method === 'cash' || method === 'katod' + return method === 'cash' } -export const BOURSECU_WALLET_LABEL_GENERIC = 'موجودی کیف' +export function isMainMetalWalletDealMethod(method?: string | null) { + return method === 'gold' || method === 'katod' +} + +/** برچسب کیف فلز اصلی (main wallet gold) — از setting metal_type */ +export function getMainMetalWalletLabel() { + return `موجودی کیف ${useSettingsStore().metalTypeLabel}` +} + +/** برچسب کیف آبشده — از setting metal_type */ +export function getMeltedGoldWalletLabel() { + return `موجودی کیف ${useSettingsStore().meltedGoldLabel}` +} export function getGoldWalletLabel(groupType?: string | null) { - if (!isBoursecuProject()) return 'موجودی کیف طلا' + const settingsStore = useSettingsStore() + + if (!isBoursecuProject()) { + return getMainMetalWalletLabel() + } const group = normalizeProductGroupType(groupType) - if (group === BOURSECU_GROUP_KATOD) return `موجودی کیف ${BOURSECU_GROUP_KATOD}` - if (group === BOURSECU_GROUP_MAFTOL) return `موجودی کیف ${BOURSECU_GROUP_MAFTOL}` - if (group === BOURSECU_GROUP_ABSHODE) return 'موجودی کیف طلا' + if (group === BOURSECU_GROUP_MAFTOL) { + return `موجودی کیف ${BOURSECU_GROUP_MAFTOL}` + } + if (group === BOURSECU_GROUP_KATOD || group === BOURSECU_GROUP_ABSHODE || !group) { + return group === BOURSECU_GROUP_ABSHODE + ? getMeltedGoldWalletLabel() + : getMainMetalWalletLabel() + } return BOURSECU_WALLET_LABEL_GENERIC } export function getCashWalletLabel(groupType?: string | null) { - if (!isBoursecuProject()) return 'موجودی کیف پول' + if (!isBoursecuProject()) { + return 'موجودی کیف پول' + } const group = normalizeProductGroupType(groupType) - if (group === BOURSECU_GROUP_KATOD) return `موجودی کیف ${BOURSECU_GROUP_KATOD}` - if (group === BOURSECU_GROUP_MAFTOL) return `موجودی کیف ${BOURSECU_GROUP_MAFTOL}` + if (group === BOURSECU_GROUP_MAFTOL) { + return `موجودی کیف ${BOURSECU_GROUP_MAFTOL}` + } - return BOURSECU_WALLET_LABEL_GENERIC + return 'موجودی کیف پول' +} + +export function getMetalAssetLabel() { + return `دارایی ${useSettingsStore().metalTypeLabel}` +} + +export function getMeltedGoldAssetLabel() { + return `دارایی ${useSettingsStore().meltedGoldLabel}` +} + +export function getMaftolAssetLabel() { + return `دارایی ${BOURSECU_GROUP_MAFTOL}` } export function getWeightUnit() { @@ -113,6 +257,10 @@ export function formatBoursecuAssetAmount(amount?: number | null) { return `${amount ?? 0}${getWeightUnit()}` } +export function formatMainMetalWalletBalanceText(gold: number) { + return `${getMainMetalWalletLabel()}: ${gold} ${getWeightUnit()}` +} + export function formatGoldWalletBalanceText(gold: number, groupType?: string | null) { return `${getGoldWalletLabel(groupType)}: ${gold} ${getWeightUnit()}` } @@ -128,3 +276,19 @@ export function getInsufficientGoldWalletMessage(groupType?: string | null) { export function getInsufficientCashWalletMessage(groupType?: string | null) { return `${getCashWalletLabel(groupType)} ناکافی است` } + +export function getInsufficientMainMetalWalletMessage() { + return `${getMainMetalWalletLabel()} ناکافی است` +} + +export function getMeltedGoldTradeLabel() { + return useSettingsStore().meltedGoldLabel +} + +export function getMetalTypeTradeLabel() { + return useSettingsStore().metalTypeLabel +} + +export function getTradePriceUnitLabel() { + return useSettingsStore().metalTypeLabel +} diff --git a/src/utils/productPrice.ts b/src/utils/productPrice.ts index 623d04a..4843c67 100644 --- a/src/utils/productPrice.ts +++ b/src/utils/productPrice.ts @@ -1,10 +1,10 @@ import type { Product } from '@/models/products' -import { lastPrice } from '@/utils/price' +import { getTradeBuyPrice, getTradeSellPrice, lastPrice } from '@/utils/price' /** قیمت خرید نمایشی محصول (همان مقداری که در لیست و اکشن‌شیت نشان داده می‌شود) */ export function getProductBuyPrice(product: Product): number { if (product.group_type === 'آبشده') { - return lastPrice.value?.buy ?? 0 + return getTradeBuyPrice(lastPrice.value) + (product.cash_fee_buy ?? 0) } if (['مس', 'نقره'].includes(product.group_type)) { @@ -18,6 +18,14 @@ export function getProductBuyPrice(product: Product): number { : basePrice } +/** قیمت فروش نمایشی آبشده — فقط cash_fee_sell محصول اختلاف ایجاد می‌کند */ +export function getProductSellPrice(product: Product): number { + if (product.group_type === 'آبشده') { + return getTradeSellPrice(lastPrice.value) - (product.cash_fee_sell ?? 0) + } + return getTradeSellPrice(lastPrice.value) +} + export function isProductPriceInactive(product: Product): boolean { return getProductBuyPrice(product) <= 0 } diff --git a/src/views/base/copper&silver/index.vue b/src/views/base/copper&silver/index.vue index b3f8988..e4e6df0 100644 --- a/src/views/base/copper&silver/index.vue +++ b/src/views/base/copper&silver/index.vue @@ -232,7 +232,7 @@ import type { Transaction } from '@/models/transaction' import type { TableEngineInput, TableOutput } from '@/models/table' import { useInfiniteScroll } from '@vueuse/core' import { getTransactionTable } from '@/api/transaction' -import { getLastPrices, getUpPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price' +import { getLastPrices, getTradeBuyPrice, getTradeSellPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price' import type { Product } from '@/models/products' import { useFundUserStore } from '@/store/fundStore' import {useConfigStore} from "@/store/configStore"; @@ -327,7 +327,8 @@ const disableTransaction = computed(() => form.value?.goldCash === undefined || (isBuy.value ? (form.value?.goldCash ?? 0) < 500000 : (form.value?.goldValue ?? 0) < 0.001) || (!isBuy.value && form.value.goldValue > walletStore?.walletInfo?.gold) || - price.value?.buy === undefined) + !lastPrice.value || + (isBuy.value ? getTradeBuyPrice(lastPrice.value) <= 0 : getTradeSellPrice(lastPrice.value) <= 0)) function refreshTable() { sellItems.value = [] @@ -515,7 +516,7 @@ const limitedPrice = computed(() => { } }*/ function syncFormWithLatestPrice() { - if (!price.value) return + if (!lastPrice.value) return const goldValue = form.value.goldValue if (goldValue !== undefined && goldValue !== null && goldValue !== '' && !isNaN(Number(goldValue))) { @@ -538,26 +539,20 @@ watch( function calculateCash(val: number) { priceErrorVisible.value = false - if (price.value) { - form.value.goldVazn = parseFloat((val * (( props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy)))/lastPrice.value?.buy).toFixed(1) - if (isBuy.value) { - if (val) { - form.value.goldCash = parseFloat(val * (( props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy))).toFixed(0) - } - else { - form.value.goldCash = 0 - form.value.goldVazn = 0 - } - } - else { - if (val) - form.value.goldCash = parseFloat((val * props?.ProductItem?.price) - (props?.ProductItem?.cash_fee_sell)).toFixed(0) - else{ - form.value.goldCash = 0 - form.value.goldVazn = 0 - } - } - console.log(form.value.goldVazn) + if (!lastPrice.value) return + + const tradeBuy = getTradeBuyPrice(lastPrice.value) + form.value.goldVazn = parseFloat((val * ((props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy))) / tradeBuy).toFixed(1) + if (isBuy.value) { + form.value.goldCash = val + ? parseFloat(String(val * ((props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy)))) + : 0 + if (!val) form.value.goldVazn = 0 + } else { + form.value.goldCash = val + ? parseFloat(String((val * props?.ProductItem?.price) - (props?.ProductItem?.cash_fee_sell))) + : 0 + if (!val) form.value.goldVazn = 0 } } @@ -629,15 +624,14 @@ const price = computed((): Price => lastPrice.value ?? 0) const goldPriceValue = computed(() => { if (!lastPrice.value?.price) return 0 return isBuy.value - ? (lastPrice.value.buy ?? 0) - : (lastPrice.value.sell ?? 0) + ? getTradeBuyPrice(lastPrice.value) + : getTradeSellPrice(lastPrice.value) }) async function initPrice() { try { // chartLoading.value = true await getLastPrices() - await getUpPrice() await setIntervalGetAllPrice() loading.value = true } catch (e) { diff --git a/src/views/base/fund/components/Item.vue b/src/views/base/fund/components/Item.vue index a82bc8f..8d1c94c 100644 --- a/src/views/base/fund/components/Item.vue +++ b/src/views/base/fund/components/Item.vue @@ -9,7 +9,15 @@
{{props.item?.title?? '-'}}
-
{{props.item?.wallet?.gold?? '-'}}
{{props.item?.unit}}
+
+
+
{{ props.item?.wallet?.gold ?? '-' }}
+ {{ getProductQuantityUnit(props.item) }} +
+
+ هر عدد {{ getProductUnitWeightLabel(props.item) }} +
+
@@ -30,6 +38,7 @@ import sekkeImg from "@/assets/img/sekkeImg.svg" import type { Product } from '@/models/products' import mesImg from "@/assets/img/mesImg.jpg"; import noghrehImg from "@/assets/img/noghrehImg.webp"; +import { getProductQuantityUnit, getProductUnitWeightLabel } from '@/utils/productDealMethod' /*function itemImg() { }*/ diff --git a/src/views/base/fund/index.vue b/src/views/base/fund/index.vue index f65a09a..17ddea4 100644 --- a/src/views/base/fund/index.vue +++ b/src/views/base/fund/index.vue @@ -10,33 +10,6 @@
موجودی دارایی ها
- -
@@ -99,7 +71,7 @@ import BasicModal from "@/components/BasicPacks/BasicModal.vue"; import img from '@/assets/img/user_ly1.svg' import empty from '@/assets/img/cash_empty.svg' import Item from './components/Item.vue' -import {onMounted, ref} from "vue"; +import {onMounted, ref, computed} from "vue"; import {loading} from "@/utils"; import type {TableOutput} from "@/models/table"; import type {Fund} from "@/models/fund"; @@ -110,13 +82,9 @@ import {usePriceWithoutType} from "../../../utils/usePrice"; import {useWalletStore} from "@/store/walletStore"; import {useConfigStore} from "@/store/configStore"; import { isBoursecuProject } from '@/utils/config' -import { - BOURSECU_ASSET_LABEL_GOLD, - BOURSECU_ASSET_LABEL_KATOD, - BOURSECU_ASSET_LABEL_MAFTOL, - formatBoursecuAssetAmount, -} from '@/utils/productDealMethod' +import { formatBoursecuAssetAmount, getMetalAssetLabel, getWeightUnit } from '@/utils/productDealMethod' const nameProject = useConfigStore().config.name +const metalAssetLabel = computed(() => getMetalAssetLabel()) const items = ref([]) const tableOutput = ref | null>(null) diff --git a/src/views/base/gold/index.vue b/src/views/base/gold/index.vue index 0efecf9..d1ec275 100644 --- a/src/views/base/gold/index.vue +++ b/src/views/base/gold/index.vue @@ -6,11 +6,11 @@
- خرید طلا {{ props?.ProductItem?.title }} + خرید {{ meltedGoldLabel }} {{ props?.ProductItem?.title }}
- فروش طلا {{ props?.ProductItem?.title }} + فروش {{ meltedGoldLabel }} {{ props?.ProductItem?.title }}
مظنه:
-
{{ usePriceWithoutType(isBuy ? price.buy ?? 0 : price.sell ?? 0) }}
+
{{ usePriceWithoutType(isBuy ? getTradeBuyPrice(lastPrice) : getTradeSellPrice(lastPrice)) }}
ریال
@@ -227,16 +227,21 @@ import type { Transaction } from '@/models/transaction' import type { TableEngineInput, TableOutput } from '@/models/table' import { useInfiniteScroll } from '@vueuse/core' import { getTransactionTable } from '@/api/transaction' -import { getLastPrices, getUpPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price' +import { getProductBuyPrice, getProductSellPrice } from '@/utils/productPrice' +import { getLastPrices, getTradeBuyPrice, getTradeSellPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price' import type { Product } from '@/models/products' import { useFundUserStore } from '@/store/fundStore' import {useConfigStore} from "@/store/configStore"; import { calcFeeInGrams, loadServiceFeeFromSettings } from '@/utils/serviceFee' import { formatCashWalletBalanceText, formatGoldWalletBalanceText } from '@/utils/productDealMethod' +import { useSettingsStore } from '@/store/settingsStore' +import { storeToRefs } from 'pinia' const infoVisible = ref(false) const walletStore = useWalletStore() const userStore = useUserStore() +const settingsStore = useSettingsStore() +const { meltedGoldLabel } = storeToRefs(settingsStore) const fundStore = useFundUserStore() const confirmAction = ref(false) const noCompleteVisible = ref(false) @@ -273,9 +278,13 @@ const sellPagination = ref({ }], limit: 6, page: 0 }) -const unitPrice = computed(() => - isBuy.value ? price.value?.buy ?? 0 : price.value?.sell ?? 0 -) +const unitPrice = computed(() => { + const product = props.ProductItem + if (product?.group_type === 'آبشده') { + return isBuy.value ? getProductBuyPrice(product) : getProductSellPrice(product) + } + return isBuy.value ? getTradeBuyPrice(lastPrice.value) : getTradeSellPrice(lastPrice.value) +}) const feeInGrams = computed(() => calcFeeInGrams(form.value?.goldValue)) const finalPrice = computed(() => (form.value?.goldValue ?? 0) * unitPrice.value) const feeInRial = computed(() => unitPrice.value * feeInGrams.value) @@ -292,7 +301,8 @@ const disableTransaction = computed(() => form.value?.goldCash === undefined || (isBuy.value ? (form.value?.goldCash ?? 0) < 500000 : (form.value?.goldValue ?? 0) < 0.001) || (!isBuy.value && form.value.goldValue > walletStore?.walletInfo?.gold) || - price.value?.buy === undefined) + !lastPrice.value || + (isBuy.value ? getTradeBuyPrice(lastPrice.value) <= 0 : getTradeSellPrice(lastPrice.value) <= 0)) function refreshTable() { sellItems.value = [] @@ -468,7 +478,7 @@ const limitedPrice = computed(() => { }) function syncFormWithLatestPrice() { - if (!price.value) return + if (!lastPrice.value) return const goldValue = form.value.goldValue if (goldValue !== undefined && goldValue !== null && goldValue !== '' && !isNaN(Number(goldValue))) { @@ -483,7 +493,7 @@ function syncFormWithLatestPrice() { } watch( - () => [lastPrice.value?.buy, lastPrice.value?.sell, isBuy.value], + () => [getTradeBuyPrice(lastPrice.value), getTradeSellPrice(lastPrice.value), isBuy.value], () => { syncFormWithLatestPrice() } @@ -491,48 +501,36 @@ watch( function calculateCash(val: number) { priceErrorVisible.value = false - // console.log(val) - if (price.value) { - if (isBuy.value) { - if (val) form.value.goldCash = parseFloat((val * price?.value?.buy).toFixed(0)) - else form.value.goldCash = undefined - } else { - if (val) form.value.goldCash = parseFloat((val * price?.value?.sell).toFixed(0)) - else form.value.goldCash = undefined - } - } + if (!lastPrice.value) return + + const unit = isBuy.value ? getTradeBuyPrice(lastPrice.value) : getTradeSellPrice(lastPrice.value) + form.value.goldCash = val ? parseFloat((val * unit).toFixed(0)) : undefined } function calculateGold(val: number) { - // console.log(val) - // form.value.goldCash = usePriceWithoutType(form.value.goldCash) - if (price.value) { - if (isBuy.value) { - if (val) { - form.value.goldValue = toFixedDownThreeChar(parseFloat(val / price?.value?.buy)) - if (parseInt(finalPrice.value) > 0) priceErrorVisible.value = true - if (parseInt(finalPrice.value) === 0) priceErrorVisible.value = false - } else if (val.toString() === '') { - form.value.goldValue = undefined - priceErrorVisible.value = false - } else { - form.value.goldValue = 0 - priceErrorVisible.value = false - } + if (!lastPrice.value) return + + const unit = isBuy.value ? getTradeBuyPrice(lastPrice.value) : getTradeSellPrice(lastPrice.value) + if (isBuy.value) { + if (val) { + form.value.goldValue = toFixedDownThreeChar(parseFloat(String(val / unit))) + priceErrorVisible.value = parseInt(finalPrice.value) > 0 + } else if (val.toString() === '') { + form.value.goldValue = undefined + priceErrorVisible.value = false } else { - if (val) { - form.value.goldValue = toFixedDownThreeChar(parseFloat((val / price?.value?.sell))) - if (parseInt(finalPrice.value) > 0) priceErrorVisible.value = true - if (parseInt(finalPrice.value) === 0) priceErrorVisible.value = false - } else if (val.toString() === '') { - // console.log('sasasasasasa') - form.value.goldValue = undefined - priceErrorVisible.value = false - } else { - form.value.goldValue = 0 - priceErrorVisible.value = false - } + form.value.goldValue = 0 + priceErrorVisible.value = false } + } else if (val) { + form.value.goldValue = toFixedDownThreeChar(parseFloat(String(val / unit))) + priceErrorVisible.value = parseInt(finalPrice.value) > 0 + } else if (val.toString() === '') { + form.value.goldValue = undefined + priceErrorVisible.value = false + } else { + form.value.goldValue = 0 + priceErrorVisible.value = false } } @@ -573,18 +571,16 @@ const formatter = (value: number) => { const price = computed((): Price => lastPrice.value ?? 0) const goldPriceValue = computed(() => { - // if (!price.value) return 0 if (!lastPrice.value?.price) return 0 - return isBuy.value - ? (price.value.buy ?? 0) - : (price.value.sell ?? 0) + return isBuy.value + ? getTradeBuyPrice(lastPrice.value) + : getTradeSellPrice(lastPrice.value) }) async function initPrice() { try { // chartLoading.value = true await getLastPrices() - await getUpPrice() await setIntervalGetAllPrice() loading.value = true } catch (e) { @@ -605,7 +601,7 @@ async function ok() { infoVisible.value = true await createOrder({ direction: isBuy.value ? 1 : 2, - price: isBuy.value ? price.value?.buy : price.value?.sell, + price: isBuy.value ? getTradeBuyPrice(lastPrice.value) : getTradeSellPrice(lastPrice.value), amount: form.value.goldValue ?? 0 }) await walletStore.getMyWallet() diff --git a/src/views/base/home/components/AssetsSection.vue b/src/views/base/home/components/AssetsSection.vue index 138115d..2994dea 100644 --- a/src/views/base/home/components/AssetsSection.vue +++ b/src/views/base/home/components/AssetsSection.vue @@ -4,8 +4,8 @@ محصولات:
{{ userStore?.userInfo?.wallet?.count_product ?? 0 }} عدد
-
- دارایی طلایی: +
+ {{ metalAssetLabel }}:
{{ (userStore?.userInfo?.wallet?.count_gold ?? 0).toFixed(3) }} گرم
@@ -18,11 +18,15 @@ \ No newline at end of file diff --git a/src/views/base/home/components/ProductInventory.vue b/src/views/base/home/components/ProductInventory.vue index 2a2f8ac..01b7469 100644 --- a/src/views/base/home/components/ProductInventory.vue +++ b/src/views/base/home/components/ProductInventory.vue @@ -10,15 +10,24 @@
-
+
+
-
+ +
{{userWallet.walletInfo?.gold??0}} - {{props?.ProductItem.wallet?.gold??0}} - {{props?.ProductItem?.unit}} + {{ props?.ProductItem.wallet?.gold ?? 0 }} + {{ getProductQuantityUnit(props.ProductItem) }} +
+
+
+ هر عدد {{ getProductUnitWeightLabel(props.ProductItem) }}
@@ -30,6 +39,7 @@ import BasicIcon from "@/components/BasicPacks/BasicIcon.vue"; import type {PInventory} from "@/models/products"; import {useWalletStore} from "../../../../store/walletStore"; +import { getProductQuantityUnit, getProductUnitWeightLabel } from '@/utils/productDealMethod' interface Prop { ProductItem: PInventory } diff --git a/src/views/base/home/index.vue b/src/views/base/home/index.vue index 80008d8..4682baf 100644 --- a/src/views/base/home/index.vue +++ b/src/views/base/home/index.vue @@ -85,7 +85,7 @@ import {useWalletStore} from '@/store/walletStore' import {useConfigStore} from '@/store/configStore' import {useFundUserStore} from '@/store/fundStore' import {usePrice, usePriceWithoutType} from '../../../utils/usePrice' -import {getLastPrices, getUpPrice, lastPrice, price, setIntervalGetAllPrice, stopPriceInterval} from '@/utils/price' +import {getLastPrices, lastPrice, price, setIntervalGetAllPrice, stopPriceInterval} from '@/utils/price' import {getConstByKey} from '@/api/const' import {message, Modal} from 'ant-design-vue' @@ -260,7 +260,6 @@ onMounted(async () => { await Promise.all([ loadFunds(), getLastPrices(), - getUpPrice(), fetchPrices(), setIntervalGetAllPrice(), loadBanners() diff --git a/src/views/base/physicalReceive/components/NewRequest.vue b/src/views/base/physicalReceive/components/NewRequest.vue index 7d14221..8ba6de5 100644 --- a/src/views/base/physicalReceive/components/NewRequest.vue +++ b/src/views/base/physicalReceive/components/NewRequest.vue @@ -32,15 +32,20 @@
تعداد موجودی:
-
-
{{ val.product.wallet.gold }}
-
{{ val.product.unit }}
+
+
+
{{ val.product.wallet.gold }}
+
{{ getProductQuantityUnit(val.product) }}
+
+
+ هر عدد {{ getProductUnitWeightLabel(val.product) }} +
تعداد درخواستی:
- +
@@ -104,6 +109,7 @@ import {message} from "ant-design-vue" import New_EditAddress from "@/views/base/address/components/New_EditAddress.vue" import mesImg from "@/assets/img/mesImg.jpg"; import noghrehImg from "@/assets/img/noghrehImg.webp"; +import { getProductQuantityUnit, getProductUnitWeightLabel } from '@/utils/productDealMethod' const items = ref() const baseItems = ref() diff --git a/src/views/base/physicalReceive/index.vue b/src/views/base/physicalReceive/index.vue index 4216a2a..6508706 100644 --- a/src/views/base/physicalReceive/index.vue +++ b/src/views/base/physicalReceive/index.vue @@ -5,8 +5,8 @@
-
دریافت طلای فیزیکی
-
دریافت طلای فیزیکی-درخواست جدید
+
دریافت فیزیکی
+
دریافت فیزیکی-درخواست جدید
diff --git a/src/views/base/products/components/DealProduct.vue b/src/views/base/products/components/DealProduct.vue index c79dd90..ed296c7 100644 --- a/src/views/base/products/components/DealProduct.vue +++ b/src/views/base/products/components/DealProduct.vue @@ -79,20 +79,27 @@
{{ usePrice(form.goldCash ?? 0) }}
-
-
وزن کل
-
{{ form.goldVazn ?? 0 }} {{ getWeightUnit() }}
+
+
وزن کل
+
{{ totalWeightDisplay }}
+
+
+
وزن هر عدد
+
{{ getProductUnitWeightLabel(props?.ProductItem) }}
-
-
{{ goldWalletBalanceText }}
+
+
{{ buyMetalWalletBalanceText }}
-
+
{{ cashWalletBalanceText }}
-
{{ `موجودی محصول: ${getInventoryById(props?.ProductItem?.id)}` }} +
{{ `موجودی محصول: ${getInventoryById(props?.ProductItem?.id)} ${getProductQuantityUnit(props?.ProductItem)}` }}
@@ -184,7 +191,7 @@
{{ form.goldValue }}
عدد
-
عدد {{ props?.ProductItem?.title }}
+
{{ props?.ProductItem?.title }}
@@ -250,7 +257,7 @@ import BasicIcon from '@/components/BasicPacks/BasicIcon.vue' import type { Transaction } from '@/models/transaction' import type { TableEngineInput, TableOutput } from '@/models/table' import { getTransactionTable } from '@/api/transaction' -import { getLastPrices, lastPrice} from '@/utils/price' +import { getLastPrices, getTradeBuyPrice, getTradeSellPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price' import { Product } from '@/models/products' import BasicSelect from '@/components/BasicPacks/BasicSelect.vue' import Bg_main from '@/components/bg_main.vue' @@ -258,20 +265,46 @@ import { useFundUserStore } from '@/store/fundStore' import { getDefaultProductDealMethod, getProductDealMethodOptions, - isCashLikeDealMethod, formatCashWalletBalanceText, formatGoldWalletBalanceText, - getWeightUnit, + formatMainMetalWalletBalanceText, + formatProductWeightAmount, + getProductQuantityUnit, + getProductTotalWeightLabel, + getProductUnitWeightLabel, + hasProductUnitWeight, + isCountBasedProduct, + shouldShowProductTotalWeight, } from '@/utils/productDealMethod' const typeDeal = computed(() => getProductDealMethodOptions(props?.ProductItem?.group_type)) const productGroupType = computed(() => props?.ProductItem?.group_type) +const isCountBasedProductItem = computed(() => isCountBasedProduct(props?.ProductItem)) +const totalWeightDisplay = computed(() => { + const product = props?.ProductItem + if (!product) { + return formatProductWeightAmount(0, product) + } + + if (isCountBasedProductItem.value) { + return getProductTotalWeightLabel(form.value.goldValue, product) + ?? formatProductWeightAmount(0, product) + } + + return formatProductWeightAmount(form.value.goldVazn ?? 0, product) +}) const goldWalletBalanceText = computed(() => formatGoldWalletBalanceText(walletStore?.walletInfo?.gold ?? 0, productGroupType.value) ) +const buyMetalWalletBalanceText = computed(() => + form.value.method === 'katod' + ? formatMainMetalWalletBalanceText(walletStore?.walletInfo?.gold ?? 0) + : goldWalletBalanceText.value +) + const cashWalletBalanceText = computed(() => formatCashWalletBalanceText( usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0), @@ -352,7 +385,8 @@ const disableTransaction = computed(() => form.value?.goldCash === undefined || (isBuy.value ? (form.value?.goldCash ?? 0) < 500000 : (form.value?.goldValue ?? 0) < 0.001) || // (!isBuy.value && form.value.goldValue > walletStore?.walletInfo?.gold) || - price.value?.buy === undefined) + !lastPrice.value || + (isBuy.value ? getTradeBuyPrice(lastPrice.value) <= 0 : getTradeSellPrice(lastPrice.value) <= 0)) function refreshTable() { sellItems.value = [] @@ -557,8 +591,9 @@ function handleGoldValueChange(val: string | number | undefined) { function calculateCash(val: number) { priceErrorVisible.value = false - if (price.value) { - form.value.goldVazn = parseFloat(val * props?.ProductItem?.amount) + if (!lastPrice.value) return + + form.value.goldVazn = parseFloat(String(val * props?.ProductItem?.amount)) // form.value.goldVazn = parseFloat((val * (( props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy)))/lastPrice.value?.buy).toFixed(2) if (isBuy.value) { if (val){ @@ -589,7 +624,6 @@ function calculateCash(val: number) { form.value.goldVazn = 0 } } - } } /*function calculateGold(val: number) { @@ -673,9 +707,6 @@ async function initPrice() { await getLastPrices() // await setIntervalGetPrice() loading.value = true - price.value = lastPrice.value - /*props.ProductItem.price = lastPrice.value?.buy * props.ProductItem?.amount - props.ProductItem.sellPrice = lastPrice.value?.sell * props.ProductItem?.amount*/ props.ProductItem.price = lastPrice?.value?.price? (lastPrice?.value?.price + props.ProductItem?.cash_fee_buy) * props.ProductItem?.amount: 0 props.ProductItem.sellPrice = lastPrice?.value?.price? (lastPrice?.value?.price - props.ProductItem?.percent_fee_sell) * props.ProductItem?.amount:0 } catch (e) { diff --git a/src/views/base/products/components/DealProduct_old.vue b/src/views/base/products/components/DealProduct_old.vue index e8222d2..3e803fd 100644 --- a/src/views/base/products/components/DealProduct_old.vue +++ b/src/views/base/products/components/DealProduct_old.vue @@ -184,7 +184,7 @@
{{ form.goldValue }}
عدد
-
عدد {{ props?.ProductItem?.title }}
+
{{ props?.ProductItem?.title }}
diff --git a/src/views/base/products/components/ProductItem.vue b/src/views/base/products/components/ProductItem.vue index 12f2095..b9fa762 100644 --- a/src/views/base/products/components/ProductItem.vue +++ b/src/views/base/products/components/ProductItem.vue @@ -32,8 +32,7 @@ import type {Product} from "@/models/products"; import {usePrice} from '@/utils/usePrice'; import {getFileUrl} from '@/utils/file'; import {computed, ref} from "vue"; -import { lastPrice } from '@/utils/price' -import type { Price } from '@/models/home' +import { getProductBuyPrice } from '@/utils/productPrice' interface Prop { ProductItem: Product @@ -88,12 +87,7 @@ const price = computed(()=>{ } }) -const priceLast = computed((): Price => lastPrice.value ?? 0) - -const goldPriceValue = computed(() => { - if (!priceLast.value) return 0 - return priceLast.value.buy -}) +const goldPriceValue = computed(() => getProductBuyPrice(props.ProductItem)) diff --git a/src/views/base/products/index.vue b/src/views/base/products/index.vue index 6c381ba..235c6e7 100644 --- a/src/views/base/products/index.vue +++ b/src/views/base/products/index.vue @@ -219,9 +219,7 @@ async function initPrice() { try { // chartLoading.value = true await getLastPrices() - // await setIntervalGetPrice() loading.value = true - price.value = lastPrice.value } catch (e) { console.log(e) } finally { diff --git a/src/views/base/transactions/components/Item.vue b/src/views/base/transactions/components/Item.vue index c02e385..ba318bb 100644 --- a/src/views/base/transactions/components/Item.vue +++ b/src/views/base/transactions/components/Item.vue @@ -54,17 +54,25 @@
-
قیمت هر گرم طلا حین معامله:
+
قیمت هر گرم {{ getTradePriceUnitLabel() }} حین معامله:
{{ usePriceWithoutType(item.order?.price?? 0) }}
ریال
-
مقدار {{item.wallet?.product? item.wallet.product.title: 'آبشده' }} مبادله شده:
-
-
{{ item.gold }}
- {{item.unit}} +
مقدار {{ item.wallet?.product ? item.wallet.product.title : getMeltedGoldTradeLabel() }} مبادله شده:
+
+
+
{{ item.gold }}
+ {{ item.unit }} +
+
+ {{ getProductTotalWeightLabel(Math.abs(item.gold ?? 0), item.wallet.product) }} +
@@ -76,9 +84,14 @@
موجودی {{item.wallet.product.title}}:
-
-
{{ item.balance_gold }}
- {{item.wallet.product.unit}} +
+
+
{{ item.balance_gold }}
+ {{ getProductQuantityUnit(item.wallet.product) }} +
+
+ هر عدد {{ getProductUnitWeightLabel(item.wallet.product) }} +
@@ -138,7 +151,7 @@ import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue' import { computed, ref } from 'vue' import BasicButton from '@/components/BasicPacks/BasicButton.vue' import type { Transaction } from '@/models/transaction' -import { getCashWalletLabel, getGoldWalletLabel, getWeightUnit } from '@/utils/productDealMethod' +import { getCashWalletLabel, getGoldWalletLabel, getMeltedGoldTradeLabel, getProductQuantityUnit, getProductTotalWeightLabel, getProductUnitWeightLabel, getTradePriceUnitLabel, getWeightUnit } from '@/utils/productDealMethod' import { toJalaliNotime, toJalaliOutOfUTC, toTime } from '../../../../utils/useDateTime' const infoVisible = ref(false) diff --git a/src/views/base/wallet/components/Item.vue b/src/views/base/wallet/components/Item.vue index 7900222..ac98f43 100644 --- a/src/views/base/wallet/components/Item.vue +++ b/src/views/base/wallet/components/Item.vue @@ -65,14 +65,14 @@
-
مقدار طلا مبادله شده:
+
مقدار {{ getMetalTypeTradeLabel() }} مبادله شده:
{{ item.gold }}
گرم
-
قیمت هر گرم طلا حین معامله:
+
قیمت هر گرم {{ getTradePriceUnitLabel() }} حین معامله:
{{ usePriceWithoutType(item.order?.price?? 0) }}
ریال @@ -143,7 +143,7 @@ import BasicActionSheet from "@/components/BasicPacks/BasicActionSheet.vue"; import {computed, ref} from "vue"; import BasicButton from "@/components/BasicPacks/BasicButton.vue"; import type {Transaction} from "@/models/transaction"; -import {getCashWalletLabel, getGoldWalletLabel, getWeightUnit} from '@/utils/productDealMethod' +import {getCashWalletLabel, getGoldWalletLabel, getMetalTypeTradeLabel, getTradePriceUnitLabel, getWeightUnit} from '@/utils/productDealMethod' import {toJalaliNotime, toJalaliOutOfUTC, toTime} from "../../../../utils/useDateTime"; const infoVisible = ref(false) diff --git a/src/views/login/components/Login.vue b/src/views/login/components/Login.vue index 1158bd1..61bc8d7 100644 --- a/src/views/login/components/Login.vue +++ b/src/views/login/components/Login.vue @@ -43,10 +43,21 @@
- - + + @@ -255,6 +266,7 @@ import { loginCustomer, verifyToken } from '@/api/login' import router from '@/router' import { useUserStore } from '@/store/userStore' import { useWalletStore } from '@/store/walletStore' +import { useSettingsStore } from '@/store/settingsStore' import { fingerPosition, setTruth } from '@/main' import {useConfigStore} from "@/store/configStore"; import {getConfigApp, getProjectLoginLogo, getProjectLoginTaglineLines, isBoursecuProject} from "@/utils/config"; @@ -420,10 +432,9 @@ async function installWebApp() { } const isRegister = ref() async function isOpenRegister() { - const settings = await getSettings() - if (settings && Array.isArray(settings)) { - isRegister.value = settings.find(s => s?.key === 'open_register' && s?.is_active === true) - } + const settingsStore = useSettingsStore() + await settingsStore.fetchSettings() + isRegister.value = settingsStore.settings.find(s => s?.key === 'open_register' && s?.is_active === true) } async function proceedWithInstall() { diff --git a/src/views/login/components/PhoneVerify.vue b/src/views/login/components/PhoneVerify.vue index d2ab182..a53deab 100644 --- a/src/views/login/components/PhoneVerify.vue +++ b/src/views/login/components/PhoneVerify.vue @@ -2,7 +2,7 @@
ورود / ثبت نام
- +
مالکیت شماره باید به نام خودتان باشد
@@ -30,7 +30,7 @@