// pages/cert/cert.js import { postApi, getApi } from "../../apis/api"; Page({ data: { shipName: "长江之星", mmsi: "413123456", shipCerts: [ { name: "船舶检验证书", photoUrl: "https://example.com/cert1.jpg", expireDate: "2024-12-31", }, { name: "船舶营运证", photoUrl: "https://example.com/cert2.jpg", expireDate: "2024-06-30", }, ], crewCerts: [ { name: "张三", medicalReport: "https://example.com/medical1.jpg", serviceBook: "https://example.com/service1.jpg", certificates: [ { name: "船员适任证书", photoUrl: "https://example.com/crew_cert1.jpg", expireDate: "2024-12-31", }, { name: "特殊培训合格证", photoUrl: "https://example.com/crew_cert2.jpg", expireDate: "2024-09-30", }, ], }, { name: "李四", medicalReport: "https://example.com/medical2.jpg", serviceBook: "https://example.com/service2.jpg", certificates: [ { name: "船员适任证书", photoUrl: "https://example.com/crew_cert3.jpg", expireDate: "2024-11-30", }, ], }, ], certs: [], contacts: [], introduce: {}, }, async getCerts() { let { data } = await postApi("/ship/cert/list", { userId: wx.getStorageSync("userId"), }); if (data.status === 0) { data.result.forEach((cert) => { cert.endValidTime = cert.endValidTime.split(" ")[0]; }); this.setData({ certs: data.result, }); } else { this.setData({ certs: [], }); wx.showToast({ title: data.msg, icon: "none", }); } }, async getContacts() { let { data } = await getApi("/ship/cert/operation/contacts"); if (data.status === 0) { this.setData({ contacts: data.result, }); } else { this.setData({ contacts: [], }); wx.showToast({ title: data.msg, icon: "none", }); } }, async getIntroduce() { let { data } = await getApi("/ship/cert/operation/introduce"); if (data.status === 0) { this.setData({ introduce: data.result, }); } else { this.setData({ introduce: {}, }); wx.showToast({ title: data.msg, icon: "none", }); } }, makePhoneCall(e) { wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.phone, }); }, preview(e) { wx.previewImage({ urls: [e.currentTarget.dataset.url], }); }, copy(e) { wx.setClipboardData({ data: e.currentTarget.dataset.phone, success(res) { wx.showToast({ title: "复制成功", }); }, }); }, onLoad(options) { this.getCerts(); this.getContacts(); this.getIntroduce(); }, onShow() { if (typeof this.getTabBar === "function" && this.getTabBar()) { this.getTabBar().setData({ selected: 1, }); } }, });