fix bug of register page

This commit is contained in:
2026-06-06 17:43:46 +03:30
32 changed files with 823 additions and 464 deletions
+1
View File
@@ -3,6 +3,7 @@ import type {Price} from "@/models/home";
export const getChart = async () => await useAxios.get<Array<Array<any>>>(`/api/candle`)
/** @deprecated قیمت up داخل /api/price/last در فیلد up برمی‌گردد */
export const getPrice = async () => await useAxios.get<Price>(`/api/price/up`)
export const getLastPrice = async () => await useAxios.get<Price>(`/api/price/last`)
+3
View File
@@ -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
+16 -5
View File
@@ -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
}
+1
View File
@@ -53,6 +53,7 @@ export interface PInventory {
deleted_at: any
price?:number
unit?: string
direct_price?: number
wallet:Wallet
}
+74
View File
@@ -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<AppSetting[]>([])
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,
}
})
+2
View File
@@ -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
+18 -5
View File
@@ -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();
+9
View File
@@ -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 : 'آبشده'
}
+72 -65
View File
@@ -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<typeof setInterval> | undefined
/** @deprecated از lastPrice استفاده کنید — برای سازگاری با کد قدیمی sync می‌شود */
export const price = ref<Price>()
export const lastPrice = ref<Price>()
export const olderPrice = ref<number| undefined>(0)
export const olderPrice = ref<number | undefined>(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<PriceUp | undefined> {
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
}
if (!olderPrice.value) {
return 0
}
return ((lastPrice.value?.price_last! - olderPrice.value) * 100) / olderPrice.value
}
+200 -36
View File
@@ -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
}
+10 -2
View File
@@ -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
}
+20 -26
View File
@@ -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 => <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) {
+10 -1
View File
@@ -9,7 +9,15 @@
<!-- <img :src="props.item.img" alt="image">-->
<img v-if="props.item.group_type=='طلا'|| props.item.group_type=='آبشده'|| props.item.group_type== null" :src="defaultImg">
<div class="mt-3">{{props.item?.title?? '-'}}</div>
<div class="mt-1 flex gap-1"> <div class="font-bold"> {{props.item?.wallet?.gold?? '-'}} </div> {{props.item?.unit}} </div>
<div class="mt-1 flex flex-col items-center gap-0.5 text-center">
<div class="flex gap-1">
<div class="font-bold">{{ props.item?.wallet?.gold ?? '-' }}</div>
{{ getProductQuantityUnit(props.item) }}
</div>
<div v-if="getProductUnitWeightLabel(props.item)" class="text-xs text-gray-500">
هر عدد {{ getProductUnitWeightLabel(props.item) }}
</div>
</div>
<!-- {{props.item?.wallet[0]?.cash}}-->
</div>
</template>
@@ -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() {
}*/
+6 -38
View File
@@ -10,33 +10,6 @@
<img :src="img" alt="" class="w-full absolute bottom-0 left-0 opacity-5 pointer-events-none z-0" />
<div class="pt-15 flex flex-col relative z-10">
<div class="text-tertiary font-bold mr-5 z-20">موجودی دارایی ها</div>
<template v-if="isBoursecuProject()">
<div class="flex justify-center mt-2 w-full z-20">
{{ BOURSECU_ASSET_LABEL_KATOD }}:
<div class="text-l mr-4 font-bold">
{{ formatBoursecuAssetAmount(walletStore.walletInfo?.count_katod_mes) }}
</div>
</div>
<div class="flex justify-center mt-2 w-full z-20">
{{ BOURSECU_ASSET_LABEL_MAFTOL }}:
<div class="text-l mr-4 font-bold">
{{ formatBoursecuAssetAmount(walletStore.walletInfo?.count_maftol_mes) }}
</div>
</div>
<div class="flex justify-center mt-2 w-full z-20">
{{ BOURSECU_ASSET_LABEL_GOLD }}:
<div class="text-l mr-4 font-bold">
{{ formatBoursecuAssetAmount(walletStore.walletInfo?.count_gold) }}
</div>
</div>
<div class="flex justify-center mt-2 w-full z-20">
دارایی ریالی:
<div class="text-l mr-4 font-bold">
{{ usePriceWithoutType(walletStore.walletInfo?.count_cash ?? 0) }}ریال
</div>
</div>
</template>
<template v-else>
<div class="flex mt-4 justify-center mt-2 w-full z-20">
محصولات:
<div class="text-l mr-4 font-bold">{{ walletStore.walletInfo?.count_product ?? 0}}عدد</div>
@@ -49,9 +22,9 @@
دارایی مس:
<div class="text-l mr-4 font-bold">{{ walletStore.walletInfo?.count_copper ?? 0}}گرم</div>
</div>
<div class="flex justify-center mt-2 w-full z-20">
دارایی طلایی:
<div class="text-l mr-4 font-bold">{{ walletStore.walletInfo?.count_gold ?? 0}}گرم</div>
<div v-if="!isBoursecuProject" class="flex justify-center mt-2 w-full z-20">
{{ metalAssetLabel }}:
<div class="text-l mr-4 font-bold">{{ walletStore.walletInfo?.count_gold ?? 0 }}{{ getWeightUnit() }}</div>
</div>
<div class="flex justify-center mt-2 w-full z-20">
دارایی ریالی:
@@ -61,7 +34,6 @@
معادل ریالی مجموع دارایی ها:
<div class="text-l mr-4 font-bold">{{ usePriceWithoutType(walletStore.walletInfo?.count_cash_total ?? 0) }}ریال</div>
</div>
</template>
</div>
</div>
<div class="pt-[20rem] ">
@@ -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<Fund[]>([])
const tableOutput = ref<TableOutput<Fund> | null>(null)
+49 -53
View File
@@ -6,11 +6,11 @@
<div class="flex justify-evenly w-full px-2 h-11 items-center bg-gray-50 relative rounded ">
<div :class="isBuy?'text-tertiary':'text-gray-400'" class="w-full text-center z-2"
@click.stop="setIsBuy(true) ">
خرید طلا {{ props?.ProductItem?.title }}
خرید {{ meltedGoldLabel }} {{ props?.ProductItem?.title }}
</div>
<div :class="!isBuy?'text-tertiary':'text-gray-400'" class="w-full text-center z-2"
@click.stop="setIsBuy(false) ">
فروش طلا {{ props?.ProductItem?.title }}
فروش {{ meltedGoldLabel }} {{ props?.ProductItem?.title }}
</div>
<!-- <div ref="bganim" class="absolute bg-white h-8 w-1/2 rounded-lg " :style="`transform: translateX(${isbuy? '0':'-100%'}); left: ${isbuy? '0':'100%'}`"></div>-->
<div ref="bganim" :style="useStyle()"
@@ -160,7 +160,7 @@
<div class="flex justify-between mt-3">
<div>مظنه:</div>
<div class="flex items-center">
<div class="font-bold">{{ usePriceWithoutType(isBuy ? price.buy ?? 0 : price.sell ?? 0) }}</div>
<div class="font-bold">{{ usePriceWithoutType(isBuy ? getTradeBuyPrice(lastPrice) : getTradeSellPrice(lastPrice)) }}</div>
<div class="text-xs mr-1">ریال</div>
</div>
</div>
@@ -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<boolean>(false)
const noCompleteVisible = ref<boolean>(false)
@@ -273,9 +278,13 @@ const sellPagination = ref<TableEngineInput>({
}], 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 => <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()
@@ -4,8 +4,8 @@
محصولات:
<div class="text-l mr-2 font-bold">{{ userStore?.userInfo?.wallet?.count_product ?? 0 }} عدد</div>
</div>
<div class="flex mt-2 justify-center text-tertiary w-full z-20">
دارایی طلایی:
<div v-if="!isBoursecuProject()" class="flex mt-2 justify-center text-tertiary w-full z-20">
{{ metalAssetLabel }}:
<div class="text-l mr-2 font-bold">{{ (userStore?.userInfo?.wallet?.count_gold ?? 0).toFixed(3) }} گرم</div>
<BasicIcon @click="$emit('openGoldModal')" icon="vuesax-linear:info-circle" size="18" color="tertiary" />
</div>
@@ -18,11 +18,15 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { useUserStore } from '@/store/userStore'
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import {usePriceWithoutType} from "../../../../utils/usePrice";
import { isBoursecuProject } from '@/utils/config'
import { getMetalAssetLabel } from '@/utils/productDealMethod'
const userStore = useUserStore()
const metalAssetLabel = computed(() => getMetalAssetLabel())
defineEmits<{
openGoldModal: []
@@ -31,7 +31,7 @@
<script setup lang="ts">
import Icon from '@/components/BasicPacks/BasicIcon.vue'
import { useConfigStore } from '@/store/configStore'
import {lastPrice, percentPriceChanged, price} from '@/utils/price'
import { getTradeBuyPrice, lastPrice, percentPriceChanged, price } from '@/utils/price'
import Vue3Odometer from 'vue3-odometer'
import 'odometer/themes/odometer-theme-default.css'
import {useTowDecimal} from "../../../../utils/usePrice";
@@ -42,19 +42,19 @@ const config = useConfigStore()
// محاسبه درصد تغییرات به صورت reactive
const percentChange = computed(() => {
if (! lastPrice?.value?.price_last) return 0
if (!getTradeBuyPrice(lastPrice.value)) return 0
return percentPriceChanged()
})
// بررسی بسته بودن بازار
const isMarketClosed = computed(() => {
return lastPrice?.value?.goldir === 0 && lastPrice?.value?.price_last === 0
return lastPrice?.value?.goldir === 0 && getTradeBuyPrice(lastPrice.value) === 0
})
// مقدار نمایشی برای ادومتر (با مدیریت خطا)
const displayGoldVal = computed(() => {
if (isMarketClosed.value) return 0
return lastPrice?.value?.price_last|| 0
return getTradeBuyPrice(lastPrice.value)
})
// انیمیشن fade-in
@@ -4,7 +4,7 @@
<div>بالاترین قیمت امروز</div>
<div v-if="price" class="flex flex-col items-center mt-3">
<div class="text-green-600 flex gap-1 text-xs items-center">
<div class="text-base">{{ usePriceWithoutType(price?.buy ?? 0) }}</div>
<div class="text-base">{{ usePriceWithoutType(highPrice) }}</div>
ریال
</div>
</div>
@@ -15,7 +15,7 @@
<div class="flex w-full mt-3 justify-evenly">
<div v-if="price" class="flex flex-col items-center">
<div class="text-red-600 flex gap-1 text-xs items-center">
<div class="text-base">{{ usePriceWithoutType(price?.sell ?? 0) }}</div>
<div class="text-base">{{ usePriceWithoutType(lowPrice) }}</div>
ریال
</div>
</div>
@@ -25,10 +25,14 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { getTradeBuyPrice, getTradeSellPrice } from '@/utils/price'
import { usePriceWithoutType } from '../../../../utils/usePrice'
import {usePriceWithoutType} from "../../../../utils/usePrice";
defineProps<{
const props = defineProps<{
price: any
}>()
const highPrice = computed(() => getTradeBuyPrice(props.price))
const lowPrice = computed(() => getTradeSellPrice(props.price))
</script>
@@ -10,15 +10,24 @@
<BasicIcon v-else-if="['آبشده','طلا'].includes(props.ProductItem.group_type)" stroke-width="1" size="50" color="#0A1B37" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
<BasicIcon v-else stroke-width="1" size="50" color="#0A1B37" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
</div>
<div class="flex justify-between px-2 items-center ">
<div class="px-2">
<div class="flex justify-between items-center">
<BasicIcon v-if="props.ProductItem.group_type=='گوی'" stroke-width="1" size="26" color="#0A1B37" class="rotate-310" icon="vuesax-linear:grammerly"/>
<BasicIcon v-else-if="props.ProductItem.group_type=='سکه'" stroke-width="1" size="26" color="#0A1B37" class="rotate-310" icon="vuesax-linear:coin"/>
<BasicIcon v-else-if="props.ProductItem.group_type=='شمش'" stroke-width="1" size="26" color="#0A1B37" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
<BasicIcon v-else-if="props.ProductItem.group_type=='مکعب'" stroke-width="1" size="26" color="#0A1B37" class="rotate-310" icon="vuesax-linear:keyboard"/>
<BasicIcon v-else stroke-width="1" size="26" color="#0A1B37" class="rotate-310" icon="vuesax-linear:slider-vertical"/> <div class="flex justify-between gap-2 items-center">
<BasicIcon v-else stroke-width="1" size="26" color="#0A1B37" class="rotate-310" icon="vuesax-linear:slider-vertical"/>
<div class="flex justify-between gap-2 items-center">
<span v-if="['آبشده','طلا'].includes(props.ProductItem.group_type)" class="font-bold text-secondary">{{userWallet.walletInfo?.gold??0}}</span>
<span v-else class="font-bold text-secondary">{{props?.ProductItem.wallet?.gold??0}}</span>
<span class="text-gray-400">{{props?.ProductItem?.unit}}</span>
<span v-else class="font-bold text-secondary">{{ props?.ProductItem.wallet?.gold ?? 0 }}</span>
<span class="text-gray-400">{{ getProductQuantityUnit(props.ProductItem) }}</span>
</div>
</div>
<div
v-if="getProductUnitWeightLabel(props.ProductItem)"
class="mt-1 text-left text-xs text-gray-400"
>
هر عدد {{ getProductUnitWeightLabel(props.ProductItem) }}
</div>
</div>
</div>
@@ -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
}
+1 -2
View File
@@ -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()
@@ -32,15 +32,20 @@
</div>
<div class="flex mt-3 justify-between items-center">
<div>تعداد موجودی:</div>
<div class="flex gap-1 items-center">
<div class="font-bold">{{ val.product.wallet.gold }}</div>
<div>{{ val.product.unit }}</div>
<div class="flex flex-col items-end gap-0.5">
<div class="flex gap-1 items-center">
<div class="font-bold">{{ val.product.wallet.gold }}</div>
<div>{{ getProductQuantityUnit(val.product) }}</div>
</div>
<div v-if="getProductUnitWeightLabel(val.product)" class="text-xs text-gray-500">
هر عدد {{ getProductUnitWeightLabel(val.product) }}
</div>
</div>
</div>
<div class="flex justify-between items-center mt-2">
<div>تعداد درخواستی:</div>
<div class="flex gap-1 items-center w-40%">
<BasicInput v-model:value="val.count" addon-before="عدد"/>
<BasicInput v-model:value="val.count" :addon-before="getProductQuantityUnit(val.product)"/>
</div>
</div>
</div>
@@ -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<PInventory[]>()
const baseItems = ref<PInventory[]>()
+2 -2
View File
@@ -5,8 +5,8 @@
<div @click="router.back()">
<BasicIcon icon="vuesax-linear:arrow-right-1"/>
</div>
<div v-if="route.name=='list'" class="mr-2">دریافت طلای فیزیکی</div>
<div v-else class="mr-2">دریافت طلای فیزیکی-درخواست جدید</div>
<div v-if="route.name=='list'" class="mr-2">دریافت فیزیکی</div>
<div v-else class="mr-2">دریافت فیزیکی-درخواست جدید</div>
</div>
</div>
<div>
@@ -79,20 +79,27 @@
<div>{{ usePrice(form.goldCash ?? 0) }}</div>
</div>
<div v-if="props?.ProductItem?.group_type !== 'سکه'" class="flex justify-between">
<div> وزن کل</div>
<div>{{ form.goldVazn ?? 0 }} {{ getWeightUnit() }}</div>
<div v-if="shouldShowProductTotalWeight(props?.ProductItem)" class="flex justify-between">
<div>وزن کل</div>
<div>{{ totalWeightDisplay }}</div>
</div>
<div
v-if="isCountBasedProductItem && hasProductUnitWeight(props?.ProductItem)"
class="flex justify-between text-xs text-gray-500"
>
<div>وزن هر عدد</div>
<div>{{ getProductUnitWeightLabel(props?.ProductItem) }}</div>
</div>
<!-- {{walletStore?.walletInfo?.gold}}-->
<Transition mode="out-in" name="fade" class="mt-2">
<div v-if="isBuy && form.method === 'gold'" class="font-bold text-xs">
<div>{{ goldWalletBalanceText }}</div>
<div v-if="isBuy && (form.method === 'gold' || form.method === 'katod')" class="font-bold text-xs">
<div>{{ buyMetalWalletBalanceText }}</div>
</div>
<div v-else-if="isBuy" class="font-bold text-xs">
<div v-else-if="isBuy && form.method === 'cash'" class="font-bold text-xs">
{{ cashWalletBalanceText }}
</div>
<div class="font-bold text-xs" v-else>{{ `موجودی محصول: ${getInventoryById(props?.ProductItem?.id)}` }}
<div class="font-bold text-xs" v-else>{{ `موجودی محصول: ${getInventoryById(props?.ProductItem?.id)} ${getProductQuantityUnit(props?.ProductItem)}` }}
</div>
</Transition>
<Transition mode="out-in" name="fade">
@@ -184,7 +191,7 @@
<div class="flex items-center">
<div class="font-bold">{{ form.goldValue }}</div>
<div class="text-xs mr-1"> عدد</div>
<div class="text-base font-bold mr-1"> عدد {{ props?.ProductItem?.title }}</div>
<div class="text-base font-bold mr-1"> {{ props?.ProductItem?.title }}</div>
</div>
</div>
<div class="flex justify-between mt-3">
@@ -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) {
@@ -184,7 +184,7 @@
<div class="flex items-center">
<div class="font-bold">{{ form.goldValue }}</div>
<div class="text-xs mr-1"> عدد</div>
<div class="text-base font-bold mr-1"> عدد {{ props?.ProductItem?.title }}</div>
<div class="text-base font-bold mr-1"> {{ props?.ProductItem?.title }}</div>
</div>
</div>
<div class="flex justify-between mt-3">
@@ -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 => <Price>lastPrice.value ?? 0)
const goldPriceValue = computed(() => {
if (!priceLast.value) return 0
return priceLast.value.buy
})
const goldPriceValue = computed(() => getProductBuyPrice(props.ProductItem))
</script>
-2
View File
@@ -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 {
@@ -54,17 +54,25 @@
</div>
</div>
<div v-if="item.order" class="flex justify-between mb-3">
<div class="text-primary">قیمت هر گرم طلا حین معامله:</div>
<div class="text-primary">قیمت هر گرم {{ getTradePriceUnitLabel() }} حین معامله:</div>
<div class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.price?? 0) }}</div>
ریال
</div>
</div>
<div class="flex justify-between mb-3">
<div class="text-primary">مقدار {{item.wallet?.product? item.wallet.product.title: 'آبشده' }} مبادله شده:</div>
<div :class="item.gold >= 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ item.gold }}</div>
{{item.unit}}
<div class="text-primary">مقدار {{ item.wallet?.product ? item.wallet.product.title : getMeltedGoldTradeLabel() }} مبادله شده:</div>
<div :class="item.gold >= 0? 'text-green-600' : 'text-red-600'" class="flex flex-col items-end text-xs number-ltr">
<div class="flex items-center">
<div class="text-base ml-1">{{ item.gold }}</div>
{{ item.unit }}
</div>
<div
v-if="item.wallet?.product && getProductTotalWeightLabel(Math.abs(item.gold ?? 0), item.wallet.product)"
class="text-gray-500"
>
{{ getProductTotalWeightLabel(Math.abs(item.gold ?? 0), item.wallet.product) }}
</div>
</div>
</div>
<div class="flex justify-between mb-3">
@@ -76,9 +84,14 @@
</div>
<div class="flex justify-between mb-3" v-if="item.wallet?.product">
<div class="text-primary">موجودی {{item.wallet.product.title}}:</div>
<div class="flex text-xs text-yellow-700 items-center">
<div class="text-base ml-1">{{ item.balance_gold }}</div>
{{item.wallet.product.unit}}
<div class="flex flex-col items-end text-xs text-yellow-700">
<div class="flex items-center">
<div class="text-base ml-1">{{ item.balance_gold }}</div>
{{ getProductQuantityUnit(item.wallet.product) }}
</div>
<div v-if="getProductUnitWeightLabel(item.wallet.product)" class="text-gray-500">
هر عدد {{ getProductUnitWeightLabel(item.wallet.product) }}
</div>
</div>
</div>
<div class="flex justify-between mb-3" v-else>
@@ -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<boolean>(false)
+3 -3
View File
@@ -65,14 +65,14 @@
</div>
</div>
<div class="flex justify-between mb-3">
<div class="text-black">مقدار طلا مبادله شده:</div>
<div class="text-black">مقدار {{ getMetalTypeTradeLabel() }} مبادله شده:</div>
<div :class="item.gold >= 0? 'text-green-600' : 'text-red-600'" class="flex text-xs items-center">
<div class="text-base ml-1 number-ltr">{{ item.gold }}</div>
گرم
</div>
</div>
<div v-if="item.order" class="flex justify-between mb-3">
<div class="text-black">قیمت هر گرم طلا حین معامله:</div>
<div class="text-black">قیمت هر گرم {{ getTradePriceUnitLabel() }} حین معامله:</div>
<div class="flex text-xs items-center number-ltr">
<div class="text-base ml-1">{{ usePriceWithoutType(item.order?.price?? 0) }}</div>
ریال
@@ -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<boolean>(false)
+19 -8
View File
@@ -43,10 +43,21 @@
</div>
<!-- <transition name="fade" mode="out-in">-->
<a-form-item v-if="!stepTwoVerify" :rules="[required('شماره تلفن'),mobileValidation()]"
class="home_appear_fade_in_down" label="شماره تلفن"
name="mobile">
<BasicInput v-model:value="userFormState.mobile" place-holder="شماره تلفن" size="large" inputmode="decimal"/>
<a-form-item
v-if="!stepTwoVerify"
:rules="[required('شماره تلفن'), mobileValidation('شماره تلفن')]"
:validate-trigger="['change', 'blur']"
class="home_appear_fade_in_down"
label="شماره تلفن"
name="mobile"
>
<BasicInput
v-model:value="userFormState.mobile"
place-holder="شماره تلفن"
size="large"
inputmode="numeric"
type="tel"
/>
</a-form-item>
<!-- </transition>-->
<!-- <transition name="fade" mode="out-in">-->
@@ -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() {
+2 -2
View File
@@ -2,7 +2,7 @@
<div class="w-full p-8">
<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="[lengthValidation(11),required]">
<a-form-item label="شماره تلفن همراه" name="mobile" :rules="[required,mobileValidation('شماره تلفن همراه')]">
<BasicInput v-model:value="userFormState.mobile" type="tel" size="large" place-holder="شماره تلفن همراه"/>
<div class="text-xs mt-1 text-gray-400">مالکیت شماره باید به نام خودتان باشد</div>
</a-form-item>
@@ -30,7 +30,7 @@
<script setup lang="ts">
import {lengthValidation, required} from "@/utils/inputRules";
import {mobileValidation, required} from "@/utils/inputRules";
import type {UserMobile} from "@/models/login";
import BasicInput from "@/components/BasicPacks/BasicInput.vue";
import BasicButton from "@/components/BasicPacks/BasicButton.vue";
+2 -2
View File
@@ -30,9 +30,9 @@
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" label="نام خانوادگی" name="lname">
<BasicInput v-model:value="userFormState.lname" place-holder="نام خانوادگی" />
</a-form-item>
<a-form-item :rules="[required(),mobileValidation()]" class="home_appear_fade_in_down" label="شماره تلفن"
<a-form-item :rules="[required(),mobileValidation('شماره تلفن')]" class="home_appear_fade_in_down" label="شماره تلفن"
name="mobile">
<BasicInput v-model:value="userFormState.mobile" place-holder="شماره تلفن" inputmode="decimal"/>
<BasicInput v-model:value="userFormState.mobile" place-holder="شماره تلفن" inputmode="numeric"/>
</a-form-item>
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" label="کلمه عبور" name="password">
<!-- <BasicInput v-model:value="userFormState.password" size="large" place-holder="کلمه عبور"/>-->