|
- const app = getApp();
- import {getUserInfo} from '../utils/getUserInfo.js'
- Component({
- data: {
- selected: 0,
- color: "#939393",
- selectedColor: "#477DF3",
- list: [
- {
- pagePath: "/pages/home/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
- },
- 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 {
- getUserInfo().then(res=> {
- wx.switchTab({
- url: path
- })
- })
- }
-
- } else {
- //正常的tabbar切换界面
- wx.switchTab({
- url: path
- })
- }
- }
- }
- })
|