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 {
|
2025-11-26 15:41:57 +00:00
|
|
|
|
ref,
|
|
|
|
|
|
onMounted,
|
|
|
|
|
|
onBeforeMount,
|
|
|
|
|
|
watch
|
2025-11-24 14:57:53 +00:00
|
|
|
|
} from 'vue';
|
|
|
|
|
|
import {
|
2025-11-26 15:41:57 +00:00
|
|
|
|
extractModuleData
|
|
|
|
|
|
} from '@/utils/moudlesData.ts';
|
2025-11-24 14:57:53 +00:00
|
|
|
|
// 响应式数据:当前激活的 Swiper 标签索引
|
|
|
|
|
|
const currentTab = ref(0);
|
|
|
|
|
|
|
|
|
|
|
|
// 核心数据:计算分组和功能项定义
|
2025-11-26 15:41:57 +00:00
|
|
|
|
const calcGroups = ref([]);
|
2025-11-24 14:57:53 +00:00
|
|
|
|
|
2025-11-26 15:41:57 +00:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
calcGroups.value = extractModuleData(['流量计算', '参数计算'], false)
|
|
|
|
|
|
console.log(calcGroups.value);
|
|
|
|
|
|
})
|
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) => {
|
2025-11-26 15:41:57 +00:00
|
|
|
|
const dMeterType = item.params;
|
2025-11-25 02:51:26 +00:00
|
|
|
|
// 使用 UniApp 原生导航 API
|
|
|
|
|
|
uni.navigateTo({
|
2025-11-26 15:41:57 +00:00
|
|
|
|
url: item.path + `?dMeterType=${dMeterType}`
|
2025-11-25 02:51:26 +00:00
|
|
|
|
});
|
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>
|