const getHeight = require("../../utils/getRheRemainingHeight"); const _Http = getApp().globalData.http; Page({ /** * 页面的初始数据 */ data: { scrollHeight: 0, //滚动区域高度 searchContent: "", //搜索内容 mainActiveIndex: 0, //分类选择器打开分类的下标 activeId: null, //分类选择器选择id showText: null, //左上显示文本 items: [], //分类列表 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.selectMenu(0); _Http.basic({ "classname": "saletool.courseware.courseware", "method": "selectList", "content": { "pageNumber": 1, "pageSize": 10, "where": { "condition": "", "sorttype": 2, "sat_courseware_classid": 31 } } }).then(res => { console.log(res) }) }, /* 查询菜单分类 */ selectMenu(index) { if (index == '5') return wx.showToast({ title: '加载失败,请稍后再试', icon: "none" }) _Http.basic({ "classname": "saletool.courseware.courseware", "method": "selectMenu", "content": {} }).then(res => { console.log(res) if (res.msg != '成功') return this.selectMenu(index + 1) let str = JSON.stringify(res.data).replace(/classname/g, 'text').replace(/sat_courseware_classid/g, 'id'); this.setData({ items: JSON.parse(str) }) }) }, onClickNav({ detail = {} }) { this.setData({ mainActiveIndex: detail.index || 0, }); }, onClickItem({ detail = {} }) { const activeId = this.data.activeId === detail.id ? null : detail.id, showText = this.data.showText === detail.text ? null : detail.text; this.setData({ activeId, showText }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { //滚动区域高度 getHeight.getHeight('.menu', this).then(res => { this.setData({ scrollHeight: res }) }) }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })