123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- 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() {
- }
- })
|