choose_project.vue
11.1 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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<template>
<view style="padding: 25rpx;">
<!--个人报名 - 选择参赛项目 -->
<button class="addBtn" @click="addProject">+ 选择参赛项目</button>
<view class="block" v-for="(p,index) in chooseList" :key="p.id">
<view class="t">{{p.name}}</view>
<uni-swipe-action>
<uni-swipe-action-item>
<view class="content-box">
<text class="content-z">{{p.cptProjectName}}</text>
<text class="content-j">{{p.cptGroupName}}{{p.cptLevelName}}</text>
</view>
<template v-slot:right>
<view class="slot-button" @click="removeThis(p,index)">
<!-- <uni-icons type="trash" color="#fff" size="20"></uni-icons> -->
<text class="slot-button-text">删除</text>
</view>
</template>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
<view class="nodata" v-if="chooseList.length==0">
<image mode="aspectFit" src="/static/nodata.png"></image>
<text>点击选择参赛项目参加赛事</text>
</view>
<view class="fixedBottom">
<button class="btn btnKx" @click="goPrev" type="default">上一步</button>
<button class="btn btn1" @click="goNext" type="default">下一步</button>
</view>
<!-- 选参赛项目 -->
<uni-popup ref="popup" type="bottom" background-color="#fff">
<view class="t">可报项目</view>
<view class="vh65">
<uni-collapse accordion>
<uni-collapse-item v-for="(p,index) in projectList" :key="index" :show-arrow="false" :border="false"
title-border="none">
<template v-slot:title>
<view class="levelTitle" @click="chooseThisProject(p)">{{p.name}}
<text>查看组别</text>
</view>
</template>
<uni-list :border="false">
<!-- 组别 -->
<uni-list-item v-for="(group,index) in signGroupList" :key="index" :title="group.name"
clickable @click="findLevels(group.id)">
</uni-list-item>
</uni-list>
<view class="nodata" v-if="signGroupList.length==0">
<image mode="aspectFit" src="/static/nodata.png"></image>
<text>暂无可选组别</text>
</view>
</uni-collapse-item>
</uni-collapse>
</view>
</uni-popup>
<!-- 级别 -->
<uni-popup ref="signlevelListPopup" @maskClick="levelMaskClick">
<view class="levelList">
<view class="t">可报级别</view>
<view v-if="signlevelList.length&&signlevelList.length>0">
<uni-data-checkbox mode="button" @change="changeSignlevel0" v-model="signlevel0"
:localdata="signlevelList"></uni-data-checkbox>
</view>
<uni-section title="男子组" type="line" v-if="signlevelListBoy.length>0">
<uni-data-checkbox mode="button" @change="changeSignlevel1" v-model="signlevel1"
:localdata="signlevelListBoy"></uni-data-checkbox>
</uni-section>
<uni-section title="女子组" type="line" v-if="signlevelListGirl.length>0">
<uni-data-checkbox mode="button" @change="changeSignlevel2" v-model="signlevel2"
:localdata="signlevelListGirl"></uni-data-checkbox>
</uni-section>
<button class="btn btn1" @click="levelDone">确定</button>
</view>
</uni-popup>
</view>
</template>
<script setup>
import {
reactive,
toRefs
} from 'vue';
import * as match from '@/common/match.js';
import {
onLoad,onShow
} from '@dcloudio/uni-app';
const data = reactive({
baseFormData: {},
projectList: [],
matchId: '',
chooseList: [],
signGroupList: [],
signlevel0: [],
signlevel1: [],
signlevel2: [],
signlevelListPopup: null,
signlevelList: [],
signlevelListGirl: [],
signlevelListBoy: [],
popup: null
});
const {
baseFormData,
projectList,
matchId,
chooseList,
popup,
signGroupList,
signlevelList,
signlevelListGirl,
signlevelListBoy,
signlevelListPopup,
signlevel0,
signlevel1,
signlevel2
} = toRefs(data);
let personId = ''
let chargeFlag = ''
onLoad((option) => {
if (option.matchId) {
matchId.value = option.matchId
// getCanSignProjectList(matchId.value)
}
// 获取个人信息拿到personId
getMyself()
match.getMatchById({
id: matchId.value
}).then(res => {
chargeFlag = res.data.chargeFlag
})
})
onShow(()=>{
if(matchId.value){
getMySignInfo()
}
})
function getMyself() {
match.getMyPersonInfo().then(res => {
personId = res.data.id;
});
}
function getCanSignProjectList(id) {
projectList.value = []
match.getCanSignProjectList(id).then(res => {
for (let p of res.data) {
if (p.canSign == '1') {
projectList.value.push(p)
}
}
})
}
function addProject() {
if (signInfoType == '2') {
match.recoverMySign({cptId:matchId.value}).then(res => {
if (res.msg.indexOf("Exception:") > -1) {
let msg = res.msg.slice(10)
uni.showModal({
title: '提示',
content: msg,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
}
}
});
return
}
getMySignInfo()
})
}
// popup.value.open()
uni.navigateTo({
url: `/pages_match/match/projectList?personId=${personId}&matchId=${matchId.value}&groupId=0`
});
}
function chooseThisProject(p) {
// 获取组别
signGroupList.value = []
match.getCanSignGroupListFromSelectPerson(p.id, personId).then(res => {
for (var g of res.data) {
if (g.canSign == '1') {
signGroupList.value.push(g)
}
}
})
}
function removeThis(p, index) {
match.deleteSign(p.id).then(res => {
// 重新获取已报名信息
chooseList.value = []
getMySignInfo()
})
}
let nowLevel = ''
function findLevels(groupId) {
signlevelList.value = []
signlevelListGirl.value = []
signlevelListBoy.value = []
match.getCanSignlevelListFromSelectPerson(groupId, personId).then(res => {
for (let l of res.data) {
l.text = l.name
l.value = l.id
if (l.levelType == '1') {
signlevelListBoy.value.push(l)
} else if (l.levelType == '2') {
signlevelListGirl.value.push(l)
} else {
signlevelList.value.push(l)
}
}
signlevelListPopup.value.open()
})
}
function levelMaskClick(){
signlevelList.value = []
signlevelListGirl.value = []
signlevelListBoy.value = []
signlevel0.value = ''
signlevel1.value = ''
signlevel2.value = ''
nowLevel = ''
}
function levelDone() {
console.log(signlevel0.value , signlevel1.value , signlevel2.value)
nowLevel = signlevel0.value + signlevel1.value + signlevel2.value
if(!nowLevel){
uni.showToast({
title: '请选择级别',
icon: 'none',
duration: 2000
});
return
}
// 半提交
let obj = {
levelId: nowLevel,
athleteIds: personId,
groupId: '',
teamId: ''
}
saveOne(obj)
}
function saveOne(obj) {
match.sportsmanDone(obj).then(res => {
if (res.msg.indexOf("Exception:") > -1) {
let msg = res.msg.slice(10)
uni.showModal({
title: '提示',
content: msg,
success: function(res) {
if (res.confirm) {
// let path = `/pages/usercenter/match`;
// uni.redirectTo({url: path});
}
}
});
return
}
signlevel0.value = []
signlevel1.value = []
signlevel2.value = []
nowLevel = ''
var backInfo = res.data
signlevelListPopup.value.close()
popup.value.close()
getMySignInfo()
})
}
let signInfoType = null
function getMySignInfo() {
// 是否已有
match.getMySignInfo({
cptId: matchId.value,
groupId: ''
}).then(res => {
console.log(res.data)
signInfoType = res.data.type
if(!res.data.signInfo){
return
}
chooseList.value = res.data.signInfo
// 4有被的报信息 5 有被清除的报名信息 6 有被的报名信息
if (signInfoType == '2') {
console.log('ff')
}
})
}
function goPrev(){
uni.navigateBack()
}
function goNext() {
if (signInfoType == '1') {
uni.showModal({
title: '提示',
content: '已报项,前往我的报项',
showCancel:false,
success: function (res) {
if (res.confirm) {
let path =
`/pages/usercenter/match`;
uni.reLaunch({
url: path
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
return
}
if (signInfoType == '2') {
match.recoverMySign({cptId:matchId.value}).then(res => {
if (res.msg.indexOf("Exception:") > -1) {
let msg = res.msg.slice(10)
uni.showModal({
title: '提示',
content: msg,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
}
}
});
return
} else {
afterRecover()
}
})
} else {
afterRecover()
}
}
function afterRecover(){
if (chooseList.length == 0) {
uni.showToast({
title: '请至少选择一个项目',
icon: 'none',
duration: 2000
});
return
}
// 判断是否收费
if (chargeFlag == '0') {
var obj = {
cptId: matchId.value,
groupId: ''
}
match.commitSign(obj).then(res => {
console.log(res.data)
let path =
`/pages_match/match/matchPayDone?cptId=${matchId.value}&groupId=0&chargeFlag=${chargeFlag}&orderId=${res.data}`;
uni.navigateTo({
url: path
});
})
} else {
// 生成账单
uni.navigateTo({
url: `/pages_match/match/matchBill?cptId=${matchId.value}&personId=${personId}`
});
}
}
</script>
<style scoped lang="scss">
.addBtn {
width: 700rpx;
height: 90rpx;
background: #ffffff;
border: 1rpx solid #1ec886;
color: #1ec886;
font-size: 30rpx;
border-radius: 15rpx;
}
.content-box {
flex: 1;
/* #ifdef APP-NVUE */
justify-content: center;
/* #endif */
padding: 20rpx 30rpx;
position: relative;
background-color: #fff;
border-bottom: 1rpx solid #f5f5f5;
}
.content-z {
color: #4C5359;
font-size: 30rpx;
display: block;
}
.content-j {
color: #000000;
font-size: 26rpx;
}
.slot-button {
flex: 1;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 20rpx 40rpx;
background-color: #ff5a5f;
text-align: center;
}
.slot-button-text {
color: #ffffff;
font-size: 28rpx;
display: block;
}
.uni-popup .t {
text-align: center;
font-size: 30rpx;
padding: 30rpx 0;
}
:deep(.uni-collapse-item) {
margin: 0 !important;
border-bottom: 1px solid #e1e1e1;
border-radius: 0;
}
.levelTitle {
text {
float: right;
font-size: 28rpx;
color: #999;
}
}
.levelItem {
background: #eee;
padding: 10rpx 20rpx;
margin: 20rpx 20rpx 0 0;
display: inline-block;
border-radius: 6rpx;
}
.levelList {
padding: 20rpx 40rpx 40rpx;
background: #fff;
border-radius: 20rpx;
width: 80vw;
max-height: 70vh;
overflow: auto;
box-sizing: border-box;
}
.vh65 {
height: 65vh;
overflow: auto;
:deep(.uni-list-item__container) {
padding: 10px 0;
}
:deep(.uni-list-item__content-title) {
font-size: 17px;
color: #888;
}
}
:deep(.uni-section .uni-section-header) {
padding: 12px 0 0 !important;
}
</style>