shipOwnerList.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. wx.showToast({
  17. title: '尚未登录',
  18. icon: "error"
  19. })
  20. return
  21. }
  22. let res = await postApi('/ship/list', {
  23. loginAccountId: wx.getStorageSync('loginAccountId'),
  24. term: this.data.term
  25. })
  26. if (type) wx.stopPullDownRefresh()
  27. if (res.data.status == 0) {
  28. let shipOwnerList = res.data.result
  29. shipOwnerList[0].letter = "#"
  30. shipOwnerList.push(shipOwnerList.shift())
  31. this.setData({
  32. shipOwnerList
  33. })
  34. } else {
  35. this.setData({
  36. shipOwnerList: []
  37. })
  38. }
  39. },
  40. call(e) {
  41. wx.makePhoneCall({
  42. phoneNumber: e.currentTarget.dataset.phone
  43. })
  44. },
  45. addShipOwner() {
  46. if (!wx.getStorageSync('loginAccountId')) {
  47. wx.showToast({
  48. title: '尚未登录',
  49. icon: "error"
  50. })
  51. return
  52. }
  53. wx.navigateTo({
  54. url: '../addShipOnwer/addShipOnwer',
  55. })
  56. },
  57. tapLetter(e) {
  58. this.setData({
  59. currentLetter: e.currentTarget.dataset.letter
  60. })
  61. },
  62. onLoad() {
  63. },
  64. onPullDownRefresh() {
  65. this.setData({
  66. term: ''
  67. })
  68. this.getShipOwnerList(1)
  69. },
  70. onShow() {
  71. this.getShipOwnerList()
  72. }
  73. })