unknown
2024-02-27 7edbade4d2b1c74360d0cf40cdaa2eb0de379132
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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
      })
    })
  }
});