Files
JiaZhiQianYan/unpackage/dist/build/mp-weixin/custom-tab-bar/index.js

88 lines
2.2 KiB
JavaScript

// components/custom-tab-bar/index.js
const app = getApp();
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
color: "#858C9A",
selected:0,
selectedColor: "#F3C368",
list: [
{
"pagePath": "/pages/index/index",
"text": "新闻动量",
"iconPath": "/static/icon/tabbar/home.png",
"selectedIconPath": "/static/icon/tabbar/home_s.png"
},
{
"pagePath": "/pages/concept/concept",
"text": "概念中心",
"iconPath": "/static/icon/tabbar/concept.png",
"selectedIconPath": "/static/icon/tabbar/concept_s.png"
},
{
"pagePath": "/pages/geGuCenter/geGuCenter",
"text": "个股中心",
"iconPath": "/static/icon/tabbar/gegu.png",
"selectedIconPath": "/static/icon/tabbar/gegu_s.png"
},
{
"pagePath": "/pages/ztfx/ztfx",
"text": "涨停分析",
"iconPath": "/static/icon/tabbar/zt.png",
"selectedIconPath": "/static/icon/tabbar/zt_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==3)
{
//如果是购物车和我的,需要登录
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
})
}
}
})