cert.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // pages/cert/cert.js
  2. import { postApi, getApi } from "../../apis/api";
  3. Page({
  4. data: {
  5. shipName: "长江之星",
  6. mmsi: "413123456",
  7. shipCerts: [
  8. {
  9. name: "船舶检验证书",
  10. photoUrl: "../../images/new-version/pic.png",
  11. expireDate: "2024-12-31",
  12. },
  13. {
  14. name: "船舶营运证",
  15. photoUrl: "../../images/new-version/pic.png",
  16. expireDate: "2024-06-30",
  17. },
  18. ],
  19. crewCerts: [
  20. {
  21. name: "张三",
  22. medicalReport: "../../images/new-version/pic.png",
  23. serviceBook: "../../images/new-version/pic.png",
  24. certificates: [
  25. {
  26. name: "船员适任证书",
  27. photoUrl: "../../images/new-version/pic.png",
  28. expireDate: "2024-12-31",
  29. },
  30. {
  31. name: "特殊培训合格证",
  32. photoUrl: "../../images/new-version/pic.png",
  33. expireDate: "2024-09-30",
  34. },
  35. ],
  36. },
  37. {
  38. name: "李四",
  39. medicalReport: "../../images/new-version/pic.png",
  40. serviceBook: "../../images/new-version/pic.png",
  41. certificates: [
  42. {
  43. name: "船员适任证书",
  44. photoUrl: "../../images/new-version/pic.png",
  45. expireDate: "2024-11-30",
  46. },
  47. ],
  48. },
  49. ],
  50. certs: [],
  51. contacts: [],
  52. introduce: {},
  53. },
  54. async getCerts() {
  55. let { data } = await postApi("/ship/cert/list", {
  56. userId: wx.getStorageSync("userId"),
  57. });
  58. if (data.status === 0) {
  59. data.result.forEach((cert) => {
  60. cert.endValidTime = cert.endValidTime.split(" ")[0];
  61. });
  62. this.setData({
  63. certs: data.result,
  64. });
  65. } else {
  66. this.setData({
  67. certs: [],
  68. });
  69. wx.showToast({
  70. title: data.msg,
  71. icon: "none",
  72. });
  73. }
  74. },
  75. async getContacts() {
  76. let { data } = await getApi("/ship/cert/operation/contacts");
  77. if (data.status === 0) {
  78. this.setData({
  79. contacts: data.result,
  80. });
  81. } else {
  82. this.setData({
  83. contacts: [],
  84. });
  85. wx.showToast({
  86. title: data.msg,
  87. icon: "none",
  88. });
  89. }
  90. },
  91. async getIntroduce() {
  92. let { data } = await getApi("/ship/cert/operation/introduce");
  93. if (data.status === 0) {
  94. this.setData({
  95. introduce: data.result,
  96. });
  97. } else {
  98. this.setData({
  99. introduce: {},
  100. });
  101. wx.showToast({
  102. title: data.msg,
  103. icon: "none",
  104. });
  105. }
  106. },
  107. makePhoneCall(e) {
  108. wx.makePhoneCall({
  109. phoneNumber: e.currentTarget.dataset.phone,
  110. });
  111. },
  112. preview(e) {
  113. wx.previewImage({
  114. urls: [e.currentTarget.dataset.url],
  115. });
  116. },
  117. copy(e) {
  118. wx.setClipboardData({
  119. data: e.currentTarget.dataset.phone,
  120. success(res) {
  121. wx.showToast({
  122. title: "复制成功",
  123. });
  124. },
  125. });
  126. },
  127. onLoad(options) {
  128. this.getCerts();
  129. this.getContacts();
  130. this.getIntroduce();
  131. },
  132. onShow() {
  133. if (typeof this.getTabBar === "function" && this.getTabBar()) {
  134. this.getTabBar().setData({
  135. selected: 1,
  136. });
  137. }
  138. },
  139. });