index.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. canChangeIndex: true
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad() {
  19. console.log(this.data.tabJson)
  20. },
  21. /**
  22. * 生命周期函数--监听页面初次渲染完成
  23. */
  24. onReady() {
  25. },
  26. /**
  27. * 生命周期函数--监听页面显示
  28. */
  29. onShow() {
  30. },
  31. /**
  32. * 生命周期函数--监听页面隐藏
  33. */
  34. onHide() {
  35. },
  36. /**
  37. * 生命周期函数--监听页面卸载
  38. */
  39. onUnload() {
  40. },
  41. //禁止用户手滑选项卡
  42. catchTouchMove: function () {
  43. },
  44. //是否能切换index
  45. canChangeIndex: function (event: any) {
  46. this.setData({
  47. canChangeIndex: event.detail.canChange
  48. })
  49. },
  50. //选项卡滑动
  51. selectItemIndex: function (event: any) {
  52. console.log("click selected", event.detail.selectIndex)
  53. let titleName = "";
  54. switch (Number(event.detail.selectIndex)) {
  55. case 0:
  56. titleName = "开始上课"
  57. break;
  58. case 1:
  59. titleName = "文件库"
  60. break;
  61. case 2:
  62. titleName = "故障报修"
  63. break;
  64. case 3:
  65. titleName = "我的"
  66. break;
  67. }
  68. wx.setNavigationBarTitle({
  69. title: titleName
  70. })
  71. this.setData({
  72. currPageIndex: Number(event.detail.selectIndex)
  73. })
  74. },
  75. showWindow: function (event: any) {
  76. console.log("clickId:", event.detail.item)
  77. let window = this.selectComponent("#popupwindow")
  78. window.showModal(event.detail.item, 0);
  79. },
  80. hideWindow: function () {
  81. this.selectComponent("#teacherFile").hideWindow();
  82. },
  83. fileDel: function () {
  84. console.log("有文件被删除了")
  85. this.selectComponent("#teacherFile").realod();
  86. }
  87. })