index.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // pages/teacher/index/index.ts
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. tabJson: [{ icon: "../../image/teacher/monitor.png", selectedIcon: "../../image/teacher/monitor_selected.png", title: "监控" },
  8. { icon: "../../image/teacher/file.png", selectedIcon: "../../image/teacher/file_selected.png", title: "文件库" },
  9. { icon: "../../image/teacher/fault.png", selectedIcon: "../../image/teacher/fault_selected.png", title: "报修" },
  10. { icon: "../../image/teacher/my.png", selectedIcon: "../../image/teacher/my_selected.png", title: "我的" }
  11. ],
  12. currPageIndex: 0
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad() {
  18. console.log(this.data.tabJson)
  19. },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady() {
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow() {
  29. },
  30. /**
  31. * 生命周期函数--监听页面隐藏
  32. */
  33. onHide() {
  34. },
  35. /**
  36. * 生命周期函数--监听页面卸载
  37. */
  38. onUnload() {
  39. },
  40. //禁止用户手滑选项卡
  41. catchTouchMove: function () {
  42. return false
  43. },
  44. //选项卡滑动
  45. selectItemIndex: function (event: any) {
  46. console.log("click selected", event.detail.selectIndex)
  47. let titleName = "";
  48. switch (Number(event.detail.selectIndex)) {
  49. case 0:
  50. titleName = "开始上课"
  51. break;
  52. case 1:
  53. titleName = "文件库"
  54. break;
  55. case 2:
  56. titleName = "故障报修"
  57. break;
  58. case 3:
  59. titleName = "我的"
  60. break;
  61. }
  62. wx.setNavigationBarTitle({
  63. title: titleName
  64. })
  65. this.setData({
  66. currPageIndex: Number(event.detail.selectIndex)
  67. })
  68. }
  69. })