import { fetchHome } from '../../services/home/home'; const app = getApp() Page({ data: { tabList: [], //目录 pageLoading: false, current: 1,//轮播图参数 autoplay: true, //轮播图参数 duration: '500',//轮播图参数 interval: 5000,//轮播图参数 navigation: { type: 'dots' },//轮播图参数 bannerList: [], //轮播图列表 specialSubjectList: [],//专题讨论 courseList: [], booksList: [], textbookList: [] }, goodListPagination: { index: 0, num: 20, }, privateData: { tabIndex: 0, }, onShow() { this.getTabBar().init(); this.loadHomePage(); this.getBannerList() }, onLoad() { this.init(); }, onReachBottom() { }, onPullDownRefresh() { this.init(); }, init() { this.getSubjectList(); this.getCourseList(); }, getBannerList() { const list = [] app.MG.resource.getItem({ path: 'jsek_banner\\jsek_homeBanner', fields: { jsek_link: [] }, paging: { start: 0, size: 9 } }).then(res => { for (let i = 0; i < res.datas.length; i++) { const item = res.datas[i] list.push({ value: item.icon, link: item.jsek_link }) } this.setData({ bannerList: list }) }) console.log('轮播图', this.data.bannerList); }, //搜索 navToSearchPage() { wx.navigateTo({ url: '/pages/goods/search/index' }); }, //轮播图跳转 navToActivityDetail({ detail }) { const data = this.data.bannerList[detail.index] console.log('跳转', data.link); // const { index: promotionID = 0 } = detail || {}; // wx.navigateTo({ // url: `/pages/promotion-detail/index?promotion_id=${promotionID}`, // }); }, //获取目录 loadHomePage() { wx.stopPullDownRefresh(); this.setData({ pageLoading: true, }); fetchHome().then(({ tabList }) => { this.setData({ tabList, pageLoading: false, }); }); }, //点击目录 toPages(item) { let info = item.target.dataset.info if (info.url) { wx.navigateTo({ url: info.url }) } else { wx.showToast({ title: "建设中", icon: 'none', duration: 2000 }) } }, //专题讨论 getSubjectList() { const obj = { storeInfo: "jsek_seminar", path: 'jsek_homepageSeminar', coverSize: { width: 400 }, paging: { start: 0, size: 3 }, fields: { liveTime: [], lecturer: [], startTime: [], jsek_link: [] } } app.MG.store.getProductList(obj).then((res) => { this.setData({ specialSubjectList: res.datas }) }) }, //精选课程列表 getCourseList(item) { const obj = { storeInfo: "app.config.goodsStore", path: 'jsek_homepageDigitalTextbooks', coverSize: { width: 260 }, paging: { start: 0, size: 4 }, fields: { courseLeader: [], affiliatedUnit: [], publishingUnit: [], classHours: [] } } app.MG.store.getProductList(obj).then((res) => { this.setData({ courseList: res.datas }) }) } });