sharePage.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // pages/shipyard/sharePage/sharePage.js
  2. import { postApi } from "../../../apis/api";
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. sharedTrainingNotice: null, // 用于存储分享的培训通知信息
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad(options) {
  15. const noticeId = options.noticeId;
  16. if (noticeId) {
  17. this.getSharedTrainingNotice(noticeId);
  18. } else {
  19. wx.showToast({
  20. title: "无效的分享链接",
  21. icon: "none",
  22. });
  23. }
  24. },
  25. getSharedTrainingNotice(noticeId) {
  26. // 调用API获取分享的培训通知信息
  27. // API: POST /crew/school/training/notice/share
  28. // 参数: noticeId (query)
  29. wx.showLoading({
  30. title: "加载中...",
  31. });
  32. postApi("/crew/school/training/notice/share", { noticeId })
  33. .then((res) => {
  34. wx.hideLoading();
  35. if (res.success && res.data) {
  36. this.setData({
  37. sharedTrainingNotice: res.data,
  38. });
  39. } else {
  40. wx.showToast({
  41. title: res.msg || "获取培训通知失败",
  42. icon: "none",
  43. });
  44. }
  45. })
  46. .catch((err) => {
  47. wx.hideLoading();
  48. wx.showToast({
  49. title: "网络错误",
  50. icon: "none",
  51. });
  52. console.error("获取分享培训通知信息失败:", err);
  53. });
  54. },
  55. /**
  56. * 生命周期函数--监听页面初次渲染完成
  57. */
  58. onReady() {},
  59. /**
  60. * 生命周期函数--监听页面显示
  61. */
  62. onShow() {},
  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() {},
  83. });