shipOwnerList.js 2.2 KB

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