You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bocai_supplyChain/custom-tab-bar/index.js

116 lines
2.8 KiB
JavaScript

const app = getApp();
Component({
data: {
isShow: false,
toTop: false,
selected: 0,
color: "#666",
selectedColor: "#1890ff",
list: [
{
iconPath: "../assets/images/tabbar/home_active.svg",
selectedIconPath: "../assets/images/tabbar/home.svg",
pagePath: "/pages/firstBill/index",
text: "首页",
index: 0,
},
{
"iconPath": "../assets/images/tabbar/order_active.svg",
"selectedIconPath": "../assets/images/tabbar/order.svg",
"pagePath": "/pages/myBill/index",
"text": "工单",
index: 1,
},
{
"iconPath": "../assets/images/tabbar/message_active.svg",
"selectedIconPath": "../assets/images/tabbar/message.svg",
"pagePath": "/pages/message/index",
"text": "消息",
index: 2,
},
{
iconPath: "../assets/images/tabbar/unit_active.svg",
selectedIconPath: "../assets/images/tabbar/unit.svg",
pagePath: "/pages/workBench/index",
text: "工作台",
index: 3,
},
{
iconPath: "../assets/images/tabbar/user_active.svg",
selectedIconPath: "../assets/images/tabbar/user.svg",
pagePath: "/pages/mine/index",
text: "我的",
index: 4,
},
],
},
lifetimes: {
show: function () {
// 页面被展示
console.log("tabbar show");
},
attached: function () {
// 在组件实例进入页面节点树时执行
console.log("tabbar attached");
},
detached: function () {
// 在组件实例被从页面节点树移除时执行
},
},
methods: {
switchTab (e) {
console.log('e',e)
const data = e.currentTarget.dataset;
const url = data.path;
wx.vibrateShort({
type: "heavy",
success: function (e) {
console.log(e);
},
});
if (data.index == 0 && this.data.selected == 0) {
if (this.data.toTop) {
app.globalData.toTop = 1;
} else {
app.globalData.refresh = 1
}
}
// if (!app.globalData.isLogin) {
// if (data.index == 1) {
// wx.navigateTo({
// url: "/pages/login/index",
// });
// return;
// }
// }
// else {
// if (data.index == 1) {
// if (app.globalData.loginUserInfo.agencyStatus != 1) {
// wx.navigateTo({
// url: "/pages/tobeAgency/index",
// });
// } else {
// wx.navigateTo({
// url,
// });
// // wx.redirectTo({});
// }
// return;
// }
// }
// this.setData({
// selected: data.index,
// });
wx.switchTab({ url });
},
touchMove () {
return false
}
},
});