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

98 lines
2.2 KiB
JavaScript

const app = getApp();
Component({
data: {
isShow: false,
toTop: false,
selected: 0,
color: "#444",
selectedColor: "#1890ff",
list: [
{
1 year ago
iconPath: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/IOS/home.png",
selectedIconPath: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/IOS/home1.png",
pagePath: "/pages/firstBill/index",
text: "首页",
index: 0,
},
{
1 year ago
iconPath: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/IOS/ksbm.svg",
selectedIconPath: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/IOS/ksbm.svg",
pagePath: "/pages/newEnroll/enroll/index",
// text: "消息",
index: 1,
},
{
1 year ago
iconPath: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/IOS/wd.png",
selectedIconPath: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/IOS/wd1.png",
pagePath: "/pages/mine/index",
text: "我的",
index: 2,
},
],
},
lifetimes: {
show: function () {
// 页面被展示
console.log("tabbar show");
},
attached: function () {
// 在组件实例进入页面节点树时执行
console.log("tabbar attached");
},
detached: function () {
// 在组件实例被从页面节点树移除时执行
},
},
methods: {
switchTab(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
}
},
});