index.js 998 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. },
  12. async getIndexInfo() {
  13. let res = await postApi('/index', {
  14. loginAccountId: wx.getStorageSync('loginAccountId'),
  15. })
  16. if (res.data.status == 0) {
  17. this.setData({
  18. indexInfo: res.data.result
  19. })
  20. } else if (res.data.status == 1) {
  21. wx.showToast({
  22. title: '暂无数据',
  23. icon: "error"
  24. })
  25. } else if (res.data.status == 2) {
  26. wx.showToast({
  27. title: '尚未登录',
  28. icon: "error"
  29. })
  30. }
  31. },
  32. forbidTouchMove() {
  33. },
  34. onLoad() {},
  35. onShow() {
  36. this.getIndexInfo()
  37. },
  38. goTo(e) {
  39. let {
  40. url,
  41. maintab
  42. } = e.currentTarget.dataset
  43. app.globalData.maintab = maintab
  44. if (maintab) {
  45. wx.switchTab({
  46. url
  47. })
  48. } else {
  49. wx.navigateTo({
  50. url
  51. })
  52. }
  53. },
  54. })