From 4cf55474ff49d11150dfaca3633224eceea47823 Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期三, 28 二月 2024 17:21:05 +0800 Subject: [PATCH] 书展和书展详情 --- pages/home/home.js | 163 ++++++++++++++++++++++++++---------------------------- 1 files changed, 78 insertions(+), 85 deletions(-) diff --git a/pages/home/home.js b/pages/home/home.js index 68bb735..004dc03 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -1,21 +1,19 @@ import { fetchHome } from '../../services/home/home'; -import { fetchGoodsList } from '../../services/good/fetchGoods'; -import Toast from 'tdesign-miniprogram/toast/index'; const app = getApp() Page({ data: { - imgSrcs: [], - tabList: [], - goodsList: [], - goodsListLoadStatus: 0, + tabList: [], //鐩綍 pageLoading: false, - current: 1, - autoplay: true, - duration: '500', - interval: 5000, - navigation: { type: 'dots' }, - swiperImageProps: { mode: 'scaleToFill' }, - bannerList: [], + current: 1,//杞挱鍥惧弬鏁� + autoplay: true, //杞挱鍥惧弬鏁� + duration: '500',//杞挱鍥惧弬鏁� + interval: 5000,//杞挱鍥惧弬鏁� + navigation: { type: 'dots' },//杞挱鍥惧弬鏁� + bannerList: [], //杞挱鍥惧垪琛� + specialSubjectList: [],//涓撻璁ㄨ + courseList: [], + booksList: [], + textbookList: [] }, goodListPagination: { @@ -29,7 +27,9 @@ onShow() { this.getTabBar().init(); + this.loadHomePage(); this.getBannerList() + }, onLoad() { @@ -37,17 +37,13 @@ }, onReachBottom() { - if (this.data.goodsListLoadStatus === 0) { - this.loadGoodsList(); - } }, - onPullDownRefresh() { this.init(); }, - init() { - this.loadHomePage(); + this.getSubjectList(); + this.getCourseList(); }, getBannerList() { const list = [] @@ -69,87 +65,84 @@ }) console.log('杞挱鍥�', this.data.bannerList); }, + + loadHomePage() { wx.stopPullDownRefresh(); - this.setData({ pageLoading: true, }); - fetchHome().then(({ swiper, tabList }) => { + fetchHome().then(({ 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, - }); + //鐐瑰嚮鐩綍 + toPages(item) { + let info = item.target.dataset.info + if (info.url) { + wx.navigateTo({ + url: info.url + }) + } else { + wx.showToast({ + title: "寤鸿涓�", + icon: 'none', + duration: 2000 + }) } - - this.setData({ goodsListLoadStatus: 1 }); - - const pageSize = this.goodListPagination.num; - let pageIndex = this.privateData.tabIndex * pageSize + this.goodListPagination.index + 1; - if (fresh) { - pageIndex = 0; + }, + //涓撻璁ㄨ + getSubjectList() { + const obj = { + storeInfo: "jsek_seminar", + path: 'jsek_homepageSeminar', + coverSize: { + width: 400 + }, + paging: { + start: 0, + size: 3 + }, + fields: { + liveTime: [], + lecturer: [], + startTime: [], + jsek_link: [] + } } - - try { - const nextList = await fetchGoodsList(pageIndex, pageSize); + app.MG.store.getProductList(obj).then((res) => { 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 }); + 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 + }) + }) }, - 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 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}`, - // }); - }, }); -- Gitblit v1.9.1