index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. const getHeight = require("../../utils/getRheRemainingHeight");
  2. const _Http = getApp().globalData.http;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. scrollHeight: 0, //滚动区域高度
  9. searchContent: "", //搜索内容
  10. mainActiveIndex: 0, //分类选择器打开分类的下标
  11. activeId: null, //分类选择器选择id
  12. showText: null, //左上显示文本
  13. items: [], //分类列表
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad(options) {
  19. this.selectMenu(0);
  20. _Http.basic({
  21. "classname": "saletool.courseware.courseware",
  22. "method": "selectList",
  23. "content": {
  24. "pageNumber": 1,
  25. "pageSize": 10,
  26. "where": {
  27. "condition": "",
  28. "sorttype": 2,
  29. "sat_courseware_classid": 31
  30. }
  31. }
  32. }).then(res => {
  33. console.log(res)
  34. })
  35. },
  36. /* 查询菜单分类 */
  37. selectMenu(index) {
  38. if (index == '5') return wx.showToast({
  39. title: '加载失败,请稍后再试',
  40. icon: "none"
  41. })
  42. _Http.basic({
  43. "classname": "saletool.courseware.courseware",
  44. "method": "selectMenu",
  45. "content": {}
  46. }).then(res => {
  47. console.log(res)
  48. if (res.msg != '成功') return this.selectMenu(index + 1)
  49. let str = JSON.stringify(res.data).replace(/classname/g, 'text').replace(/sat_courseware_classid/g, 'id');
  50. this.setData({
  51. items: JSON.parse(str)
  52. })
  53. })
  54. },
  55. onClickNav({
  56. detail = {}
  57. }) {
  58. this.setData({
  59. mainActiveIndex: detail.index || 0,
  60. });
  61. },
  62. onClickItem({
  63. detail = {}
  64. }) {
  65. const activeId = this.data.activeId === detail.id ? null : detail.id,
  66. showText = this.data.showText === detail.text ? null : detail.text;
  67. this.setData({
  68. activeId,
  69. showText
  70. });
  71. },
  72. /**
  73. * 生命周期函数--监听页面初次渲染完成
  74. */
  75. onReady() {
  76. //滚动区域高度
  77. getHeight.getHeight('.menu', this).then(res => {
  78. this.setData({
  79. scrollHeight: res
  80. })
  81. })
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide() {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload() {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh() {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom() {
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage() {
  112. }
  113. })