tabIndex: 0,
},
onShow() {
this.getTabBar().init();
},
onLoad() {
this.init();
},
onReachBottom() {
if (this.data.goodsListLoadStatus === 0) {
this.loadGoodsList();
}
},
onPullDownRefresh() {
this.init();
},
init() {
this.loadHomePage();
},
loadHomePage() {
wx.stopPullDownRefresh();
this.setData({
pageLoading: true,
});
fetchHome().then(({ swiper, tabList }) => {
this.setData({
tabList,
imgSrcs: swiper,
pageLoading: false,
});
this.loadGoodsList(true);
});
},
tabChangeHandle(e) {
this.privateData.tabIndex = e.detail;
this.loadGoodsList(true);
},
onReTry() {
this.loadGoodsList();
},
async loadGoodsList(fresh = false) {
if (fresh) {
wx.pageScrollTo({
scrollTop: 0,
});
}
this.setData({ goodsListLoadStatus: 1 });
const pageSize = this.goodListPagination.num;
let pageIndex =
this.privateData.tabIndex \* pageSize + this.goodListPagination.index + 1;
if (fresh) {
pageIndex = 0;
}
try {
const nextList = await fetchGoodsList(pageIndex, pageSize);
this.setData({
goodsList: fresh ? nextList : this.data.goodsList.concat(nextList),
goodsListLoadStatus: 0,
});
this.goodListPagination.index = pageIndex;
this.goodListPagination.num = pageSize;
} catch (err) {
this.setData({ goodsListLoadStatus: 3 });
}
},
goodListClickHandle(e) {
const { index } = e.detail;
const { spuId } = this.data.goodsList[index];
wx.navigateTo({
url: /pages/goods/details/index?spuId=${spuId}
,
});
},
goodListAddCartHandle() {
Toast({
context: this,
selector: ‘#t-toast’,
message: ‘点击加入购物车’,
});
},
navToSearchPage() {
wx.navigateTo({ url: ‘/pages/goods/search/index’ });
},
navToActivityDetail({ detail }) {
const { index: promotionID = 0 } = detail || {};
wx.navigateTo({
url: /pages/promotion-detail/index?promotion_id=${promotionID}
,
});
},
});
// home.json
{
“navigationBarTitleText”: “首页”,
“onReachBottomDistance”: 10,
“backgroundTextStyle”: “light”,
“enablePullDownRefresh”: true,
“usingComponents”: {
“t-search”: “tdesign-miniprogram/search/search”,
“t-loading”: “tdesign-miniprogram/loading/loading”,
“t-swiper”: “tdesign-miniprogram/swiper/swiper”,
“t-swiper-item”: “tdesign-miniprogram/swiper/swiper-item”,
“t-swiper-nav”: “tdesign-miniprogram/swiper/swiper-nav”,
“t-image”: “/components/webp-image/index”,
“t-icon”: “tdesign-miniprogram/icon/icon”,
“t-toast”: “tdesign-miniprogram/toast/toast”,
“t-tabs”: “tdesign-miniprogram/tabs/tabs”,
“t-tab-panel”: “tdesign-miniprogram/tabs/tab-panel”,
“goods-list”: “/components/goods-list/index”,
“load-more”: “/components/load-more/index”
}
}
加载中...
/* home.wxss */
page {
box-sizing: border-box;
padding-bottom: calc(env(safe-area-inset-bottom) + 96rpx);
}
.t-tabs.t-tabs–top .t-tabs__scroll {
border-bottom: none !important;
}
.home-page-header {
background: linear-gradient(#fff, #f5f5f5);
}
.home-page-container {
background: #f5f5f5;
}
.home-page-container,
.home-page-header {
display: block;
padding: 0 24rpx;
}
.home-page-header .t-search__input-container {
border-radius: 32rpx !important;
height: 64rpx !important;
}
.home-page-header .t-search__input {
font-size: 28rpx !important;
color: rgb(116, 116, 116) !important;
}
.home-page-header .swiper-wrap {
margin-top: 20rpx;
}
.home-page-header .t-image__swiper {
width: 100%;
height: 300rpx;
border-radius: 10rpx;
}
.home-page-container .t-tabs {
background: #f5f5f5;
}
.home-page-container .t-tabs .t-tabs-nav {
background-color: transparent;
line-height: 80rpx;
font-size: 28rpx;
color: #333;
}
.home-page-container .t-tabs .t-tabs-scroll {
border: none !important;
}
/* 半个字 */
.home-page-container .tab.order-nav .order-nav-item.scroll-width {
min-width: 165rpx;
}
.home-page-container .tab .order-nav-item.active {
color: #fa550f !important;
}
.home-page-container .tab .bottom-line {
border-radius: 4rpx;
}
.home-page-container .tab .order-nav-item.active .bottom-line {
background-color: #fa550f !important;
}
.home-page-container .t-class-item {
color: #333333 !important;
font-size: 32rpx;
}
.home-page-container .t-class-track {
background-color: #fa4126 !important;
height: 6rpx !important;
border-radius: 4rpx !important;
width: 48rpx !important;
}
.t-tabs.t-tabs–top .t-tabs__item,
.t-tabs.t-tabs–bottom .t-tabs__item {
height: 86rpx !important;
}
.home-page-container .goods-list-container {
background: #f5f5f5 !important;
margin-top: 24rpx;
}
.t-class-indicator,
.loading-text {
color: #b9b9b9 !important;
}
算了,直接[源码下载](https://bbs.csdn.net/topics/618545628)
![img](https://img-blog.csdnimg.cn/img_convert/5f9aedc2dffae98cbae3c34dee76e38f.png)
![img](https://img-blog.csdnimg.cn/img_convert/6589ea9841800fd8192af0df491aab0f.png)
![img](https://img-blog.csdnimg.cn/img_convert/352bb36201577f9a61fe5de7426ea12a.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**
图片转存中...(img-PeGI0NYy-1714174256410)]
[外链图片转存中...(img-hjORuxsA-1714174256411)]
[外链图片转存中...(img-QS2qPwLa-1714174256411)]
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**