diff --git a/pages/index/index.vue b/pages/index/index.vue
index b212403..9a6fd0e 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -12,15 +12,15 @@
- {{ item }}
+ {{ item.name }}
-
+
-
+
@@ -203,7 +203,7 @@
-
+
@@ -242,7 +242,8 @@
data() {
return {
currentTab: 0,
- navList: ['精选', '女装', '美食', '美妆', '母婴', '鞋包', '居家', '数码'],
+ navList: [{ name: '首页', cat_id: 0 }, { name: '推荐', cat_id: -1 }],
+ scrollTarget: '',
banners: [
'https://images.unsplash.com/photo-1483985988355-763728e1935b?w=800&q=80',
'https://images.unsplash.com/photo-1542291026-7eec264c27ff?w=800&q=80',
@@ -284,6 +285,7 @@
}
},
onLoad() {
+ this.getCategoryList();
this.getNoticeList();
this.getGoodsList();
this.getWorthBuyLists();
@@ -306,6 +308,16 @@
}
},
methods: {
+ getCategoryList() {
+ uni.request({
+ url: 'https://api.cmspro.haodanku.com/index/category?cid=qOstW90',
+ success: (res) => {
+ if (res.data && res.data.code === 200 && res.data.data.category) {
+ this.navList = [{ name: '首页', cat_id: 0 }, { name: '推荐', cat_id: -1 }, ...res.data.data.category];
+ }
+ }
+ });
+ },
getNoticeList() {
uni.request({
url: 'https://api.cmspro.haodanku.com/msg/getMsgs?cid=qOstW90',
@@ -396,6 +408,16 @@
},
switchTab(index) {
this.currentTab = index;
+ const tabName = this.navList[index].name;
+
+ this.scrollTarget = ''; // 重置目标,确保下次点击仍能触发滚动
+ this.$nextTick(() => {
+ if (tabName === '推荐') {
+ this.scrollTarget = 'goods-list-section';
+ } else if (tabName === '首页') {
+ this.scrollTarget = 'top-section';
+ }
+ });
}
}
}
@@ -1137,24 +1159,23 @@
}
.brand-name-row {
- color: #fff;
- font-size: 32rpx;
- font-weight: bold;
+ color: rgba(255, 255, 255, 0.9);
+ font-size: 24rpx;
display: flex;
align-items: center;
margin-bottom: 8rpx;
}
.brand-name-row .arrow {
- margin-left: 10rpx;
- font-size: 24rpx;
+ margin-left: 8rpx;
+ font-size: 22rpx;
}
.brand-discount-text {
color: #fff;
- font-size: 28rpx;
- margin-bottom: 12rpx;
- font-weight: 500;
+ font-size: 32rpx;
+ margin-bottom: 14rpx;
+ font-weight: bold;
}
.brand-promo-tags {
@@ -1162,7 +1183,7 @@
}
.p-tag {
- background: rgba(0,0,0,0.3);
+ background: rgba(0, 0, 0, 0.25);
color: #fff;
font-size: 20rpx;
padding: 4rpx 16rpx;