diff --git a/pages/index/components/PodCatalog.vue b/pages/index/components/PodCatalog.vue index 0101be1..504dfd1 100644 --- a/pages/index/components/PodCatalog.vue +++ b/pages/index/components/PodCatalog.vue @@ -18,7 +18,7 @@ - + {{ item.name }} + + + 📦 + 暂无商品 + @@ -55,7 +60,7 @@ export default { }, data() { return { - activeCountry: 'us' + activeCountry: '' } }, methods: { @@ -188,4 +193,21 @@ export default { width: 24rpx; height: 24rpx; } + +/* 空状态 */ +.pod-empty { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 80rpx 0; +} +.empty-icon { + font-size: 80rpx; + margin-bottom: 20rpx; +} +.empty-text { + font-size: 26rpx; + color: #999999; +} diff --git a/pages/index/index.vue b/pages/index/index.vue index 0324f72..fbaf221 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -8,8 +8,9 @@ @@ -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' diff --git a/pages/products/components/ProductGrid.vue b/pages/products/components/ProductGrid.vue index 123e916..31b4843 100644 --- a/pages/products/components/ProductGrid.vue +++ b/pages/products/components/ProductGrid.vue @@ -14,7 +14,7 @@ - + + + + 📦 + 没有找到相关商品 + @@ -259,4 +264,21 @@ export default { font-size: 24rpx; color: #999999; } + +/* 空状态 */ +.product-empty { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 120rpx 0; +} +.empty-icon { + font-size: 96rpx; + margin-bottom: 24rpx; +} +.empty-text { + font-size: 26rpx; + color: #999999; +}