123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- const app = getApp()
- import { menu } from "../../utils/site";
- Component({
- /**
- * 组件的属性列表
- */
- options: { multipleSlots: true },
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- // 平台信息
- basicInfo: {},
- list: [],
- active: 0
- },
- pageLifetimes: {
- show: function () {
- const that = this;
- that.search()
- },
- hide: function () { },
- resize: function () { },
- },
- /**
- * 组件的方法列表
- */
- methods: {
- // 查询基本信息
- async search() {
- const that = this;
- // 获取当前路由地址
- let pages = getCurrentPages();
- let currentPage = pages[pages.length - 1];
- let list = menu.sort((a, b) => {
- return a.sort - b.sort
- });
- that.setData({ list })
- let routeInfo = list.find((i) => i.route == currentPage.route);
- if (routeInfo) {
- let index = list.findIndex((i) => i.route == currentPage.route);
- that.setData({ active: index })
- }
- },
- toPath(index) {
- const that = this;
- let active = index.currentTarget.dataset.index;
- that.setData({ active });
- let route = that.data.list[active];
- if (route) that.triggerEvent('toPath', route)
- }
- }
- })
|