0.0.0
This commit is contained in:
45
miniprogram/custom-tab-bar/index.js
Normal file
45
miniprogram/custom-tab-bar/index.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// custom-tab-bar — 三 Tab + 中央状态化「遛狗」FAB(docs/04 §2)
|
||||
const store = require('../utils/store.js');
|
||||
|
||||
Component({
|
||||
data: {
|
||||
selected: 1, // 0=记录 1=我的
|
||||
// walkState: idle | walking | paused —— 决定中央 FAB 颜色与文案
|
||||
walkState: 'idle',
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.syncWalkState();
|
||||
},
|
||||
},
|
||||
|
||||
pageLifetimes: {
|
||||
show() {
|
||||
this.syncWalkState();
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
syncWalkState() {
|
||||
const session = store.getWalkSession();
|
||||
this.setData({ walkState: session ? session.status : 'idle' });
|
||||
},
|
||||
|
||||
switchTab(e) {
|
||||
const { path, index } = e.currentTarget.dataset;
|
||||
this.setData({ selected: index });
|
||||
wx.switchTab({ url: path });
|
||||
},
|
||||
|
||||
// 中央「遛狗」按钮:进行中→回遛狗页;空闲→开始(单狗直进/多狗弹层)
|
||||
onCenterTap() {
|
||||
if (this.data.walkState !== 'idle') {
|
||||
wx.navigateTo({ url: '/pages/walking/walking' });
|
||||
return;
|
||||
}
|
||||
// TODO 阶段2:单狗直接进 walking;多狗触发 multi-dog-sheet
|
||||
wx.navigateTo({ url: '/pages/walking/walking' });
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user