detail.js 981 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {
  2. postApi
  3. } from "../../../apis/api"
  4. // pages/index/declarePort/detail.js
  5. Page({
  6. data: {
  7. tab: 1,
  8. detail: {
  9. }
  10. },
  11. changeTab(e) {
  12. this.setData({
  13. tab: e.currentTarget.dataset.tab
  14. })
  15. },
  16. async getDetail(voyageId) {
  17. let res = await postApi('/port/report/detail', {
  18. voyageId
  19. })
  20. this.setData({
  21. detail: res.data.result
  22. })
  23. },
  24. preview(e) {
  25. let {
  26. url
  27. } = e.currentTarget.dataset
  28. wx.previewImage({
  29. urls: [url],
  30. })
  31. },
  32. async report() {
  33. let res = await postApi('/port/report/report', {
  34. voyageId: this.data.detail.voyageId
  35. })
  36. if (res.data.status == 0) {
  37. wx.showToast({
  38. title: '报港成功!',
  39. success: e => {
  40. wx.navigateBack()
  41. }
  42. })
  43. } else {
  44. wx.showToast({
  45. title: res.data.msg,
  46. icon: "error"
  47. })
  48. }
  49. },
  50. onLoad(options) {
  51. let {
  52. id
  53. } = options
  54. this.getDetail(id)
  55. },
  56. })