拓恒河湖长制全民护河平台WEB端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

65 行
1.6KB

  1. const app = getApp();
  2. import {getOpenidData} from '../utils/getUserInfo.js'
  3. Component({
  4. data: {
  5. selected: 0,
  6. color: "#939393",
  7. selectedColor: "#2a82e4",
  8. list: [
  9. {
  10. pagePath: "/pages/FirstPage/index",
  11. iconPath: '../assets/tabBar/home.png',
  12. selectedIconPath:'../assets/tabBar/home_selected.png',
  13. text: "首页",
  14. auth: false,
  15. isSpecial: false
  16. },
  17. {
  18. pagePath: "/pages/all/index",
  19. iconPath: '../assets/tabBar/protect.png',
  20. selectedIconPath:'../assets/tabBar/protect_h.png',
  21. text: "全民护河",
  22. auth: false,
  23. isSpecial: false
  24. },
  25. {
  26. pagePath: "/pages/mine/index",
  27. iconPath: '../assets/tabBar/mine.png',
  28. selectedIconPath:'../assets/tabBar/mine_h.png',
  29. text: "我的",
  30. auth: true,
  31. isSpecial: false
  32. }
  33. ],
  34. isIphoneX: app.globalData.isIphoneX,
  35. path: ''
  36. },
  37. methods: {
  38. switchTab(e) {
  39. const dataset = e.currentTarget.dataset
  40. const path = dataset.path
  41. const index = dataset.index
  42. const auth = dataset.auth
  43. const openid = wx.getStorageSync('openid')
  44. if(auth) {
  45. if(openid) {
  46. wx.switchTab({
  47. url: path
  48. })
  49. } else {
  50. getOpenidData().then(res=> {
  51. wx.switchTab({
  52. url: path
  53. })
  54. })
  55. }
  56. } else {
  57. //正常的tabbar切换界面
  58. wx.switchTab({
  59. url: path
  60. })
  61. }
  62. }
  63. }
  64. })