mail.vue
7.39 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<template>
<view class="cert-mail-page">
<!-- 列表区域 -->
<view class="appList">
<view class="appItem" v-for="(item, index) in infoList" :key="index">
<view @click="handleView(item)">
<view class="status">
<text :class="item.postStatus == 1 ? 'text-success' : 'text-warning'">
{{ item.postStatus == 1 ? '已邮寄' : '未邮寄' }}
</text>
</view>
<view class="date" v-if="item.submitTime">
<view class="text-primary" v-if="item.payCode">{{ item.payCode }}</view>
</view>
<view class="name mt0">{{ item.name }}</view>
<view class="flexbox">
<view>
缴费单位
<view>{{ item.memberName }}</view>
</view>
<view>
证书人数
<view>{{ item.totalNum }}</view>
</view>
</view>
<view class="flex f-j-s">
<view class="mail-time" v-if="item.submitTime">
邮寄时间:{{ formatDate(item.submitTime) }}
</view>
<view class="mail-time" v-if="item.postCode ">
<view>物流编号{{ item.postCode || '-' }}</view>
</view>
</view>
</view>
<view class="func">
<button
v-if="deptType == '1' && item.postStatus != 1"
class="btn-mail"
@click.stop="handleMail(item)"
>邮寄证书</button>
<button class="btn-logistics" @click.stop="handleLogistics(item)">物流跟踪</button>
</view>
</view>
</view>
<!-- 空数据 -->
<view class="nodata" v-if="infoList.length == 0 && !loading">
<image mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
<text>暂无数据</text>
</view>
<!-- 上拉加载 -->
<view class="loading">
<uni-load-more :status="loadStatus" :contentText="loadMoreText"></uni-load-more>
</view>
</view>
</template>
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import { ref, computed } from 'vue'
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
const app = getApp()
const loading = ref(false)
// 加载状态
const loadStatus = ref('more') // more / loading / nomore
const loadMoreText = {
contentdown: '上拉加载更多',
contentrefresh: '正在加载...',
contentnomore: '没有更多了'
}
// 请求参数
const queryParams = ref({
pageNum: 1,
pageSize: 10,
type: '1'
})
// 列表数据
const infoList = ref([])
const total = ref(0)
const deptType = ref('')
onLoad((options) => {
if (options.type) {
queryParams.value.type = options.type
}
})
onShow(() => {
if (app.globalData.isLogin) {
init()
} else {
app.firstLoadCallback = () => {
init()
}
}
})
// 初始化(刷新)
function init() {
deptType.value = app.globalData.deptType
// 重置列表和页码
infoList.value = []
queryParams.value.pageNum = 1
loadStatus.value = 'more'
getList()
}
// 获取列表
function getList() {
// 没有更多数据直接返回
if (loadStatus.value === 'nomore') return
loading.value = true
loadStatus.value = 'loading'
uni.showLoading({ title: '加载中' })
api.paymentList({ ...queryParams.value }).then(res => {
const data = res.rows || []
const totalData = res.total || 0
// 拼接数据
infoList.value = [...infoList.value, ...data]
total.value = totalData
// 判断是否还有更多
if (infoList.value.length >= totalData) {
loadStatus.value = 'nomore'
} else {
loadStatus.value = 'more'
}
loading.value = false
uni.hideLoading()
}).catch(() => {
loading.value = false
uni.hideLoading()
loadStatus.value = 'more'
})
}
// 上拉加载下一页
onReachBottom(() => {
if (loadStatus.value !== 'more' || loading.value) return
queryParams.value.pageNum++
getList()
})
// 查看详情
function handleView(item) {
uni.navigateTo({
url: `/level/ztx/certDetail?examId=${item.examId}`
})
}
// 邮寄证书
async function handleMail(item) {
const res = await uni.showModal({
title: '提示',
content: '是否确认寄送快递?',
confirmText: '确认',
cancelText: '取消'
})
if (res.confirm) {
uni.showLoading({ title: '操作中' })
api.postCert(item.payId).then(() => {
uni.hideLoading()
uni.showToast({ title: '操作成功', icon: 'success' })
// 操作成功后刷新列表
init()
}).catch(() => {
uni.hideLoading()
})
}
}
// 物流跟踪
function handleLogistics(item) {
if (item.postStatus != 1 || !item.postCode) {
uni.showToast({ title: '暂无物流信息', icon: 'none' })
return
}
uni.navigateTo({
url: `/level/ztx/certLogistics?payId=${item.payId}&postCode=${item.postCode}&postStatus=${item.postStatus}&submitTime=${item.submitTime || ''}`
})
}
// 时间格式化
function formatDate(dateStr) {
if (!dateStr) return '-'
return dateStr.substring(0, 10)
}
// 等级转中文
function levelToChinese(level) {
const levelMap = {
'1': '一', '2': '二', '3': '三', '4': '四', '5': '五',
'6': '六', '7': '七', '8': '八', '9': '九', '10': '十'
}
return levelMap[String(level)] || level
}
</script>
<style lang="scss" scoped>
.cert-mail-page {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 20rpx;
}
/* 列表区域 */
.appList {
padding: 0 20rpx;
}
.appItem {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
.status {
display: inline-block;
padding: 6rpx 20rpx;
border-radius: 20rpx;
font-size: 24rpx;
margin-bottom: 16rpx;
.text-success {
color: #4caf50;
}
.text-warning {
color: #ff9800;
}
}
.date {
font-size: 24rpx;
color: #999;
}
.text-primary {
font-size: 28rpx;
color: #AD181F;
}
.name {
font-size: 28rpx;
font-weight: 600;
color: #333;
margin-bottom: 20rpx;
margin-top: 10rpx;
&.mt0 {
margin-top: 0;
}
}
.flexbox {
display: flex;
justify-content: space-between;
background-color: #fafafa;
border-radius: 12rpx;
padding: 20rpx;
margin: 20rpx 0;
view {
flex: 1;
text-align: center;
font-size: 24rpx;
color: #999;
view {
font-size: 28rpx;
color: #333;
font-weight: 500;
margin-top: 8rpx;
}
}
}
.mail-time {
font-size: 24rpx;
color: #666;
margin-top: 16rpx;
}
.func {
display: flex;
gap: 20rpx;
margin-top: 24rpx;
padding-top: 24rpx;
border-top: 1px solid #f0f0f0;
justify-content: flex-end;
button {
height: 64rpx;
line-height: 64rpx;
font-size: 26rpx;
border-radius: 32rpx;
border: none;
}
.btn-mail {
width: 100px;
background: #AD181F;
color: #fff;
}
.btn-logistics {
width: 100px;
background: linear-gradient(135deg, #2196f3, #42a5f5);
color: #fff;
}
}
}
.nodata {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 0;
image {
width: 300rpx;
height: 300rpx;
}
text {
font-size: 28rpx;
color: #999;
margin-top: 20rpx;
}
}
.loading {
padding: 30rpx 0;
text-align: center;
}
</style>