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. },
  43. //选项卡滑动
  44. selectItemIndex: function (event: any) {
  45. console.log("click selected", event.detail.selectIndex)
  46. let titleName = "";
  47. switch (Number(event.detail.selectIndex)) {
  48. case 0:
  49. titleName = "开始上课"
  50. break;
  51. case 1:
  52. titleName = "文件库"
  53. break;
  54. case 2:
  55. titleName = "故障报修"
  56. break;
  57. case 3:
  58. titleName = "我的"
  59. break;
  60. }
  61. wx.setNavigationBarTitle({
  62. title: titleName
  63. })
  64. this.setData({
  65. currPageIndex: Number(event.detail.selectIndex)
  66. })
  67. }
  68. })