shipOwnerList.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // pages/shipOwnerManage/shipOwnerList/shipOwnerList.js
  2. import {
  3. uploadFile
  4. } from "../../../utils/upload"
  5. import {
  6. postApi
  7. } from "../../../apis/api"
  8. Page({
  9. data: {
  10. shipOwnerList: [],
  11. term: '',
  12. currentLetter: '',
  13. timer: new Date().toJSON().substring(0, 10)
  14. },
  15. async getShipOwnerList(type) {
  16. if (!wx.getStorageSync('loginAccountId')) {
  17. this.setData({
  18. shipOwnerList: [],
  19. currentLetter: ''
  20. })
  21. wx.showToast({
  22. title: '尚未登录',
  23. icon: "error"
  24. })
  25. return
  26. }
  27. let res = await postApi('/ship/wx/list', {
  28. loginAccountId: wx.getStorageSync('loginAccountId'),
  29. term: this.data.term
  30. })
  31. if (type) wx.stopPullDownRefresh()
  32. if (res.data.status == 0) {
  33. if (res.data.result.length == 0) {
  34. wx.showToast({
  35. title: '暂无数据',
  36. icon: "error"
  37. })
  38. return
  39. }
  40. let shipOwnerList = res.data.result
  41. shipOwnerList[0].letter = "#"
  42. shipOwnerList.push(shipOwnerList.shift())
  43. this.setData({
  44. shipOwnerList
  45. })
  46. } else {
  47. this.setData({
  48. shipOwnerList: []
  49. })
  50. }
  51. },
  52. call(e) {
  53. wx.makePhoneCall({
  54. phoneNumber: e.currentTarget.dataset.phone
  55. })
  56. },
  57. addShipOwner() {
  58. if (!wx.getStorageSync('loginAccountId')) {
  59. wx.showToast({
  60. title: '尚未登录',
  61. icon: "error"
  62. })
  63. return
  64. }
  65. wx.navigateTo({
  66. url: '../addShipOnwer/addShipOnwer',
  67. })
  68. },
  69. tapLetter(e) {
  70. this.setData({
  71. currentLetter: e.currentTarget.dataset.letter
  72. })
  73. },
  74. createVoyage(e) {
  75. console.log(e)
  76. let {
  77. shipId,
  78. shipName
  79. } = e.currentTarget.dataset.shipowner
  80. wx.showModal({
  81. title: '是否创建航次?',
  82. content: shipName,
  83. success(res) {
  84. if (res.confirm) {
  85. wx.navigateTo({
  86. url: `/pages/voyageManage/createVoyage/createVoyage?shipId=${shipId}&shipName=${shipName}`,
  87. })
  88. } else if (res.cancel) {
  89. console.log('用户点击取消')
  90. }
  91. },
  92. fail: e => {
  93. console.log(e)
  94. }
  95. })
  96. },
  97. onLoad() {
  98. },
  99. onPullDownRefresh() {
  100. this.setData({
  101. term: ''
  102. })
  103. this.getShipOwnerList(1)
  104. },
  105. onShow() {
  106. this.getShipOwnerList()
  107. }
  108. })