码农搬砖工 9018a4f868 xxx
2025-04-23 18:23:41 +08:00

110 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Component({
options: {
styleIsolation: 'shared',
},
properties: {
navType: {
type: String,
value: 'title',
},
titleText: String,
},
data: {
visible: false,
sidebar: [
{
title: '首页',
url: 'pages/home/index',
isSidebar: true,
},
{
title: '搜索页',
url: 'pages/search/index',
isSidebar: false,
},
{
title: '发布页',
url: 'pages/release/index',
isSidebar: false,
},
{
title: '消息列表页',
url: 'pages/message/index',
isSidebar: true,
},
{
title: '对话页',
url: 'pages/chat/index',
isSidebar: false,
},
{
title: '个人中心页',
url: 'pages/my/index',
isSidebar: true,
},
{
title: '个人信息表单页',
url: 'pages/my/info-edit/index',
isSidebar: false,
},
{
title: '设置页',
url: 'pages/setting/index',
isSidebar: false,
},
{
title: '数据图表页',
url: 'pages/dataCenter/index',
isSidebar: false,
},
{
title: '登录注册页',
url: 'pages/login/login',
isSidebar: false,
},
],
statusHeight: 0,
},
lifetimes: {
ready() {
const statusHeight = wx.getWindowInfo().statusBarHeight;
this.setData({ statusHeight });
},
},
methods: {
openDrawer() {
this.setData({
visible: true,
});
},
itemClick(e) {
const that = this;
const { isSidebar, url } = e.detail.item;
if (isSidebar) {
wx.switchTab({
url: `/${url}`,
}).then(() => {
// 防止点回tab时sidebar依旧是展开模式
that.setData({
visible: false,
});
});
} else {
wx.navigateTo({
url: `/${url}`,
}).then(() => {
that.setData({
visible: false,
});
});
}
},
searchTurn() {
wx.navigateTo({
url: `/pages/search/index`,
});
},
},
});