index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. let res = await postApi('/voyage/index', {
  13. cargoOwnerId: wx.getStorageSync('cargoOwnerId')
  14. })
  15. this.setData({
  16. indexInfo: res.data.result
  17. })
  18. },
  19. forbidTouchMove() {
  20. },
  21. onLoad() {
  22. wx.removeStorageSync('voyageDetailId')
  23. },
  24. onShow() {
  25. if (wx.getStorageSync('voyageDetailId')) return
  26. wx.removeStorageSync('voyageDetailId')
  27. let cargoOwnerId = wx.getStorageSync('cargoOwnerId')
  28. if (cargoOwnerId) {
  29. this.getIndexInfo()
  30. this.setData({
  31. cargoOwnerId
  32. })
  33. }
  34. let rolePermission = wx.getStorageSync('rolePermission')
  35. if (rolePermission.indexOf('VOYAGELIST') == -1) {
  36. wx.showToast({
  37. icon: "none",
  38. title: '暂无权限,请联系管理员',
  39. })
  40. return
  41. }
  42. const child = this.selectComponent('.voyages');
  43. child.getVoyageList()
  44. }
  45. })