From 7edbade4d2b1c74360d0cf40cdaa2eb0de379132 Mon Sep 17 00:00:00 2001
From: unknown <unknown@example.com>
Date: 星期二, 27 二月 2024 09:32:14 +0800
Subject: [PATCH] 中台

---
 pages/home/home.js |  185 +++++++++++++++++++++++----------------------
 1 files changed, 94 insertions(+), 91 deletions(-)

diff --git a/pages/home/home.js b/pages/home/home.js
index 68bb735..d55db36 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,6 +27,7 @@
 
   onShow() {
     this.getTabBar().init();
+    this.loadHomePage();
     this.getBannerList()
   },
 
@@ -37,17 +36,13 @@
   },
 
   onReachBottom() {
-    if (this.data.goodsListLoadStatus === 0) {
-      this.loadGoodsList();
-    }
   },
-
   onPullDownRefresh() {
     this.init();
   },
-
   init() {
-    this.loadHomePage();
+    this.getSubjectList();
+    this.getCourseList();
   },
   getBannerList() {
     const list = []
@@ -69,82 +64,12 @@
     })
     console.log('杞挱鍥�', this.data.bannerList);
   },
-  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 data = this.data.bannerList[detail.index]
     console.log('璺宠浆', data.link);
     // const { index: promotionID = 0 } = detail || {};
@@ -152,4 +77,82 @@
     //   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
+      })
+    })
+  }
 });

--
Gitblit v1.9.1