// pages/digitalCourses/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { barHeight: "", navBarHeight: "", tabPanelstyle: 'display:flex;justify-content:center;align-items:center;', tabList: [], courseList: [], searchValue: '', activeItem: null }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 this.setData({ barHeight: systInfo.statusBarHeight, navBarHeight: navBarHeight, }); this.getCourseTypeListList() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, onTabsChange(event) { const value = event.detail.value this.getCourseList(this.data.tabList[value]) }, goBack() { wx.navigateBack(); }, getCourseTypeListList() { const data = { path: '*', filterList: [{ value: 'Normal', field: 'state' }], queryType: '\\', searchList: [], size: '20', start: '0', storeRefCode: app.config.digitalCourses, sort: { type: 'Asc', field: 'LinkOrder' } } app.MG.store.getStoreChannelList(data).then((res) => { // 去除数组最后一个元素 const newData = res.datas.slice(0, res.datas.length - 1) this.setData({ tabList: newData, activeItem: newData[0] }) this.getCourseList(newData[0]) }) }, getCourseList(item) { let searchObj = {} // let sort = {} // // 搜索框 if (this.data.searchValue) { searchObj = { 'Name*': this.data.searchValue.trim() // '||subtitle*': searchInputValue.value.trim() } } // if (timeSort.value) { // sort = { // CreateDate: timeSort.value || 'Desc' // } // } else { // sort = { // ViewCount: nameSort.value || 'Desc' // } // // 组合的写法 要查询的字段:升序和降序 // // Name: "Desc" // //一般的排序传法 // // type: "Asc", // // field: "CreateDate", // } // courseList.value = []; const obj = { storeInfo: app.config.goodsStore, path: item.pathList + '\\' + item.id, coverSize: { width: 260 }, paging: { start: 0, size: 99 }, filterList: [{ value: 'Normal', field: 'state' }], // sort: sort, fields: { courseLeader: [], affiliatedUnit: [], publishingUnit: [], classHours: [], ViewCount: [], ...searchObj } } app.MG.store.getProductList(obj).then((res) => { console.log(res, '7895') res.datas.forEach(item => { item.price = item.price.toFixed(2) }) this.setData({ courseList: res.datas }) console.log(this.data.courseList); }) }, searchBook() { console.log(this.data.searchValue); this.getCourseList(this.data.activeItem) }, courseDetail(e) { console.log(e); const item = e.currentTarget.dataset.item wx.navigateTo({ url: '/pages/digitalCourses/digitalCoursesDetails/index?id=' + item.id, }) } })