首页商品

This commit is contained in:
2026-08-22 11:54:45 +08:00
parent 075c4ceee2
commit c3b6af07c9
3 changed files with 96 additions and 9 deletions
+49 -6
View File
@@ -8,8 +8,9 @@
<!-- 全球POD货盘 -->
<PodCatalog
:countries="countryTabs"
:countries="podCountries"
:products="podProducts"
@countryChange="onPodCountryChange"
@moreTap="onGoProducts"
@productTap="onGoDetail"
/>
@@ -33,11 +34,11 @@ import PlatformFeatures from './components/PlatformFeatures.vue'
import WhyChoose from './components/WhyChoose.vue'
import CompanyIntro from './components/CompanyIntro.vue'
import { getCountries, getGoods } from '@/api/public.js'
import {
trustStats,
stepList,
countryTabs,
podProducts,
featureList,
reasonList,
companyFeatures
@@ -56,14 +57,56 @@ export default {
return {
trustStats,
stepList,
countryTabs,
podProducts,
featureList,
reasonList,
companyFeatures
companyFeatures,
podCountries: [],
podProducts: []
}
},
async onLoad() {
await this.loadPodCountries()
await this.loadPodProducts('')
},
methods: {
async loadPodCountries() {
try {
const res = await getCountries()
const data = (res.data && res.data.data) || []
const countries = [{ id: '', name: '全部' }]
data.forEach((c) => {
countries.push({ id: c.id, name: c.countryName })
})
this.podCountries = countries
} catch (err) {
console.error('[loadPodCountries Error]', err)
}
},
async loadPodProducts(countryId) {
try {
const params = { page: 1, pageSize: 4 }
if (countryId) {
params.countryId = countryId
}
const res = await getGoods(params)
const data = (res.data && res.data.data) || { items: [] }
const items = (data.items || []).slice(0, 4)
this.podProducts = items.map((item) => ({
id: item.goodId,
name: item.goodName,
image: item.image
}))
} catch (err) {
console.error('[loadPodProducts Error]', err)
this.podProducts = []
}
},
async onPodCountryChange(id) {
await this.loadPodProducts(id)
},
onGoProducts() {
uni.switchTab({
url: '/pages/products/products'