price changes
This commit is contained in:
Vendored
-1
@@ -8,7 +8,6 @@ export {}
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
AButton: typeof import('ant-design-vue/es')['Button']
|
||||
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
|
||||
ADivider: typeof import('ant-design-vue/es')['Divider']
|
||||
AForm: typeof import('ant-design-vue/es')['Form']
|
||||
AFormItem: typeof import('ant-design-vue/es')['FormItem']
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import useAxios from '@/utils/useAxios'
|
||||
|
||||
export interface StoreCategory {
|
||||
id: number
|
||||
name: string
|
||||
sort_order?: number
|
||||
}
|
||||
|
||||
export const getStoreCategories = async (): Promise<StoreCategory[]> =>
|
||||
await useAxios.get<StoreCategory[]>('/customer/categories')
|
||||
@@ -0,0 +1,7 @@
|
||||
import { getStoreCategories } from '@/api/categories'
|
||||
|
||||
/** تبهای فیلتر محصول — فقط از API دستهبندی (هماهنگ با پنل ادمین) */
|
||||
export async function loadProductCategoryTabNames(): Promise<string[]> {
|
||||
const categories = await getStoreCategories()
|
||||
return categories.map((item) => item.name)
|
||||
}
|
||||
@@ -7,6 +7,9 @@ export const UNIFIED_PRODUCT_CATEGORIES = [
|
||||
'گوی',
|
||||
'سکه',
|
||||
'سکه پارسیان',
|
||||
'شمش',
|
||||
'شمش ونوس',
|
||||
'شمش برنا',
|
||||
'مس',
|
||||
'نقره',
|
||||
] as const
|
||||
|
||||
@@ -102,6 +102,7 @@ import { isProductPriceInactive } from '@/utils/productPrice'
|
||||
import { isMetalCommodityGroup, isMeltedTradeGroup } from '@/utils/productCategories'
|
||||
import { isBoursecuDealProductGroup } from '@/utils/productDealMethod'
|
||||
import { loadServiceFeeFromSettings } from '@/utils/serviceFee'
|
||||
import { loadProductCategoryTabNames } from '@/utils/categoryTabs'
|
||||
import { getLastPrices, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
||||
|
||||
const activekey = ref('طلا' ||'آبشده')
|
||||
@@ -158,9 +159,18 @@ function changeTab() {
|
||||
|
||||
const firstItems = ref<Product[]>()
|
||||
const items = ref<Product[]>()
|
||||
const typeItems = ref([])
|
||||
const typeItems = ref<string[]>([])
|
||||
let productListInterval: ReturnType<typeof setInterval> | undefined
|
||||
|
||||
async function loadCategoryTabs() {
|
||||
try {
|
||||
typeItems.value = await loadProductCategoryTabNames()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
typeItems.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* رفرش بیصدای لیست محصولات (هر ۱۰ ثانیه تا وقتی در این صفحهایم).
|
||||
* آپدیت درجا انجام میشود تا لیست re-render کامل نشود و نپرد؛
|
||||
@@ -173,12 +183,6 @@ async function refreshProducts() {
|
||||
return
|
||||
}
|
||||
|
||||
fresh.forEach((val) => {
|
||||
if (!typeItems.value.includes(val.group_type)) {
|
||||
typeItems.value.push(val.group_type)
|
||||
}
|
||||
})
|
||||
|
||||
const freshById = new Map(fresh.map((p) => [p.id, p]))
|
||||
const current = firstItems.value
|
||||
|
||||
@@ -220,12 +224,7 @@ onMounted(async () => {
|
||||
openTime.value = items.value[0].auto_open_at
|
||||
}
|
||||
|
||||
items.value?.forEach((val, index) => {
|
||||
if (!typeItems.value.includes(val.group_type)){
|
||||
typeItems.value.push(val.group_type)
|
||||
}
|
||||
// typeItems.value[index] = val.group_type
|
||||
})
|
||||
await loadCategoryTabs()
|
||||
firstItems.value = items.value
|
||||
await loadServiceFeeFromSettings()
|
||||
productListInterval = setInterval(refreshProducts, 10000)
|
||||
|
||||
Reference in New Issue
Block a user