hookehuyr

feat: 添加家庭创建权限检查并调整页面顺序

在Welcome页面添加根据用户年龄判断是否显示创建家庭按钮的功能
Dashboard页面添加未加入家庭时的重定向逻辑
调整app.config.js中的页面顺序
1 /* 1 /*
2 * @Date: 2025-06-28 10:33:00 2 * @Date: 2025-06-28 10:33:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-08-28 21:48:50 4 + * @LastEditTime: 2025-08-28 22:28:53
5 * @FilePath: /lls_program/src/app.config.js 5 * @FilePath: /lls_program/src/app.config.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -9,10 +9,10 @@ export default { ...@@ -9,10 +9,10 @@ export default {
9 pages: [ 9 pages: [
10 // 'pages/index/index', 10 // 'pages/index/index',
11 // 'pages/auth/index', 11 // 'pages/auth/index',
12 + 'pages/Dashboard/index',
12 'pages/Welcome/index', 13 'pages/Welcome/index',
13 'pages/CreateFamily/index', 14 'pages/CreateFamily/index',
14 'pages/JoinFamily/index', 15 'pages/JoinFamily/index',
15 - 'pages/Dashboard/index',
16 'pages/Activities/index', 16 'pages/Activities/index',
17 'pages/RewardCategories/index', 17 'pages/RewardCategories/index',
18 'pages/Rewards/index', 18 'pages/Rewards/index',
......
...@@ -88,12 +88,11 @@ ...@@ -88,12 +88,11 @@
88 </template> 88 </template>
89 89
90 <script setup> 90 <script setup>
91 -import { ref, computed } from 'vue'; 91 +import { ref, computed, onMounted } from 'vue';
92 import Taro from '@tarojs/taro'; 92 import Taro from '@tarojs/taro';
93 import { Setting, Photograph, Right } from '@nutui/icons-vue-taro'; 93 import { Setting, Photograph, Right } from '@nutui/icons-vue-taro';
94 import BottomNav from '../../components/BottomNav.vue'; 94 import BottomNav from '../../components/BottomNav.vue';
95 import PointsCollector from '@/components/PointsCollector.vue' 95 import PointsCollector from '@/components/PointsCollector.vue'
96 -import BASE_URL from '@/utils/config';
97 96
98 const todaySteps = ref(2000); 97 const todaySteps = ref(2000);
99 const pointsCollectorRef = ref(null) 98 const pointsCollectorRef = ref(null)
...@@ -155,61 +154,18 @@ const openAlbumList = () => { ...@@ -155,61 +154,18 @@ const openAlbumList = () => {
155 }; 154 };
156 155
157 /** 156 /**
158 - * 显示提示信息
159 - */
160 -const showToast = (message, type = 'success') => {
161 - const icon = type === 'error' ? 'error' : 'success';
162 - Taro.showToast({
163 - title: message,
164 - icon: icon,
165 - duration: 2000
166 - });
167 -};
168 -
169 -/**
170 - * 上传文件到服务器
171 - */
172 -const uploadFile = (filePath) => {
173 - // 显示上传中提示
174 - Taro.showLoading({
175 - title: '上传中',
176 - mask: true
177 - });
178 -
179 - wx.uploadFile({
180 - url: BASE_URL + '/admin/?m=srv&a=upload',
181 - filePath,
182 - name: 'file',
183 - header: {
184 - 'content-type': 'multipart/form-data',
185 - },
186 - success: function (res) {
187 - let upload_data = JSON.parse(res.data);
188 - Taro.hideLoading({
189 - success: () => {
190 - if (res.statusCode === 200) {
191 - console.log('上传成功', upload_data.data.src);
192 - showToast('上传成功', 'success');
193 - } else {
194 - showToast('服务器错误,稍后重试!', 'error');
195 - }
196 - },
197 - });
198 - },
199 - fail: function (res) {
200 - Taro.hideLoading({
201 - success: () => {
202 - showToast('上传失败,稍后重试!', 'error');
203 - }
204 - });
205 - }
206 - });
207 -};
208 -
209 -/**
210 * 打开拍照上传页面 157 * 打开拍照上传页面
211 */ 158 */
212 const openCamera = () => { 159 const openCamera = () => {
213 Taro.navigateTo({ url: '/pages/UploadMedia/index' }); 160 Taro.navigateTo({ url: '/pages/UploadMedia/index' });
214 } 161 }
162 +
163 +onMounted(() => {
164 + // TODO: 等待真实接口获取用户是否加入家庭
165 + const hasJoinedFamily = false; // Change to true to simulate having a family
166 +
167 + if (!hasJoinedFamily) {
168 + Taro.redirectTo({ url: '/pages/Welcome/index' });
169 + }
170 +})
215 </script> 171 </script>
......
1 <!-- 1 <!--
2 * @Date: 2025-08-27 17:43:45 2 * @Date: 2025-08-27 17:43:45
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-08-28 22:08:17 4 + * @LastEditTime: 2025-08-28 22:47:16
5 * @FilePath: /lls_program/src/pages/Welcome/index.vue 5 * @FilePath: /lls_program/src/pages/Welcome/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
61 </view> 61 </view>
62 <!-- Action Buttons --> 62 <!-- Action Buttons -->
63 <view class="space-y-4 mt-auto"> 63 <view class="space-y-4 mt-auto">
64 - <view @tap="handleNavigate('/pages/CreateFamily/index')" class="w-full py-3.5 bg-blue-500 text-white text-lg font-medium rounded-full text-center"> 64 + <view v-if="canCreateFamily" @tap="handleNavigate('/pages/CreateFamily/index')" class="w-full py-3.5 bg-blue-500 text-white text-lg font-medium rounded-full text-center">
65 创建家庭 65 创建家庭
66 </view> 66 </view>
67 <view @tap="handleNavigate('/pages/JoinFamily/index')" class="w-full py-3.5 bg-white text-gray-800 text-lg font-medium rounded-full border border-gray-300 text-center" style="margin-bottom: 1rem;"> 67 <view @tap="handleNavigate('/pages/JoinFamily/index')" class="w-full py-3.5 bg-white text-gray-800 text-lg font-medium rounded-full border border-gray-300 text-center" style="margin-bottom: 1rem;">
...@@ -75,10 +75,15 @@ ...@@ -75,10 +75,15 @@
75 </template> 75 </template>
76 76
77 <script setup> 77 <script setup>
78 +import { ref, computed } from 'vue';
78 import Taro from '@tarojs/taro'; 79 import Taro from '@tarojs/taro';
79 import BottomNav from '../../components/BottomNav.vue'; // 假设BottomNav组件已转换 80 import BottomNav from '../../components/BottomNav.vue'; // 假设BottomNav组件已转换
80 import welcomeHomeImg from '../../assets/images/welcome_home.png'; 81 import welcomeHomeImg from '../../assets/images/welcome_home.png';
81 82
83 +// TODO: 等待真实接口获取用户年龄
84 +const userAge = ref(65); // or 55 to test the other case
85 +const canCreateFamily = computed(() => userAge.value >= 60);
86 +
82 const navigateTo = (url) => { 87 const navigateTo = (url) => {
83 Taro.navigateTo({ url }); 88 Taro.navigateTo({ url });
84 }; 89 };
...@@ -104,9 +109,3 @@ const handleNavigate = (url) => { ...@@ -104,9 +109,3 @@ const handleNavigate = (url) => {
104 } 109 }
105 }; 110 };
106 </script> 111 </script>
107 -
108 -<style lang="less">
109 -.font-sans {
110 - font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
111 -}
112 -</style>
......