xunji.vue
5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<template>
<view class="home-page">
<view class="tab-bar" :style="{ paddingTop: PageHeight + 'px' }">
<view class="tab-item" :class="{ active: currentTab == 1 }" @click="handleTabClick(1)">计划</view>
<view class="tab-item" :class="{ active: currentTab == 2 }" @click="handleTabClick(2)">日历</view>
<view class="tab-item" :class="{ active: currentTab == 3 }" @click="handleTabClick(3)">动作</view>
<view class="tab-item" :class="{ active: currentTab == 4 }" @click="handleTabClick(4)">模板</view>
<view class="tab-item" :class="{ active: currentTab == 5 }" @click="handleTabClick(5)">数据</view>
<view class="menu-btn" @click="drawerShow = true">
<up-icon name="list" size="20" />
</view>
</view>
<view class="content">
<xunjiXunlianjihua v-if="currentTab === 1" />
<xunjiRili v-if="currentTab === 2" />
<xunjiDongzuo v-if="currentTab === 3" />
<xunjiMoban v-if="currentTab === 4" />
<xunjiShuju v-if="currentTab === 5" />
</view>
<up-popup :show="drawerShow" mode="right" :closeable="true" @close="drawerShow = false">
<view class="drawer-content" :style="{ paddingTop: PageHeight + 'px' }">
<view class="user-header">
<image class="avatar" :src="userInfo.avatar || defaultAvatar" mode="aspectFill" />
<view class="user-info">
<text class="nickname">{{ userInfo.nickname || '-' }}</text>
</view>
</view>
<up-cell-group :border="false">
<up-cell title="我的主页" icon="account" :isLink="true"
@click="navigateTo('/pages4/pages/xunji/xunji-wode-zhuye')" />
<up-cell title="我的模板" icon="file-text" :isLink="true"
@click="navigateTo('/pages4/pages/xunji/xunji-wode-moban')" />
<up-cell title="我的计划" icon="order" :isLink="true"
@click="navigateTo('/pages4/pages/xunji/xunji-wode-jihua')" />
<up-cell title="训记使用教程" icon="question-circle" :isLink="true" @click="navigateTo('/pages4/pages/xunji/shiyon-jiaochen')" />
</up-cell-group>
</view>
</up-popup>
<TrainingFloating />
<Tabbar />
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import useUserStore from '@/sheep/store/user';
import { getMenuButtonHeight, getTopSafeArea } from '@/utils/safeArea';
import { defaultAvatar } from '@/sheep/config/index';
import xunjiRili from '@/pages/xunji/components/xunji-rili.vue';
import xunjiDongzuo from '@/pages/xunji/components/xunji-dongzuo.vue';
import xunjiMoban from '@/pages/xunji/components/xunji-moban.vue';
import xunjiShuju from '@/pages/xunji/components/xunji-shuju.vue';
import xunjiXunlianjihua from '@/pages/xunji/components/xunji-xunlianjihua.vue';
import TrainingFloating from '@/pages/TrainingFloating.vue';
const userStore = useUserStore();
const drawerShow = ref(false);
const currentTab = ref(1);
const menuButtonHeight = ref(getMenuButtonHeight());
const topSafeArea = ref(getTopSafeArea());
const PageHeight = ref(topSafeArea.value);
// #ifdef MP-WEIXIN
PageHeight.value = menuButtonHeight.value + topSafeArea.value;
// #endif
const userInfo = computed(() => userStore.userInfo || {});
onLoad((options) => {
userStore.getInfo();
if (options && options.currentTab) {
currentTab.value = Number(options.currentTab);
}
});
onShow(() => {
const targetTab = uni.getStorageSync('xunjiTargetTab');
if (targetTab !== '' && targetTab != null) {
const tabNum = Number(targetTab);
currentTab.value = tabNum;
handleTabClick(tabNum);
uni.removeStorageSync('xunjiTargetTab');
}
});
const navigateTo = (url) => {
uni.navigateTo({ url });
};
const handleTabClick = (index) => {
currentTab.value = index;
};
defineExpose({ switchTabIndex: handleTabClick });
</script>
<style scoped lang="scss">
.home-page {
width: 100%;
height: calc(100vh - 50px);
background-color: #fff;
.content {
box-sizing: border-box;
overflow: hidden;
padding-top: 65rpx;
// #ifdef MP-WEIXIN
padding-top: 220rpx;
// #endif
}
}
.tab-bar {
display: flex;
align-items: flex-end;
justify-content: space-between;
padding: 0 20px;
background-color: #fff;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 999;
box-sizing: border-box;
.tab-item {
font-size: 16px;
color: #666;
padding: 5px 0;
padding-top: 30rpx;
&.active {
color: #333;
border-bottom: 2px solid #000;
font-weight: 500;
}
}
.menu-btn {
font-size: 20px;
color: #666;
}
}
.card-subtitle {
font-size: 24rpx;
color: #666;
margin-bottom: 10rpx;
}
.plan-btn {
width: 100%;
height: 50rpx;
background-color: #2eaa8a;
color: white;
font-size: 24rpx;
font-weight: bold;
border-radius: 25rpx;
line-height: 50rpx;
text-align: center;
margin-top: 10rpx;
}
.card-value {
font-size: 36rpx;
color: #333;
margin-bottom: 10rpx;
}
.card-desc {
font-size: 24rpx;
color: #666;
}
.drawer-content {
width: 500rpx;
background-color: #f7f7f8;
height: 100%;
padding: 0;
box-sizing: border-box;
.user-header {
display: flex;
align-items: center;
padding: 40rpx 30rpx 30rpx;
background: #fff;
margin-bottom: 20rpx;
.avatar {
width: 90rpx;
height: 90rpx;
border-radius: 50%;
background: #f0f0f0;
flex-shrink: 0;
}
.user-info {
margin-left: 20rpx;
.nickname {
font-size: 28rpx;
font-weight: 500;
color: #333;
}
}
}
}
</style>