sharePage.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. makePhoneCall: function (e) {
  12. const phoneNumber = e.currentTarget.dataset.phone;
  13. if (phoneNumber) {
  14. wx.makePhoneCall({
  15. phoneNumber: phoneNumber,
  16. });
  17. } else {
  18. wx.showToast({
  19. title: "电话号码不存在",
  20. icon: "none",
  21. });
  22. }
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad(options) {
  28. const shipyardId = options.shipyardId;
  29. if (shipyardId) {
  30. this.getSharedTrainingNotice(shipyardId);
  31. } else {
  32. wx.showToast({
  33. title: "无效的分享链接",
  34. icon: "none",
  35. });
  36. }
  37. },
  38. async getSharedTrainingNotice(shipyardId) {
  39. wx.showLoading({
  40. title: "加载中...",
  41. });
  42. let { data } = await postApi("/shipyard/info/share", {
  43. shipyardId,
  44. });
  45. wx.hideLoading();
  46. if (data.status === 0) {
  47. this.setData({
  48. sharedTrainingNotice: data.result,
  49. });
  50. } else {
  51. wx.showToast({
  52. title: data.msg || "获取通知信息失败",
  53. icon: "none",
  54. });
  55. }
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady() {},
  61. /**
  62. * 生命周期函数--监听页面显示
  63. */
  64. onShow() {},
  65. /**
  66. * 生命周期函数--监听页面隐藏
  67. */
  68. onHide() {},
  69. /**
  70. * 生命周期函数--监听页面卸载
  71. */
  72. onUnload() {},
  73. /**
  74. * 页面相关事件处理函数--监听用户下拉动作
  75. */
  76. onPullDownRefresh() {},
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom() {},
  81. /**
  82. * 用户点击右上角分享
  83. */
  84. onShareAppMessage() {},
  85. });