ruoyi-geek-App/pages_caltools/pages/index.vue

163 lines
3.4 KiB
Vue
Raw Normal View History

2025-11-24 14:57:53 +00:00
<template>
<view class="container">
<!-- Swiper 组件用于在不同计算分组间滑动 -->
2025-11-25 02:51:26 +00:00
<swiper class="calc-swiper" :current="currentTab" @change="handleSwiperChange" :indicator-dots="true"
2025-11-24 14:57:53 +00:00
indicator-color="#BBBBBB" indicator-active-color="#007AFF">
<!-- 遍历分组数据动态生成 swiper-item -->
<swiper-item v-for="(group, groupIndex) in calcGroups" :key="groupIndex">
2025-11-25 02:51:26 +00:00
<scroll-view scroll-y="true" class="scroll-content">
<view class="page-header">{{group.name}}</view>
<uni-grid :column="3" :show-border="true" :border="true" border-color="#EEEEEE" class="custom-grid">
<!-- 遍历每个分组下的功能项动态生成宫格 -->
<uni-grid-item v-for="(item, itemIndex) in group.items" :key="itemIndex"
@click="navigateToCalc(item)" class="grid-item">
<view class="grid-content">
<view class="grid-icon">
<uni-icons :type="item.icon" size="32" :color="group.color"></uni-icons>
</view>
<text class="grid-text">{{ item.name }}</text>
</view>
</uni-grid-item>
</uni-grid>
</scroll-view>
2025-11-24 14:57:53 +00:00
</swiper-item>
</swiper>
</view>
</template>
<script setup>
import {
ref
} from 'vue';
// 响应式数据:当前激活的 Swiper 标签索引
const currentTab = ref(0);
// 核心数据:计算分组和功能项定义
const calcGroups = [{
name: '流量计算',
color: '#007AFF',
items: [{
name: '差压式流量计算',
2025-11-25 02:51:26 +00:00
icon: 'smallcircle',
dMeterType: 0
2025-11-24 14:57:53 +00:00
},
{
name: '速度式流量计算',
2025-11-25 02:51:26 +00:00
icon: 'paperplane',
dMeterType: 1
2025-11-24 14:57:53 +00:00
},
]
},
{
name: '参数计算',
color: '#5AC8FA',
items: [{
name: '压缩因子',
2025-11-25 02:51:26 +00:00
icon: 'pyq',
dMeterType: 4
2025-11-24 14:57:53 +00:00
},
{
name: '声速计算',
2025-11-25 02:51:26 +00:00
icon: 'sound',
dMeterType: 5
2025-11-24 14:57:53 +00:00
},
{
name: '发热量',
2025-11-25 02:51:26 +00:00
icon: 'fire',
dMeterType: 6
2025-11-24 14:57:53 +00:00
},
{
name: '其他参数',
2025-11-25 02:51:26 +00:00
icon: 'more',
dMeterType: 7
2025-11-24 14:57:53 +00:00
}
]
}
];
/**
* 处理 Swiper 滑动切换事件
* @param {Object} e 事件对象
*/
const handleSwiperChange = (e) => {
currentTab.value = e.detail.current;
};
/**
* 导航到具体的计算页面
2025-11-25 02:51:26 +00:00
* @param {Object} item 点击的项
2025-11-24 14:57:53 +00:00
*/
const navigateToCalc = (item) => {
const dMeterType = item.dMeterType;
console.log(`导航到计算页面dMeterType: ${dMeterType}`);
2025-11-25 02:51:26 +00:00
// 使用 UniApp 原生导航 API
uni.navigateTo({
url: `/pages_caltools/pages/main?dMeterType=${dMeterType}`
});
2025-11-24 14:57:53 +00:00
};
</script>
<style scoped>
.container {
2025-11-25 02:51:26 +00:00
padding: 16rpx;
2025-11-24 14:57:53 +00:00
background-color: #F5F5F5;
box-sizing: border-box;
min-height: 100vh;
}
.page-header {
2025-11-25 02:51:26 +00:00
font-size: 36rpx;
2025-11-24 14:57:53 +00:00
font-weight: 500;
color: #333333;
2025-11-25 02:51:26 +00:00
margin: 30rpx 0;
text-align: center;
2025-11-24 14:57:53 +00:00
}
.calc-swiper {
2025-11-25 02:51:26 +00:00
width: 100vw;
height: 800rpx;
2025-11-24 14:57:53 +00:00
}
2025-11-25 02:51:26 +00:00
.scroll-content {
2025-11-24 14:57:53 +00:00
height: 100%;
2025-11-25 02:51:26 +00:00
width: 100%;
}
::v-deep .custom-grid {
width: 100%;
height: auto;
2025-11-24 14:57:53 +00:00
}
.grid-item {
2025-11-25 02:51:26 +00:00
height: 200rpx;
}
.grid-content {
2025-11-24 14:57:53 +00:00
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
2025-11-25 02:51:26 +00:00
height: 100%;
padding: 20rpx;
2025-11-24 14:57:53 +00:00
}
.grid-icon {
2025-11-25 02:51:26 +00:00
margin-bottom: 20rpx;
display: flex;
align-items: center;
justify-content: center;
width: 80rpx;
height: 80rpx;
2025-11-24 14:57:53 +00:00
}
.grid-text {
2025-11-25 02:51:26 +00:00
font-size: 24rpx;
2025-11-24 14:57:53 +00:00
color: #333333;
text-align: center;
2025-11-25 02:51:26 +00:00
line-height: 1.4;
/* 允许文字换行 */
word-break: break-all;
2025-11-24 14:57:53 +00:00
}
</style>