添加mock数据
This commit is contained in:
@@ -181,6 +181,7 @@
|
||||
<script lang="uts">
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
import MerchantTabBar from '@/components/merchant-tabbar/MerchantTabBar.uvue'
|
||||
import { USE_MOCK, MOCK_MERCHANT_ID, MOCK_SHOP_INFO, MOCK_TODAY_STATS, MOCK_PENDING_COUNTS, getMockRecentOrders } from '@/pages/mall/merchant/mock/merchant-mock-data.uts'
|
||||
|
||||
// ---- 复用 index 的类型定义 ----
|
||||
type ShopInfoType = {
|
||||
@@ -328,6 +329,10 @@
|
||||
},
|
||||
|
||||
async initMerchantId() {
|
||||
if (USE_MOCK) {
|
||||
this.merchantId = MOCK_MERCHANT_ID
|
||||
return
|
||||
}
|
||||
try {
|
||||
const session = supa.getSession()
|
||||
if (session != null && session.user != null) {
|
||||
@@ -343,6 +348,35 @@
|
||||
|
||||
// 复用 index 的完整数据加载链
|
||||
async loadAllData() {
|
||||
if (USE_MOCK) {
|
||||
this.shopInfo = {
|
||||
id: MOCK_SHOP_INFO.id,
|
||||
merchant_id: MOCK_SHOP_INFO.merchant_id,
|
||||
shop_name: MOCK_SHOP_INFO.shop_name,
|
||||
shop_logo: MOCK_SHOP_INFO.shop_logo,
|
||||
shop_banner: MOCK_SHOP_INFO.shop_banner,
|
||||
description: MOCK_SHOP_INFO.description,
|
||||
contact_name: MOCK_SHOP_INFO.contact_name,
|
||||
contact_phone: MOCK_SHOP_INFO.contact_phone,
|
||||
rating_avg: MOCK_SHOP_INFO.rating_avg,
|
||||
total_sales: MOCK_SHOP_INFO.total_sales,
|
||||
status: MOCK_SHOP_INFO.status
|
||||
} as ShopInfoType
|
||||
this.todayStats = {
|
||||
orders: MOCK_TODAY_STATS.orders,
|
||||
sales: MOCK_TODAY_STATS.sales,
|
||||
visitors: MOCK_TODAY_STATS.visitors,
|
||||
conversion: MOCK_TODAY_STATS.conversion
|
||||
} as TodayStatsType
|
||||
this.pendingCounts = {
|
||||
pending_shipment: MOCK_PENDING_COUNTS.pending_shipment,
|
||||
refund_requests: MOCK_PENDING_COUNTS.refund_requests,
|
||||
low_stock: MOCK_PENDING_COUNTS.low_stock,
|
||||
pending_reviews: MOCK_PENDING_COUNTS.pending_reviews
|
||||
} as PendingCountsType
|
||||
this.recentOrders = getMockRecentOrders() as OrderType[]
|
||||
return
|
||||
}
|
||||
await this.loadMerchantData()
|
||||
await this.loadTodayStats()
|
||||
await this.loadPendingCounts()
|
||||
|
||||
Reference in New Issue
Block a user