textClass.vue
4.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
<template>
<div>
<nav-bar class="navbar">
<div slot="left" class="back">
<div @click="goBack">
<img src="../../assets/img/back.png" alt="" class="backimg"/>
</div>
</div>
<div slot="center" class="navtitle">
<div>文本课程</div>
</div>
<div slot="right" class="picker display-flex-around" @click="poslist">
<div>{{infoData?infoData:postname}}</div>
<img src="../../assets/img/xia.png" alt="" :class="isShow?'rotate':''">
</div>
</nav-bar>
<fil-ter :show="isShow" :posts="posts" @infoType="infoType"></fil-ter>
<div class="video_list">
<div class="noresult" v-if="testclass.length == 0">暂无文本课程</div>
<van-list
v-else
v-model="loading"
:finished="finished"
finished-text="没有更多了"
@load="scrollEnd">
<router-link :to="{path:'/TextClassDetail', query:{id:item.id}}" class="class display-flex-between" v-for="(item,index) in testclass" :key="index">
<div><van-image
width="100%"
height="100%"
fit="cover"
:src="item.image"
/></div>
<!-- <img :src="item.image" mode="widthFix" > -->
<div class="class_detail">
<div style="color: #000;" class="p-1">{{ item.name }}</div>
<div class="class_info p-2">{{item.intro}}</div>
</div>
</router-link>
</van-list>
</div>
</div>
</template>
<script>
import '@/assets/style/list3.css'
import '@/assets/style/classlist.css'
import '@/assets/style/common.css'
import filTer from '@/components/filter.vue'
export default {
components: {
filTer
},
data () {
return {
scrollX: false,
pulldown: true,
pullup: false,
testclass: [],
posts: [],
isShow: false,
infoData: '',
postname: '',
pId: '',
page: 1, // 页码
pageNum: 20, // 每页条数
ifmore: false, // 页码数据(第二页是否有数据)
loading: false,
finished: false
}
},
created () {
this.pId = this.$route.query.id
this.textList()
},
methods: {
goBack () {
this.$router.go(-1)
},
scrollEnd () {
if (this.ifmore) {
this.loading = true;
++this.page
this.textList()
}
},
// 文本课程列表
async textList () {
const params = {
pos_id: this.pId,
page: this.page,
page_num: this.pageNum
}
const reslist = await this.api.textList(params)
if (reslist.code === 1) {
// console.log(reslist,'文本课程');
const res = reslist.data.list.data // 文本课程的列表
if (res.length === 0) {
this.ifmore = false
this.finished = true;
this.testclass = this.testclass.concat(res) // 合并数组
} else {
this.ifmore = true
this.testclass = this.page === 1 ? res : this.testclass.concat(res)
}
this.loading = false;
} else {
this.loading = false;
this.$toast(reslist.msg)
}
},
// 工种列表接口
async poslist () {
this.isShow = !this.isShow
const reslist = await this.api.pos()
if (reslist.code === 1) {
// console.log(reslist);
this.posts = reslist.data.list
} else {
this.$toast(reslist.msg)
}
},
infoType (infoType, itemId) {
this.isShow = false
this.infoData = infoType
this.pId = itemId
this.page = 1
this.testclass = []
this.textList()
}
},
mounted () {
if (localStorage.getItem('postname', this.postname)) {
this.postname = localStorage.getItem('postname', this.postname)
this.pId = localStorage.getItem('pId', this.pId)
}
}
}
</script>
<style scoped lang="scss">
.navbar{
background-color: #fff;
}
.back{
width: 1.5rem;
}
.back{
font-size: 0.32rem;
}
.picker{
width: 1.5rem;
justify-content: flex-end;
// font-size: 0.32rem;
}
.video_list {
width: 100%;
padding: 0 .32rem;
box-sizing: border-box;
margin-top: 1rem;
}
</style>