|
- const app = getApp();
- import {getOpenidData} from '../utils/getUserInfo.js'
- Component({
- data: {
- selected: 0,
- color: "#939393",
- selectedColor: "#2a82e4",
- list: [
- {
- pagePath: "/pages/FirstPage/index",
- iconPath: '../assets/tabBar/home.png',
- selectedIconPath:'../assets/tabBar/home_selected.png',
- text: "首页",
- auth: false,
- isSpecial: false
- },
- {
- pagePath: "/pages/all/index",
- iconPath: '../assets/tabBar/protect.png',
- selectedIconPath:'../assets/tabBar/protect_h.png',
- text: "全民护河",
- auth: false,
- isSpecial: false
- },
- {
- pagePath: "/pages/mine/index",
- iconPath: '../assets/tabBar/mine.png',
- selectedIconPath:'../assets/tabBar/mine_h.png',
- text: "我的",
- auth: true,
- isSpecial: false
- }
- ],
- isIphoneX: app.globalData.isIphoneX,
- path: ''
- },
- methods: {
- switchTab(e) {
- const dataset = e.currentTarget.dataset
- const path = dataset.path
- const index = dataset.index
- const auth = dataset.auth
- const openid = wx.getStorageSync('openid')
- if(auth) {
- if(openid) {
- wx.switchTab({
- url: path
- })
- } else {
- getOpenidData().then(res=> {
- wx.switchTab({
- url: path
- })
- })
- }
-
- } else {
- //正常的tabbar切换界面
- wx.switchTab({
- url: path
- })
- }
- }
- }
- })
|