shipOwnerList.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. onLoad() {
  74. },
  75. onPullDownRefresh() {
  76. this.setData({
  77. term: ''
  78. })
  79. this.getShipOwnerList(1)
  80. },
  81. onShow() {
  82. this.getShipOwnerList()
  83. }
  84. })