sharePage.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // pages/school/sharePage/sharePage.js
  2. import { postApi } from "../../../apis/api";
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. sharedShipyardInfo: null, // 用于存储分享的船厂信息
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad(options) {
  15. const shipyardId = options.shipyardId;
  16. if (shipyardId) {
  17. this.getSharedShipyardInfo(shipyardId);
  18. } else {
  19. wx.showToast({
  20. title: "无效的分享链接",
  21. icon: "none",
  22. });
  23. }
  24. },
  25. async getSharedShipyardInfo(shipyardId) {
  26. wx.showLoading({
  27. title: "加载中...",
  28. });
  29. let { data } = await postApi("/shipyard/info/share", { shipyardId });
  30. wx.hideLoading();
  31. if (data.status === 0) {
  32. this.setData({
  33. sharedShipyardInfo: data.result,
  34. });
  35. } else {
  36. wx.showToast({
  37. title: data.msg || "获取船厂信息失败",
  38. icon: "none",
  39. });
  40. }
  41. },
  42. /**
  43. * 生命周期函数--监听页面初次渲染完成
  44. */
  45. onReady() {},
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow() {},
  50. /**
  51. * 生命周期函数--监听页面隐藏
  52. */
  53. onHide() {},
  54. /**
  55. * 生命周期函数--监听页面卸载
  56. */
  57. onUnload() {},
  58. /**
  59. * 页面相关事件处理函数--监听用户下拉动作
  60. */
  61. onPullDownRefresh() {},
  62. /**
  63. * 页面上拉触底事件的处理函数
  64. */
  65. onReachBottom() {},
  66. /**
  67. * 用户点击右上角分享
  68. */
  69. onShareAppMessage() {},
  70. });