| | |
| | | selected: 0, |
| | | list: TabMenu, |
| | | }, |
| | | // observers: { |
| | | // 'active': function (newValue) { |
| | | // console.log('active变化', newValue); |
| | | // } |
| | | // }, |
| | | methods: { |
| | | changeTab(item) { |
| | | this.setData({ |
| | |
| | | url: this.data.list[this.data.selected].url.startsWith('/') ? |
| | | this.data.list[this.data.selected].url : `/${this.data.list[this.data.selected].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 }); |
| | | // }, |
| | | } |
| | | }, |
| | | }); |
| | |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | if (typeof this.getTabBar === 'function' && this.getTabBar()) { |
| | | this.getTabBar().setData({ |
| | | active: 1 |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | |
| | | this.shoppingCartGet(); |
| | | }, |
| | | onShow() { |
| | | if (typeof this.getTabBar === 'function' && this.getTabBar()) { |
| | | this.getTabBar().setData({ |
| | | active: 3 |
| | | }) |
| | | } |
| | | this.shoppingCartGet(); |
| | | this.setData({ totalPrice: 0.00, selectedCount: 0, checkAll: false, }) |
| | | |
| | | }, |
| | | onDelete(e) { |
| | | const item = e.currentTarget.dataset.item; |
| | |
| | | |
| | | }, |
| | | onShow() { |
| | | |
| | | if (typeof this.getTabBar === 'function' && this.getTabBar()) { |
| | | this.getTabBar().setData({ |
| | | active: 4 |
| | | }) |
| | | } |
| | | }, |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | if (typeof this.getTabBar === 'function' && this.getTabBar()) { |
| | | this.getTabBar().setData({ |
| | | active: 2 |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | /** |