shipOwnerList.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. if(res.data.result.length==0) {
  29. wx.showToast({
  30. title: '暂无数据',
  31. icon:"error"
  32. })
  33. return
  34. }
  35. let shipOwnerList = res.data.result
  36. shipOwnerList[0].letter = "#"
  37. shipOwnerList.push(shipOwnerList.shift())
  38. this.setData({
  39. shipOwnerList
  40. })
  41. } else {
  42. this.setData({
  43. shipOwnerList: []
  44. })
  45. }
  46. },
  47. call(e) {
  48. wx.makePhoneCall({
  49. phoneNumber: e.currentTarget.dataset.phone
  50. })
  51. },
  52. addShipOwner() {
  53. if (!wx.getStorageSync('loginAccountId')) {
  54. wx.showToast({
  55. title: '尚未登录',
  56. icon: "error"
  57. })
  58. return
  59. }
  60. wx.navigateTo({
  61. url: '../addShipOnwer/addShipOnwer',
  62. })
  63. },
  64. tapLetter(e) {
  65. this.setData({
  66. currentLetter: e.currentTarget.dataset.letter
  67. })
  68. },
  69. onLoad() {
  70. },
  71. onPullDownRefresh() {
  72. this.setData({
  73. term: ''
  74. })
  75. this.getShipOwnerList(1)
  76. },
  77. onShow() {
  78. this.getShipOwnerList()
  79. }
  80. })