cert.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. this.setData({
  15. certs: data.result,
  16. });
  17. } else {
  18. this.setData({
  19. certs: [],
  20. });
  21. wx.showToast({
  22. title: data.msg,
  23. icon: "none",
  24. });
  25. }
  26. },
  27. async getContacts() {
  28. let { data } = await getApi("/ship/cert/operation/contacts");
  29. if (data.status === 0) {
  30. this.setData({
  31. contacts: data.result,
  32. });
  33. } else {
  34. this.setData({
  35. contacts: [],
  36. });
  37. wx.showToast({
  38. title: data.msg,
  39. icon: "none",
  40. });
  41. }
  42. },
  43. async getIntroduce() {
  44. let { data } = await getApi("/ship/cert/operation/introduce");
  45. if (data.status === 0) {
  46. this.setData({
  47. introduce: data.result,
  48. });
  49. } else {
  50. this.setData({
  51. introduce: [],
  52. });
  53. wx.showToast({
  54. title: data.msg,
  55. icon: "none",
  56. });
  57. }
  58. },
  59. makePhoneCall(e) {
  60. wx.makePhoneCall({
  61. phoneNumber: e.currentTarget.dataset.phone,
  62. });
  63. },
  64. preview(e) {
  65. wx.previewImage({
  66. urls: [e.currentTarget.dataset.url],
  67. });
  68. },
  69. copy(e) {
  70. wx.setClipboardData({
  71. data: e.currentTarget.dataset.phone,
  72. success(res) {
  73. wx.showToast({
  74. title: "复制成功",
  75. });
  76. },
  77. });
  78. },
  79. onLoad(options) {
  80. this.getCerts();
  81. this.getContacts();
  82. this.getIntroduce();
  83. },
  84. });