classification.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const { ificationContent } = require('../../utils/data.js')
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. activeIndex:0,
  8. VerticalNavTop: 0,
  9. TabCur: 0,
  10. ificationTitle:[
  11. {title:"有声书"},
  12. {title:"畅销书"},
  13. {title:"儿童"},
  14. {title:"相声评书"},
  15. {title:"情感生活"},
  16. {title:"人文"},
  17. {title:"历史"},
  18. {title:"国学书院"},
  19. {title:"音乐"},
  20. {title:"英语"},
  21. {title:"教育培训"},
  22. {title:"健康养生"},
  23. {title:"广播剧"},
  24. {title:"戏曲"}
  25. ],
  26. ificationContent:ificationContent
  27. },
  28. onLoad() {
  29. const that = this;
  30. //调用getSystemInfo APi获取到用户的手机屏幕高度,动态设置scroll-view的高度
  31. // 还有缺陷,代改进
  32. wx.getSystemInfo({
  33. success (res) {
  34. // var heightleft = (res.windowHeight*2);
  35. const height = (res.windowHeight*2);
  36. that.setData({
  37. phoneHeight: height,
  38. })
  39. }
  40. })
  41. },
  42. //随着滚动动态设置左侧边栏的选中态
  43. showActive(e) {
  44. //方法欠佳,还需改进
  45. const index = parseInt(e.detail.scrollTop/116);
  46. this.setData({
  47. activeIndex: index
  48. })
  49. },
  50. // 侧边栏的点击事件
  51. change(e) {
  52. const { index, id } = e.currentTarget.dataset
  53. this.setData({
  54. VerticalNavTop: (index - 1) * 50,
  55. activeIndex:index,
  56. TabCur: id,
  57. })
  58. },
  59. })