shipOwnerList.js 1.4 KB

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