137 lines
2.3 KiB
JavaScript
137 lines
2.3 KiB
JavaScript
import {
|
|
getbannerList
|
|
} from '~/services/home/getbannerList';
|
|
import {
|
|
getHomeCategoryListApi
|
|
} from '~/services/home/getHomeCategoryListApi';
|
|
import {
|
|
getNoticeList
|
|
} from '~/services/home/getNoticeList';
|
|
import Toast from 'tdesign-miniprogram/toast/index';
|
|
|
|
Page({
|
|
data: {
|
|
imgSrcs: [],
|
|
tabList: [
|
|
{
|
|
text: "精选推荐",
|
|
key: 0,
|
|
categoryGuid: 1,
|
|
}
|
|
],
|
|
noticeList: [],
|
|
marquee: {
|
|
speed: 40,
|
|
loop: -1,
|
|
delay: 0,
|
|
},
|
|
pageLoading: false,
|
|
current: 0,
|
|
autoplay: true,
|
|
duration: '500',
|
|
interval: 5000,
|
|
navigation: {
|
|
type: 'dots',
|
|
},
|
|
swiperImageProps: {
|
|
mode: 'scaleToFill',
|
|
},
|
|
categoryGuid: 0,
|
|
},
|
|
|
|
|
|
privateData: {
|
|
tabIndex: 0,
|
|
},
|
|
|
|
onShow() {
|
|
this.getTabBar().init();
|
|
},
|
|
|
|
onLoad() {
|
|
this.init();
|
|
},
|
|
|
|
// 划到底部触发
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
onPullDownRefresh() {
|
|
this.init();
|
|
},
|
|
|
|
init() {
|
|
this.loadHomePage();
|
|
},
|
|
|
|
loadHomePage() {
|
|
wx.stopPullDownRefresh();
|
|
|
|
this.setData({
|
|
pageLoading: true,
|
|
});
|
|
|
|
// 获取轮播图列表
|
|
getbannerList().then((res) => {
|
|
if (res.code == 200) {
|
|
this.setData({
|
|
imgSrcs: res.data.map((v) => v.bannerImg),
|
|
});
|
|
}
|
|
});
|
|
|
|
// 获取首页推荐类目
|
|
// getHomeCategoryListApi().then((res) => {
|
|
// this.setData({
|
|
// tabList: res.data,
|
|
// });
|
|
// this.data.tabList.unshift({
|
|
// text: "精选推荐",
|
|
// key: 0,
|
|
// categoryGuid: 1,
|
|
// })
|
|
// this.setData({
|
|
// tabList: res.data,
|
|
// pageLoading: false,
|
|
// });
|
|
// // 刷新列表
|
|
// });
|
|
|
|
// 获取公告列表
|
|
getNoticeList().then((res) => {
|
|
if (res.code == 200) {
|
|
const _noticeData = res.data.map((v) => {
|
|
return {
|
|
...v,
|
|
visible: true
|
|
};
|
|
});
|
|
this.setData({
|
|
noticeList: _noticeData,
|
|
pageLoading: false
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
// 点击分类
|
|
tabChangeHandle(e) {
|
|
this.privateData.tabIndex = e.detail;
|
|
this.setData({
|
|
categoryGuid: e.detail.value,
|
|
});
|
|
// 刷新列表
|
|
|
|
},
|
|
|
|
|
|
|
|
navToSearchPage() {
|
|
wx.navigateTo({
|
|
url: '/pages/home/search/index',
|
|
});
|
|
},
|
|
|
|
|
|
}); |