76 lines
1.8 KiB
JavaScript
76 lines
1.8 KiB
JavaScript
// components/custom-tab-bar/index.js
|
|
const app = getApp();
|
|
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
color: "#858C9A",
|
|
selected:0,
|
|
selectedColor: "#F97316",
|
|
list: [
|
|
{
|
|
"pagePath": "/pages/index/index",
|
|
"text": "新闻动量",
|
|
"iconPath": "/static/icon/tabbar/home.png",
|
|
"selectedIconPath": "/static/icon/tabbar/home_s.png"
|
|
},
|
|
{
|
|
"pagePath": "/pages/invest/invest",
|
|
"text": "投资日历",
|
|
"iconPath": "/static/icon/tabbar/invest.png",
|
|
"selectedIconPath": "/static/icon/tabbar/invest_s.png"
|
|
},
|
|
{
|
|
"pagePath": "/pages/mine/mine",
|
|
"text": "个人中心",
|
|
"iconPath": "/static/icon/tabbar/mine.png",
|
|
"selectedIconPath": "/static/icon/tabbar/mine_s.png"
|
|
}
|
|
]
|
|
},
|
|
attached() {
|
|
this.setData({
|
|
selected:app.globalData.tabIndex
|
|
})
|
|
},
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
switchTab(e) {
|
|
const data = e.currentTarget.dataset;
|
|
const url = data.path;
|
|
const index = data.index
|
|
// if(index==2||index==4)
|
|
// {
|
|
// //如果是购物车和我的,需要登录
|
|
// let token = wx.getStorageSync('token')
|
|
// if (!token) {
|
|
// wx.navigateTo({
|
|
// url:'/pages/login/login'
|
|
// })
|
|
// return
|
|
// }
|
|
// }
|
|
app.globalData.tabIndex = index
|
|
wx.switchTab({url})
|
|
},
|
|
navigateTo(e) {
|
|
const data = e.currentTarget.dataset;
|
|
const url = data.path;
|
|
wx.navigateTo({
|
|
url: url
|
|
})
|
|
}
|
|
}
|
|
})
|