You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
818 B
34 lines
818 B
12 months ago
|
import TabMenu from './data';
|
||
|
Component({
|
||
|
data: {
|
||
|
active: 0,
|
||
|
list: TabMenu,
|
||
|
},
|
||
|
|
||
|
methods: {
|
||
|
onChange(event) {
|
||
|
if (event.detail.value == 1) {
|
||
|
wx.setStorageSync('refreshFlag', 1);
|
||
|
}
|
||
|
|
||
|
this.setData({ active: event.detail.value });
|
||
|
wx.switchTab({
|
||
|
url: this.data.list[event.detail.value].url.startsWith('/')
|
||
|
? this.data.list[event.detail.value].url
|
||
|
: `/${this.data.list[event.detail.value].url}`,
|
||
|
});
|
||
|
},
|
||
|
|
||
|
init() {
|
||
|
const page = getCurrentPages().pop();
|
||
|
const route = page ? page.route.split('?')[0] : '';
|
||
|
const active = this.data.list.findIndex(
|
||
|
(item) =>
|
||
|
(item.url.startsWith('/') ? item.url.substr(1) : item.url) ===
|
||
|
`${route}`,
|
||
|
);
|
||
|
this.setData({ active });
|
||
|
},
|
||
|
},
|
||
|
});
|