school.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // pages/school/school.js
  2. import { getApi, postApi } from "../../apis/api";
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. school: {
  9. id: 1,
  10. crewSchoolName: "新蔡海员培训学校",
  11. crewSchoolImgFileKey:
  12. "new/crew_school/2cd3fd6c-0de4-400c-a847-d7fa07ddd6d31746529627175.png",
  13. crewSchoolImgUrl:
  14. "https://hhd-shipping-1255802371.cos.ap-shanghai.myqcloud.com/new/crew_school/2cd3fd6c-0de4-400c-a847-d7fa07ddd6d31746529627175.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKID4xb091cy4tRikV0EBrGOGsCF1WkhMlum%26q-sign-time%3D1746529628%3B93158697600%26q-key-time%3D1746529628%3B93158697600%26q-header-list%3Dhost%26q-url-param-list%3D%26q-signature%3D659f4bedef396f033e75d39425a4fe00f93dca3c",
  15. crewSchoolIntroduce: "新蔡海员",
  16. crewSchoolSiteSize: 2000,
  17. crewSchoolAnnualGraduationNum: 500,
  18. createTime: "2024/02/01 00:00:00",
  19. },
  20. noticeList: [
  21. {
  22. id: 3,
  23. crewSchoolId: 1,
  24. trainingNoticeTitle: "测试公告",
  25. trainingNoticeImgFileKey:
  26. "new/crew_school_training_notice/31c56330-3e68-4204-860b-87925b0f24dd1746495769145.png",
  27. trainingNoticeImgUrl:
  28. "https://hhd-shipping-1255802371.cos.ap-shanghai.myqcloud.com/new/crew_school_training_notice/31c56330-3e68-4204-860b-87925b0f24dd1746495769145.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKID4xb091cy4tRikV0EBrGOGsCF1WkhMlum%26q-sign-time%3D1746495776%3B93158697600%26q-key-time%3D1746495776%3B93158697600%26q-header-list%3Dhost%26q-url-param-list%3D%26q-signature%3D53284698ccdc5d1cbafe36965c22375effbc3e84",
  29. trainingNoticeContent: "测试内容",
  30. postedBy: "汇很多",
  31. createTime: "2025/04/25 14:42:23",
  32. },
  33. ],
  34. notice: {
  35. title: "海员培训课程将在2025年3月10-15日期间在新蔡学员举办",
  36. author: "汇很多",
  37. date: "2024-02-01",
  38. photoUrl: "../../images/new-version/pic.png",
  39. content:
  40. "为提高海员专业素质,满足航运业发展需求,我校定于2025年3月10日至15日开展新一期海员培训课程。本次培训主要面向有志于从事航海事业的学员,课程内容包括船舶操作技能、航海英语、海事法规、安全管理等方面。培训采用理论与实践相结合的方式,配备经验丰富的教师团队,使用先进的模拟设备,确保学员能够掌握必要的专业知识和实操技能。完成培训并通过考核的学员,将获得相应的培训证书。此次培训名额有限,请有意向的学员提前报名。学校将为学员提供良好的学习环境和完善的后勤保障服务。",
  41. },
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad(options) {
  47. this.getSchoolInfo();
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady() {},
  53. /**
  54. * 生命周期函数--监听页面显示
  55. */
  56. onShow() {
  57. if (typeof this.getTabBar === "function" && this.getTabBar()) {
  58. this.getTabBar().setData({
  59. selected: 5,
  60. });
  61. }
  62. },
  63. /**
  64. * 生命周期函数--监听页面隐藏
  65. */
  66. onHide() {},
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload() {},
  71. /**
  72. * 页面相关事件处理函数--监听用户下拉动作
  73. */
  74. onPullDownRefresh() {},
  75. /**
  76. * 页面上拉触底事件的处理函数
  77. */
  78. onReachBottom() {},
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage(res) {
  83. if (res.from === "button") {
  84. const title = res.target.dataset.title || "海员培训学校通知";
  85. return {
  86. title: title,
  87. path: "/pages/school/school",
  88. };
  89. }
  90. return {
  91. title: "海员培训学校通知",
  92. path: "/pages/school/school",
  93. };
  94. },
  95. makePhoneCall(e) {
  96. const phone = e.currentTarget.dataset.phone;
  97. if (phone) {
  98. wx.makePhoneCall({
  99. phoneNumber: phone,
  100. });
  101. } else {
  102. wx.showToast({
  103. title: "电话号码不存在",
  104. icon: "none",
  105. });
  106. }
  107. },
  108. async getSchoolTrainingNoticeList() {
  109. let { data } = await postApi("/crew/school/training/notices", {
  110. currentPage: 1,
  111. size: 1000,
  112. crewSchoolId: this.data.school.id,
  113. });
  114. if (data.status === 0) {
  115. this.setData({
  116. noticeList: data.result,
  117. });
  118. } else {
  119. this.setData({
  120. noticeList: [],
  121. });
  122. }
  123. },
  124. async getSchoolInfo() {
  125. let { data } = await getApi("/crew/school/info", {});
  126. if (data.status === 0) {
  127. this.setData({
  128. school: data.result,
  129. });
  130. this.getSchoolTrainingNoticeList();
  131. } else {
  132. this.setData({
  133. school: {},
  134. });
  135. }
  136. },
  137. });