index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // pages/index/index.js
  2. import {
  3. getApi,
  4. postApi
  5. } from "../../apis/api"
  6. import cloudApi from "../../apis/cloudApi"
  7. Page({
  8. data: {
  9. indexInfo: {},
  10. },
  11. async getIndexInfo() {
  12. if (wx.getStorageSync('isClient')) return
  13. let res = await postApi('/voyage/index', {
  14. loginAccountId: wx.getStorageSync('loginAccountId'),
  15. isClient: wx.getStorageSync('isClient'),
  16. })
  17. this.setData({
  18. indexInfo: res.data.result
  19. })
  20. },
  21. forbidTouchMove() {
  22. },
  23. onLoad() {
  24. wx.removeStorageSync('voyageDetailId')
  25. },
  26. onShow() {
  27. if (wx.getStorageSync('isClient')) return
  28. if (wx.getStorageSync('voyageDetailId')) return
  29. wx.removeStorageSync('voyageDetailId')
  30. let cargoOwnerId = wx.getStorageSync('cargoOwnerId')
  31. if (cargoOwnerId) {
  32. this.getIndexInfo()
  33. this.setData({
  34. cargoOwnerId
  35. })
  36. }
  37. let rolePermission = wx.getStorageSync('rolePermission')
  38. const child = this.selectComponent('.voyages');
  39. if (rolePermission.indexOf('VOYAGELIST') == -1) {
  40. this.setData({
  41. indexInfo: {}
  42. })
  43. child.clearList()
  44. wx.showToast({
  45. icon: "none",
  46. title: '暂无权限,请联系管理员',
  47. })
  48. return
  49. } else {
  50. child.getVoyageList()
  51. }
  52. }
  53. })