school.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // pages/school/school.js
  2. import { getApi, postApi } from "../../apis/api";
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. school: {},
  9. noticeList: [],
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad(options) {
  15. this.getSchoolInfo();
  16. },
  17. /**
  18. * 生命周期函数--监听页面初次渲染完成
  19. */
  20. onReady() {},
  21. /**
  22. * 生命周期函数--监听页面显示
  23. */
  24. onShow() {
  25. if (typeof this.getTabBar === "function" && this.getTabBar()) {
  26. this.getTabBar().setData({
  27. selected: 5,
  28. });
  29. }
  30. },
  31. /**
  32. * 生命周期函数--监听页面隐藏
  33. */
  34. onHide() {},
  35. /**
  36. * 生命周期函数--监听页面卸载
  37. */
  38. onUnload() {},
  39. /**
  40. * 页面相关事件处理函数--监听用户下拉动作
  41. */
  42. onPullDownRefresh() {},
  43. /**
  44. * 页面上拉触底事件的处理函数
  45. */
  46. onReachBottom() {},
  47. /**
  48. * 用户点击右上角分享
  49. */
  50. share(e) {
  51. this.setData({
  52. shareNoticeId: e.currentTarget.dataset.id,
  53. shareNoticeTitle: e.currentTarget.dataset.title,
  54. });
  55. },
  56. onShareAppMessage() {
  57. return {
  58. title: this.data.shareNoticeTitle,
  59. path: `/pages/school/sharePage/sharePage?noticeId=${this.data.shareNoticeId}`,
  60. imageUrl: "../../images/logo541.png",
  61. };
  62. },
  63. makePhoneCall(e) {
  64. const phone = e.currentTarget.dataset.phone;
  65. if (phone) {
  66. wx.makePhoneCall({
  67. phoneNumber: phone,
  68. });
  69. } else {
  70. wx.showToast({
  71. title: "电话号码不存在",
  72. icon: "none",
  73. });
  74. }
  75. },
  76. async getSchoolTrainingNoticeList() {
  77. let { data } = await postApi("/crew/school/training/notices", {
  78. currentPage: 1,
  79. size: 1000,
  80. crewSchoolId: this.data.school.id,
  81. });
  82. if (data.status === 0) {
  83. this.setData({
  84. noticeList: data.result,
  85. });
  86. } else {
  87. this.setData({
  88. noticeList: [],
  89. });
  90. }
  91. },
  92. async getSchoolInfo() {
  93. let { data } = await getApi("/crew/school/info", {});
  94. if (data.status === 0) {
  95. this.setData({
  96. school: data.result,
  97. });
  98. this.getSchoolTrainingNoticeList();
  99. } else {
  100. this.setData({
  101. school: {},
  102. });
  103. }
  104. },
  105. });