shipyard.js 1.8 KB

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