renew.vue
10.4 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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
<template>
<view class="hasfixedbottom">
<view class="searchbar">
<uni-easyinput placeholderStyle="font-size:30rpx" :input-border="false" prefixIcon="search"
v-model="queryParams.perName" placeholder="搜索姓名或证件号码" @blur="getList" @clear="getList">
</uni-easyinput>
<view class="invertedbtn-red" @click="showAddPopup">+ 添加</view>
<view class="invertedbtn-red" @click="goVipList">+ 在线选择</view>
</view>
<view style="padding:0 20rpx">
<view class="vipData mtb30">
<view> 人数合计:<text>{{ countData.all? countData.all:0 }}</text>人 </view>
<view> 新会员合计:<text>{{ countData.new? countData.new:0 }}</text>人 </view>
<view> 续费会员合计:<text>{{ countData.old? countData.old:0 }}</text>人 </view>
</view>
<uni-swipe-action>
<uni-swipe-action-item class="personitem" v-for="(n,index) in list" :key="index">
<view class="content-box">
<view class="flexbox">
<view>{{n.perName}}
<view class="date">
证件号:{{n.perIdcCode}}
</view>
</view>
</view>
<view class="flexbox" @click="changeYear(n)">
<view class="text-danger">({{yearlist[n.payYear-1].text}})</view>
<uni-icons type="forward" size="18" color="#999"></uni-icons>
</view>
</view>
<template v-slot:right>
<view class="slot-button">
<view @click="handleDelete(n)">
<uni-icons type="trash-filled" color="#fff" size="20"></uni-icons>
<text class="slot-button-text">删除</text>
</view>
</view>
</template>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
<view class="nodata" v-if="list.length==0">
<image mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
<text>请添加会员</text>
</view>
<view class="fixedBottom">
<button class="btn-red" :disabled="list?.length <= 0" @click="commitFN">保存并缴费</button>
</view>
<uni-popup ref="pickView" type="bottom">
<view class="pickViewBox">
<view v-for="(n,index) in yearlist" @click="bindyear(n)" :key="index">
{{n.text}}<uni-icons v-show="n.value == (nowYear)" type="checkmarkempty" size="20"
color="green"></uni-icons>
</view>
</view>
</uni-popup>
<!-- 添加会员弹框 -->
<uni-popup ref="addPopup" type="center">
<view class="add-popup">
<view class="popup-title">添加会员</view>
<view class="popup-form">
<view class="form-item">
<view class="form-label">证件类型</view>
<view class="form-input">
<picker :value="idcListIndex" :range="idcList" range-key="label" @change="onIdcTypeChange">
<view class="picker-value">{{ idcList[idcListIndex]?.label }}</view>
</picker>
</view>
</view>
<view class="form-item">
<view class="form-label">证件号</view>
<view class="form-input">
<input v-model="addForm.idcCode" placeholder="请输入证件号" placeholder-class="placeholder-class"/>
</view>
</view>
</view>
<view class="popup-btns">
<view class="popup-btn cancel" @click="closeAddPopup">取消</view>
<view class="popup-btn confirm" @click="confirmAdd">确定</view>
</view>
</view>
</uni-popup>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import config from '@/config.js'
const app = getApp()
const queryParams = ref({
rangeId: '',
pageNum: 1,
pageSize: 10,
})
const countData = ref({})
const list = ref([])
const total = ref(0)
const nowYear = ref(1)
const nowItem = ref({})
const pickView = ref(null)
const addPopup = ref(null)
const visible = ref(true)
const addForm = ref({
idcCode: '',
idType: '0'
})
const idcList = ref([
{ label: '身份证', value: '0' },
{ label: '来往大陆(内地)通行证', value: '1' },
{ label: '香港身份证', value: '5' }
])
const idcListIndex = ref(0)
const yearlist = ref([{
text: '一年',
value: 1
}, {
text: '二年',
value: 2
}, {
text: '三年',
value: 3
}, {
text: '四年',
value: 4
}, {
text: '五年',
value: 5
}])
onLoad((option) => {
if (option.rangeId) {
queryParams.value.rangeId = option.rangeId
}
})
onShow(() => {
if (app.globalData.isLogin) {
init()
} else {
app.firstLoadCallback = () => {
init()
};
}
})
function init() {
console.log('init',queryParams.value.rangeId )
getList()
getCount()
}
// 获取列表 + 统计(修复版)
async function getList() {
try {
const res = await api.listAPI(queryParams.value)
list.value = res.rows || []
total.value = res.total || 0
} catch (e) {
list.value = []
total.value = 0
}
// 只有 rangeId 合法时才获取统计(修复关键)
// if (queryParams.value.rangeId && queryParams.value.rangeId > 0) {
// await getCount()
// } else {
// // 清空统计
// countData.value = { all: 0, new: 0, old: 0 }
// }
}
// 获取统计
async function getCount() {
try {
const res = await api.getNewCountByRangeId(queryParams.value.rangeId)
countData.value = res.data || { all: 0, new: 0, old: 0 }
} catch (e) {
countData.value = { all: 0, new: 0, old: 0 }
}
}
function goVipList() {
let path = `/personalVip/vipList?rangeId=${queryParams.value.rangeId}`
uni.navigateTo({ url: path });
}
function changeYear(e) {
nowItem.value = e
nowYear.value = e.payYear
pickView.value.open()
}
// 修改年限
async function bindyear(n) {
nowYear.value = n.value
pickView.value.close()
nowItem.value.payYear = n.value
await api.editYear({
payId: nowItem.value.payId,
year: nowItem.value.payYear
})
// 刷新列表和统计
await getList()
uni.showToast({ title: '操作成功' })
}
// 删除(修复关键逻辑)
async function handleDelete(row) {
uni.showModal({
title: '提示',
content: `确定删除${row.perName}吗`,
success: async function(res) {
if (res.confirm) {
await api.paymentNewDel(row.payId)
uni.showToast({ title: '删除成功' })
getList()
}
}
})
}
// 保存缴费
async function commitFN(){
if (!queryParams.value.rangeId) return
uni.navigateTo({
url: `/myCenter/payOrder?rangeId=${queryParams.value.rangeId}`
})
}
// 显示添加弹框
function showAddPopup() {
addForm.value.idcCode = ''
idcListIndex.value = 0
addPopup.value.open()
}
// 关闭添加弹框
function closeAddPopup() {
addPopup.value.close()
}
// 证件类型选择
function onIdcTypeChange(e) {
idcListIndex.value = e.detail.value
addForm.value.idType = idcList.value[idcListIndex.value].value
}
// 确认添加
async function confirmAdd() {
if (!addForm.value.idcCode) {
uni.showToast({ title: '请输入证件号', icon: 'none' })
return
}
if (!queryParams.value.rangeId) {
uni.showToast({ title: '缺少rangeId', icon: 'none' })
return
}
try {
await api.memberInsertPersons({
rangeId: queryParams.value.rangeId,
year: 1,
idcCode: addForm.value.idcCode
})
uni.showToast({ title: '添加成功', icon: 'success' })
closeAddPopup()
getList()
getCount()
} catch (e) {
console.error(e)
}
}
</script>
<style scoped lang="scss">
.pickViewBox {
background-color: #fff;
text-align: center;
view { line-height: 3; }
}
.searchbar {
display: flex;
align-items: center;
padding: 25rpx;
box-sizing: border-box;
.invertedbtn-red {
margin-left: 15rpx;
font-size: 30rpx;
padding: 10rpx 20rpx;
box-sizing: border-box;
border-radius: 50rpx;
background-color: #fff;
}
:deep(.uni-easyinput .uni-easyinput__content) {
border-radius: 35rpx;
border: none;
height: 70rpx;
}
:deep(.uni-easyinput__content-input) {
font-size: 26rpx;
}
}
.slot-button {
display: flex;
align-items: center;
padding: 0 20px;
text-align: center;
background-color: #E60012;
}
.slot-button-text {
color: #ffffff;
display: block;
font-size: 14px;
}
.personitem {
background: #fff;
box-sizing: border-box;
margin-bottom: 30rpx;
.content-box {
display: flex;
background-color: #fff;
align-items: center;
padding: 16rpx;
border-radius: 15rpx;
justify-content: space-between;
margin-bottom: 20rpx;
}
.flexbox {
align-items: center;
}
}
.vipData {
padding: 10rpx 20rpx 5rpx;
font-size: 28rpx;
color: #666;
view { margin-bottom: 10rpx; }
text { color: #AD181F; font-weight: bold; }
}
.nodata {
text-align: center;
padding: 100rpx 0;
image { width: 200rpx; height: 200rpx; margin-bottom: 20rpx; }
text { font-size: 28rpx; color: #999; }
}
.fixedBottom {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 20rpx;
background: #fff;
border-top: 1rpx solid #eee;
}
.btn-red {
width: 100%;
height: 80rpx;
line-height: 80rpx;
background: #E60012;
color: #fff;
border-radius: 40rpx;
font-size: 32rpx;
border: none;
}
/* 添加会员弹框 */
.add-popup {
width: 600rpx;
background: #ffffff;
border-radius: 24rpx;
overflow: hidden;
}
.popup-title {
font-size: 32rpx;
font-weight: 500;
color: #333;
text-align: center;
padding: 40rpx 30rpx 20rpx;
}
.popup-form {
padding: 20rpx 30rpx 40rpx;
}
.form-item {
display: flex;
align-items: center;
margin-bottom: 24rpx;
}
.form-item:last-child {
margin-bottom: 0;
}
.form-label {
width: 140rpx;
font-size: 28rpx;
color: #333;
flex-shrink: 0;
}
.form-input {
flex: 1;
background: #f5f5f5;
border-radius: 12rpx;
padding: 20rpx 24rpx;
}
.form-input input {
font-size: 28rpx;
color: #333;
width: 100%;
}
.picker-value {
font-size: 28rpx;
color: #333;
}
.placeholder-class {
color: #999;
}
.popup-btns {
display: flex;
border-top: 1rpx solid #eee;
}
.popup-btn {
flex: 1;
height: 100rpx;
line-height: 100rpx;
text-align: center;
font-size: 30rpx;
}
.popup-btn.cancel {
color: #666;
border-right: 1rpx solid #eee;
}
.popup-btn.confirm {
color: #E60012;
font-weight: 500;
}
</style>