添加mock数据

This commit is contained in:
2026-04-13 11:32:31 +08:00
parent 334e5936c9
commit 37141c1d6b
17 changed files with 1843 additions and 330 deletions

View File

@@ -96,6 +96,7 @@
<script lang="uts">
import supa from '@/components/supadb/aksupainstance.uts'
import { USE_MOCK, MOCK_MERCHANT_ID, getMockInventoryStats, MOCK_INVENTORY_PRODUCTS } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
type ProductType = {
id: string
@@ -137,6 +138,10 @@
methods: {
async initMerchantId() {
if (USE_MOCK) {
this.merchantId = MOCK_MERCHANT_ID
return
}
try {
const session = supa.getSession()
if (session != null && session.user != null) {
@@ -151,7 +156,21 @@
async loadProducts() {
if (this.loading && this.page === 1) return
this.loading = true
if (USE_MOCK) {
const all = MOCK_INVENTORY_PRODUCTS
const filtered: typeof all = []
for (let i = 0; i < all.length; i++) {
const p = all[i]
if (this.currentFilter === 'low' && (p.total_stock <= 0 || p.total_stock > p.warning_stock)) continue
if (this.currentFilter === 'out' && p.total_stock !== 0) continue
filtered.push(p)
}
this.products = filtered as ProductType[]
this.hasMore = false
this.loading = false
this.refreshing = false
return
}
try {
let query = supa.from('ml_products')
.select('id, name, main_image_url, total_stock, warning_stock')
@@ -204,6 +223,10 @@
},
async loadStats() {
if (USE_MOCK) {
this.stats = getMockInventoryStats()
return
}
try {
const response = await supa.from('ml_products').select('id, total_stock, warning_stock', { count: 'exact' }).eq('merchant_id', this.merchantId).execute()