hookehuyr

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

在Welcome页面添加根据用户年龄判断是否显示创建家庭按钮的功能
Dashboard页面添加未加入家庭时的重定向逻辑
调整app.config.js中的页面顺序
/*
* @Date: 2025-06-28 10:33:00
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-28 21:48:50
* @LastEditTime: 2025-08-28 22:28:53
* @FilePath: /lls_program/src/app.config.js
* @Description: 文件描述
*/
......@@ -9,10 +9,10 @@ export default {
pages: [
// 'pages/index/index',
// 'pages/auth/index',
'pages/Dashboard/index',
'pages/Welcome/index',
'pages/CreateFamily/index',
'pages/JoinFamily/index',
'pages/Dashboard/index',
'pages/Activities/index',
'pages/RewardCategories/index',
'pages/Rewards/index',
......
......@@ -88,12 +88,11 @@
</template>
<script setup>
import { ref, computed } from 'vue';
import { ref, computed, onMounted } from 'vue';
import Taro from '@tarojs/taro';
import { Setting, Photograph, Right } from '@nutui/icons-vue-taro';
import BottomNav from '../../components/BottomNav.vue';
import PointsCollector from '@/components/PointsCollector.vue'
import BASE_URL from '@/utils/config';
const todaySteps = ref(2000);
const pointsCollectorRef = ref(null)
......@@ -155,61 +154,18 @@ const openAlbumList = () => {
};
/**
* 显示提示信息
*/
const showToast = (message, type = 'success') => {
const icon = type === 'error' ? 'error' : 'success';
Taro.showToast({
title: message,
icon: icon,
duration: 2000
});
};
/**
* 上传文件到服务器
*/
const uploadFile = (filePath) => {
// 显示上传中提示
Taro.showLoading({
title: '上传中',
mask: true
});
wx.uploadFile({
url: BASE_URL + '/admin/?m=srv&a=upload',
filePath,
name: 'file',
header: {
'content-type': 'multipart/form-data',
},
success: function (res) {
let upload_data = JSON.parse(res.data);
Taro.hideLoading({
success: () => {
if (res.statusCode === 200) {
console.log('上传成功', upload_data.data.src);
showToast('上传成功', 'success');
} else {
showToast('服务器错误,稍后重试!', 'error');
}
},
});
},
fail: function (res) {
Taro.hideLoading({
success: () => {
showToast('上传失败,稍后重试!', 'error');
}
});
}
});
};
/**
* 打开拍照上传页面
*/
const openCamera = () => {
Taro.navigateTo({ url: '/pages/UploadMedia/index' });
}
onMounted(() => {
// TODO: 等待真实接口获取用户是否加入家庭
const hasJoinedFamily = false; // Change to true to simulate having a family
if (!hasJoinedFamily) {
Taro.redirectTo({ url: '/pages/Welcome/index' });
}
})
</script>
......
<!--
* @Date: 2025-08-27 17:43:45
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-28 22:08:17
* @LastEditTime: 2025-08-28 22:47:16
* @FilePath: /lls_program/src/pages/Welcome/index.vue
* @Description: 文件描述
-->
......@@ -61,7 +61,7 @@
</view>
<!-- Action Buttons -->
<view class="space-y-4 mt-auto">
<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">
<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">
创建家庭
</view>
<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 @@
</template>
<script setup>
import { ref, computed } from 'vue';
import Taro from '@tarojs/taro';
import BottomNav from '../../components/BottomNav.vue'; // 假设BottomNav组件已转换
import welcomeHomeImg from '../../assets/images/welcome_home.png';
// TODO: 等待真实接口获取用户年龄
const userAge = ref(65); // or 55 to test the other case
const canCreateFamily = computed(() => userAge.value >= 60);
const navigateTo = (url) => {
Taro.navigateTo({ url });
};
......@@ -104,9 +109,3 @@ const handleNavigate = (url) => {
}
};
</script>
<style lang="less">
.font-sans {
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";
}
</style>
......