cert.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // pages/cert/cert.js
  2. import { postApi, getApi } from "../../apis/api";
  3. Page({
  4. data: {
  5. certs: [],
  6. contacts: [],
  7. introduce: {},
  8. },
  9. async getCerts() {
  10. let { data } = await postApi("/ship/cert/list", {
  11. userId: wx.getStorageSync("userId"),
  12. });
  13. if (data.status === 0) {
  14. data.result.forEach((cert) => {
  15. cert.endValidTime = cert.endValidTime.split(" ")[0];
  16. });
  17. this.setData({
  18. certs: data.result,
  19. });
  20. } else {
  21. this.setData({
  22. certs: [],
  23. });
  24. wx.showToast({
  25. title: data.msg,
  26. icon: "none",
  27. });
  28. }
  29. },
  30. async getContacts() {
  31. let { data } = await getApi("/ship/cert/operation/contacts");
  32. if (data.status === 0) {
  33. this.setData({
  34. contacts: data.result,
  35. });
  36. } else {
  37. this.setData({
  38. contacts: [],
  39. });
  40. wx.showToast({
  41. title: data.msg,
  42. icon: "none",
  43. });
  44. }
  45. },
  46. async getIntroduce() {
  47. let { data } = await getApi("/ship/cert/operation/introduce");
  48. if (data.status === 0) {
  49. this.setData({
  50. introduce: data.result,
  51. });
  52. } else {
  53. this.setData({
  54. introduce: {},
  55. });
  56. wx.showToast({
  57. title: data.msg,
  58. icon: "none",
  59. });
  60. }
  61. },
  62. makePhoneCall(e) {
  63. wx.makePhoneCall({
  64. phoneNumber: e.currentTarget.dataset.phone,
  65. });
  66. },
  67. preview(e) {
  68. wx.previewImage({
  69. urls: [e.currentTarget.dataset.url],
  70. });
  71. },
  72. copy(e) {
  73. wx.setClipboardData({
  74. data: e.currentTarget.dataset.phone,
  75. success(res) {
  76. wx.showToast({
  77. title: "复制成功",
  78. });
  79. },
  80. });
  81. },
  82. onLoad(options) {
  83. this.getCerts();
  84. this.getContacts();
  85. this.getIntroduce();
  86. },
  87. onShow() {
  88. if (typeof this.getTabBar === "function" && this.getTabBar()) {
  89. this.getTabBar().setData({
  90. selected: 1,
  91. });
  92. }
  93. },
  94. });