trainList.vue
6.71 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
<template>
<view class="box">
<view class="title">
<view class="navSerch">
<view class="serch">
<uni-search-bar class="uni-mt-10" radius="30" placeholder="搜索" clearButton="auto" Button="none"
cancelText="" v-model="name" bgColor="#F4F6FA" @confirm="initData" @blur="initData" @clear="initData" />
</view>
</view>
<view class="searchLeft">
</view>
</view>
<view>
<view class="nav-box">
<view class="nav-ul">
<view class="nva-li" @click="nvaText(index)" :class="{nt:Nindex==index}"
v-for="(item,index) in items" :key="index">
{{item}}
</view>
</view>
</view>
<view class="content">
<view class="taber">
<view v-for="item in list" :key="item.trainId" @click="detail(item)">
<uniList :pic="config.trainUrl_api + item.cover.replaceAll('\\', '/')" :title="item.name"
:card="item.signStatusStr" :tags="item.projectsStr"
:timer="item.signTimeRange"></uniList>
</view>
</view>
</view>
<view><uni-load-more :status="status" :content-text="contentText" /></view>
</view>
</view>
</template>
<script setup>
import config from '@/config.js'
import uniList from '@/training/components/ulist/ulist';
import * as train from '@/training/train.js';
import {
onLoad,
onReady,
onShareAppMessage,
onShareTimeline,
onPullDownRefresh,
onReachBottom
} from '@dcloudio/uni-app';
import {
ref,
getCurrentInstance,
reactive,
toRefs
} from 'vue';
const searchValue = ref();
const items = ref(['全部', '报名中', '培训进行中', '已结束']);
const current = ref(0);
const name = ref();
const Nindex = ref(0)
const range = ref([{
value: 1,
text: '全部'
},
{
value: 2,
text: '报名中'
},
{
value: 3,
text: '进行中'
},
{
value: 4,
text: '即将开始'
},
{
value: 5,
text: '报名未开始'
},
{
value: 6,
text: '培训未开始'
},
{
value: 7,
text: '已结束'
}
]);
const list = ref();
const total = ref();
// noMore没有更多了
// loading加载中
// more下来加载
const status = ref('more');
const flag = ref();
const data = reactive({
query: {
flag: '',
pageSize: 10,
pageNum: 1
},
contentText: {
contentdown: '',
contentrefresh: '加载中',
contentnomore: '没有更多'
}
});
const {
query,
contentText
} = toRefs(data);
// 加载培训列表数据
onLoad(option => {
initData();
});
function initData() {
query.value.flag = current.value;
train.getTrainList(query.value).then(res=>{
list.value = res.rows;
total.value = res.total;
})
}
// 详情页
function detail(item) {
let path = `/training/detailPage?trainId=${item.id}`;
uni.navigateTo({
url: path
});
}
function nvaText(index) {
Nindex.value = index
current.value = index
initData()
console.log(index);
}
// 下来刷新
onPullDownRefresh(() => {
query.value.flag = 0;
initData();
wx.stopPullDownRefresh();
});
// 上拉加载
onReachBottom(async () => {
console.log(list.value.length,total.value)
if (list.value.length >= total.value) {
status.value = 'noMore';
return false;
} else {
status.value = 'loading';
query.value.pageNum += 1;
let res = await train.getTrainList(query.value);
let arr = res.rows;
list.value = list.value.concat(arr);
total.value = res.total;
status.value = 'noMore';
}
});
</script>
<style lang="scss">
.uni-section-header {
display: none !important;
}
.box {
background-color: #fff;
}
.nav-box {
overflow-x: scroll;
}
.nav-ul {
display: flex;
justify-content: space-around;
width: 100%;
}
.nva-li {
font-size: 26rpx;
padding: 10rpx 0rpx;
margin: 0 15rpx;
}
.nt {
font-size: 30rpx;
font-weight: 400;
border-bottom: 4rpx solid #AD181F;
}
.taber {
width: 100%;
padding: 25rpx 30rpx;
padding-bottom: 0;
}
.segmented-control__text {
font-size: 26rpx !important;
font-family: PingFang SC !important;
font-weight: 400 !important;
color: #4c5359 !important;
}
.segmented-control__item--text {
border-bottom: 4rpx solid #54e1b9;
font-size: 30rpx !important;
font-family: PingFang SC !important;
font-weight: 500 !important;
color: #2b3133 !important;
}
.title {
display: flex;
justify-content: space-between;
.navSerch {
width:100%;height:100rpx;flex:1 1 auto;
position: relative;
.serch {
width:100%;
}
}
.searchLeft {
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 400;
color: #000000;
margin-top: 25rpx;
display: flex;
}
.uni-searchbar__cancel {
display: none;
}
:deep(.uni-select) {
border: 0;
// padding-left: 20rpx;
}
:deep(.uni-select__input-text) {
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 400;
color: #000000;
margin-right: 14rpx;
width: 110rpx;
text-align: right;
}
:deep(.uni-select__selector-item) {
// padding: 0 auto;
text-align: center;
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 400;
color: #000000;
}
}
// 搜索框
.search-result {
padding-top: 10rpx;
padding-bottom: 20rpx;
text-align: center;
}
.search-result-text {
text-align: center;
font-size: 14rpx;
color: #666;
}
:deep(.uni-searchbar) {box-sizing: border-box;
}
.uni-searchbar__box {
padding-right: 0rpx !important;
}
.example-body {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
padding: 0px;
}
.uni-mt-10 {
width: 600rpx;
}
// 分段器
.example-body {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
padding: 0;
}
.uni-common-mt {
margin-top: 30rpx;
}
.uni-padding-wrap {
// width: 750rpx;
padding: 0rpx 30rpx;
}
.content {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
// height: 1235rpx;
text-align: center;
}
.content-text {
font-size: 14rpx;
color: #666;
}
.color-tag {
width: 25rpx;
height: 25rpx;
}
.uni-list {
flex: 1;
}
.uni-list-item {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex: 1;
flex-direction: row;
background-color: #ffffff;
}
.uni-list-item__container {
padding: 12rpx 15rpx;
width: 100%;
flex: 1;
position: relative;
/* #ifndef APP-NVUE */
display: flex;
box-sizing: border-box;
/* #endif */
flex-direction: row;
justify-content: space-between;
align-items: center;
border-bottom-style: solid;
border-bottom-width: 1rpx;
border-bottom-color: #eee;
}
.uni-list-item__content-title {
font-size: 14rpx;
}
.chat-custom-right {
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: space-between;
align-items: flex-end;
}
.chat-custom-text {
font-size: 12rpx;
color: #999;
}
</style>