feat 对接数据

This commit is contained in:
Ironsp
2026-09-10 17:34:49 +08:00
parent 903019b15a
commit 9d39a48117
4 changed files with 61 additions and 12 deletions

View File

@@ -1,4 +1,13 @@
<script setup lang="ts">
import storage from '@/utils/storage'
const project = ref(storage.get('current_project'))
// 页面显示时刷新数据(从设置页返回时)
onShow(() => {
project.value = storage.get('current_project')
})
function onIconClick(name: string) {
if (name === '通知') {
uni.navigateTo({
@@ -27,10 +36,10 @@ function onIconClick(name: string) {
<image class="nav-logo" src="/static/logo.png" mode="aspectFit" @tap="onIconClick('logo')" />
<view class="nav-info">
<text class="nav-title">
G6高速改扩建测试测试项目
{{ project?.project_name || '未设置项目' }}
</text>
<text class="nav-subtitle">
K1+200-K1+800
{{ project?.stake_range || '--' }}
</text>
</view>
</view>

View File

@@ -1,3 +1,8 @@
<script setup lang="ts">
const now = new Date()
const dateStr = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}日`
</script>
<template>
<view class="card overview-card">
<view class="card-header">
@@ -5,7 +10,7 @@
今日作业概览
</text>
<text class="card-date">
2025年8月11日
{{ dateStr }}
</text>
</view>
<view class="overview-stats">
@@ -14,7 +19,7 @@
实时作业状态(台)
</text>
<text class="stat-value">
22
1
</text>
</view>
<view class="stat-item">

View File

@@ -1,10 +1,43 @@
<script setup lang="ts">
const projectName = ref('')
const startEndStation = ref('k12+300-k125+800')
const totalArea = ref('')
import { projectService } from '@/service'
import storage from '@/utils/storage'
function handleSave() {
console.log('保存项目设置')
const PROJECT_KEY = 'current_project'
const currentProject = storage.get(PROJECT_KEY)
const projectName = ref(currentProject?.project_name || '')
const startEndStation = ref(currentProject?.stake_range || '')
const totalArea = ref(currentProject?.total_area ? String(currentProject.total_area) : '')
async function handleSave() {
if (!projectName.value) {
uni.showToast({ title: '请输入项目名称', icon: 'none' })
return
}
try {
const id = await projectService.insert({
project_name: projectName.value,
stake_range: startEndStation.value,
total_area: Number(totalArea.value) || 0,
status: 0,
})
// 保存到 storage
storage.set(PROJECT_KEY, {
id,
project_name: projectName.value,
stake_range: startEndStation.value,
total_area: Number(totalArea.value) || 0,
status: 0,
})
uni.showToast({ title: '保存成功', icon: 'success' })
}
catch (err) {
console.error('保存失败:', err)
uni.showToast({ title: '保存失败', icon: 'none' })
}
}
</script>