index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // pages/index/index.js
  2. import {
  3. getApi,
  4. postApi
  5. } from "../../apis/api"
  6. import cloudApi from "../../apis/cloudApi"
  7. const app = getApp()
  8. Page({
  9. data: {
  10. indexInfo: {},
  11. loginName: '',
  12. logoUrl: ""
  13. },
  14. async getIndexInfo() {
  15. let res = await postApi('/index', {
  16. loginAccountId: wx.getStorageSync('loginAccountId'),
  17. })
  18. if (res.data.status == 0) {
  19. this.setData({
  20. indexInfo: res.data.result
  21. })
  22. } else if (res.data.status == 1) {
  23. wx.showToast({
  24. title: '暂无数据',
  25. icon: "error"
  26. })
  27. } else if (res.data.status == 2) {
  28. wx.showToast({
  29. title: '尚未登录',
  30. icon: "error"
  31. })
  32. }
  33. },
  34. forbidTouchMove() {
  35. },
  36. onLoad() {},
  37. onShow() {
  38. this.getIndexInfo()
  39. this.setData({
  40. loginName: wx.getStorageSync('loginName'),
  41. logo: wx.getStorageSync('logo')
  42. })
  43. },
  44. goTo(e) {
  45. if (!wx.getStorageSync('loginAccountId')) {
  46. wx.showToast({
  47. title: '请登录!',
  48. icon: "error"
  49. })
  50. return
  51. }
  52. let {
  53. url,
  54. maintab
  55. } = e.currentTarget.dataset
  56. app.globalData.maintab = maintab
  57. if (maintab) {
  58. wx.switchTab({
  59. url
  60. })
  61. } else {
  62. if (url == '/pages/voyageManage/createVoyage/createVoyage') {
  63. wx.redirectTo({
  64. url
  65. })
  66. } else {
  67. wx.navigateTo({
  68. url
  69. })
  70. }
  71. }
  72. },
  73. })