1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- const app = getApp()
- Component({
- data: {
- selected: 0,
- color: "#7A7E83",
- selectedColor: "#45A6B5",
- list: [{
- pagePath: "/pages/index/index",
- iconPath: "/imaes/home_nor@2x.png",
- selectedIconPath: "/imaes/home_sel@2x.png",
- text: "首页"
- }, {
- pagePath: "/pages/report/report",
- iconPath: "/imaes/baogao_nor@2x.png",
- selectedIconPath: "/imaes/baogao_sel@2x.png",
- text: "报告"
- },{
- pagePath: "/pages/my/my",
- iconPath: "/imaes/me_nor@2x.png",
- selectedIconPath: "/imaes/me_sel@2x.png",
- text: "我的"
- }]
- },
- attached() {
- },
- ready () {
- const selectedInex = wx.getStorageSync('selectedInex')
- this.setData({
- selected: selectedInex
- })
- },
- methods: {
- switchTab(e) {
- const data = e.currentTarget.dataset
- const url = data.path
- if (data.index == 1 || data.index == 2) {
- const isLogin = wx.getStorageSync('login')
- if (isLogin != true) {
- wx.showToast({
- title: '请先授权登录',
- icon: 'error'
- })
- return false
- } else {
- app.globalData.selectedInex = data.index
- wx.setStorageSync('selectedInex', data.index)
- wx.switchTab({url})
- }
- } else {
- app.globalData.selectedInex = data.index
- wx.setStorageSync('selectedInex', data.index)
- wx.switchTab({url})
- }
- }
- }
- })
|