treeRecord.vue
5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<template>
<view class="page-container">
<!-- 内容区域 - 集成z-paging分页 -->
<z-paging
ref="pagingRef"
v-model="rows"
@query="fetchData"
:auto-show-system-loading="true"
>
<!-- 空数据提示 -->
<template #empty>
<empty-view/>
</template>
<!-- 空数据组件 -->
<!-- <up-empty v-if="rows.length === 0" text="暂无数据" marginTop="100"></up-empty>-->
<!-- 树木列表:up-card重构 + 保留原始背景图写法 核心满足你的要求 -->
<view class="record-wrap">
<up-card
v-for="i in rows"
:key="i.treenumber"
:border="false"
:show-head="false"
class="tree-card"
:foot-border-top="false"
@click="toEditPage(i.id)"
>
<template #body>
<view class="card-body-inner">
<view class="record-list-left" :style="`background-image: url(${i.treephoto});`"></view>
<view class="record-list-right">
<view class="up-flex up-flex-items-center up-flex-between">
<view class="u-line-1 treetypeName">{{ i.treetype }}</view>
<view class="record-time">{{ timeFormat(i.updatetime) }}</view>
</view>
<view class="record-kv">
<img src="../../../static/imgs/tree/tree-high.png" class="record-ico" alt=""> 高度:{{ i.treeheight }} 米
</view>
<view class="record-kv">
<img src="../../../static/imgs/tree/treearound.png" class="record-ico" alt="">胸径:{{ i.dbh }} 厘米
</view>
</view>
</view>
<view class="record-foot">
<view class="record-tag">树木编号:{{ i.treenumber }}</view>
<text class="record-link">查看</text>
</view>
</template>
</up-card>
</view>
</z-paging>
<!-- 底部新增按钮 -->
<view class="fixed-bottom-btn-wrap">
<up-button
type="primary"
@click="toAddTreePage"
v-show="count > 0 && count > allCount"
>
新增树木录入
</up-button>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
// onUnload(() => {
// // 关闭所有页面,直接打开【行道树档案】主页面 【微信小程序完美兼容,无任何报错】
// uni.reLaunch({
// url: '/pages-sub/data/tree-archive/index'
// })
// })
import { treeRoadReq } from "@/api/tree-archive/tree-archive.js";
import { timeFormat } from '@/uni_modules/uview-plus';
const rows = ref([])
const roadId = ref('')
const count = ref(0)
const allCount = ref(0)
onLoad((options) => {
console.log(options)
roadId.value = options.roadId
count.value = options.count
})
onShow(() => {
// 初始化分页数据
pagingRef.value?.reload()
})
const toEditPage = (id) => {
uni.navigateTo({
url: `/pages-sub/data/tree-archive/editTree?id=${id}`
})
}
const toAddTreePage = () => {
uni.navigateTo({
url: `/pages-sub/data/tree-archive/addTree?roadId=${roadId.value}`
})
}
const pagingRef = ref(null) // z-paging实例
const fetchData = async (pageNo, pageSize) => {
const res = await treeRoadReq({road: roadId.value, pageNo, pageSize})
console.log(res)
allCount.value = res.total
// rows.value = res.list
pagingRef.value?.complete(res?.list || [], res?.total)
}
</script>
<style scoped lang="scss">
/* 页面底色(设计稿 --page-bg) */
.page-container {
min-height: 100vh;
background-color: #F4F6FA;
box-sizing: border-box;
}
/* 列表:左右 24rpx 留白,卡片之间 24rpx(设计稿 .body) */
.record-wrap {
padding: 24rpx 0 calc(120rpx + env(safe-area-inset-bottom)); // 底部固定按钮栏 120rpx,卡片自带 24rpx 外边距
}
/* 树木卡片:白底 16rpx 圆角 + 浅投影(设计稿 .tcard) */
.tree-card {
margin: 0 24rpx 24rpx !important;
border-radius: 16rpx !important;
background-color: #ffffff !important;
box-shadow: 0 4rpx 16rpx rgba(17, 24, 39, 0.06) !important;
}
.tree-card :deep(.u-card__body) {
padding: 24rpx !important;
}
.card-body-inner {
display: flex;
font-size: 26rpx;
}
.record-list-left {
width: 128rpx;
height: 128rpx;
border-radius: 12rpx;
background-color: #F4F6FA;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
flex-shrink: 0;
}
.record-list-right {
margin-left: 24rpx;
flex: 1;
min-width: 0;
overflow: hidden;
}
.treetypeName {
flex: 1;
min-width: 0;
font-size: 30rpx;
font-weight: 500;
color: #1F2937;
}
.record-time {
flex-shrink: 0;
margin-left: 16rpx;
font-size: 22rpx;
color: #6B7280;
}
.record-kv {
display: flex;
align-items: center;
margin-top: 10rpx;
font-size: 24rpx;
color: #1F2937;
}
.record-ico {
width: 24rpx;
height: 24rpx;
margin-right: 8rpx;
}
/* 卡片底部:编号标签 + 查看(设计稿 .tcard-foot) */
.record-foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 1rpx solid #E8EBF0;
}
.record-tag {
display: inline-flex;
align-items: center;
height: 40rpx;
padding: 0 16rpx;
border-radius: 8rpx;
background-color: #EAF7EF;
color: #16A34A;
font-size: 22rpx;
font-weight: 500;
line-height: 1;
}
.record-link {
flex-shrink: 0;
font-size: 24rpx;
color: #2563EB;
}
</style>