SearchDetail.vue
10.5 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
<template>
  <div class="evaluateDetail">
    <div class="nav">
      <van-nav-bar title="搜索课程" left-arrow :fixed="true" @click-left="onClickLeft">
        <template #right>
          <div class="searchBtn" @click="searchBox = true">
            <van-icon name="apps-o" />
            <span>重新筛选</span>
          </div>
        </template>
      </van-nav-bar>
    </div>
    <h3 class="searchCont">共搜索到{{ listCount }}个课程</h3>
    <dl class="condition">
      <dd v-for="(n, i) in condition" :key="'100' + i">{{ n }}</dd>
    </dl>
    <ul class="list">
      <li v-for="(n, i) in list" :key="i" @click="goCourseDetail(n.id)">
        <div class="top">
          <span class="title">{{ n.baseName }}</span>
          <span class="lookNum">{{ n.read_count }}人已浏览</span>
          <img :src="n.coverUrl ? n.coverUrl : require('@/assets/defCoure.jpg')" alt="" />
        </div>
        <div class="bottom">
          <h3>{{ n.course_info }}</h3>
          <!-- <p>“深刻了解江南水乡”</p> -->
        </div>
      </li>
    </ul>
    <van-empty
      class="custom-image"
      image="https://img.yzcdn.cn/vant/custom-empty-image.png"
      description="暂无课程"
      v-if="list.length == 0"
    />
    <van-popup v-model="searchBox" position="right">
      <div class="searchBox">
        <h3>筛选搜索</h3>
        <p>年龄段</p>
        <ul class="grades">
          <li><span :class="grade.indexOf('一年级') > -1 ? 'active' : ''" @click="selectGrade('一年级', 0)">一年级</span></li>
          <li><span :class="grade.indexOf('二年级') > -1 ? 'active' : ''" @click="selectGrade('二年级', 0)">二年级</span></li>
          <li><span :class="grade.indexOf('三年级') > -1 ? 'active' : ''" @click="selectGrade('三年级', 0)">三年级</span></li>
          <li><span :class="grade.indexOf('四年级') > -1 ? 'active' : ''" @click="selectGrade('四年级', 0)">四年级</span></li>
          <li><span :class="grade.indexOf('五年级') > -1 ? 'active' : ''" @click="selectGrade('五年级', 0)">五年级</span></li>
          <li><span :class="grade.indexOf('六年级') > -1 ? 'active' : ''" @click="selectGrade('六年级', 0)">六年级</span></li>
          <li><span :class="grade.indexOf('初一') > -1 ? 'active' : ''" @click="selectGrade('初一', 0)">初一</span></li>
          <li><span :class="grade.indexOf('初二') > -1 ? 'active' : ''" @click="selectGrade('初二', 0)">初二</span></li>
          <li><span :class="grade.indexOf('初三') > -1 ? 'active' : ''" @click="selectGrade('初三', 0)">初三</span></li>
          <li><span :class="grade.indexOf('高一') > -1 ? 'active' : ''" @click="selectGrade('高一', 0)">高一</span></li>
          <li><span :class="grade.indexOf('高二') > -1 ? 'active' : ''" @click="selectGrade('高二', 0)">高二</span></li>
          <li><span :class="grade.indexOf('高三') > -1 ? 'active' : ''" @click="selectGrade('高三', 0)">高三</span></li>
        </ul>
        <p>课程分类</p>
        <ul class="grades">
          <li v-for="(n, i) in CourseTypeList" :key="i + '100'">
            <span :class="subject.indexOf(n.id) > -1 ? 'active' : ''" @click="selectGrade(n.id, 1, n.courseType)">{{ n.courseType }}</span>
          </li>
        </ul>
        <p>地点</p>
        <ul class="grades">
          <li><span :class="area.indexOf('杭州市') > -1 ? 'active' : ''" @click="selectGrade('杭州市', 2)">杭州</span></li>
          <li><span :class="area.indexOf('宁波市') > -1 ? 'active' : ''" @click="selectGrade('宁波市', 2)">宁波</span></li>
          <li><span :class="area.indexOf('温州市') > -1 ? 'active' : ''" @click="selectGrade('温州市', 2)">温州</span></li>
          <li><span :class="area.indexOf('绍兴市') > -1 ? 'active' : ''" @click="selectGrade('绍兴市', 2)">绍兴</span></li>
          <li><span :class="area.indexOf('湖州市') > -1 ? 'active' : ''" @click="selectGrade('湖州市', 2)">湖州</span></li>
          <li><span :class="area.indexOf('嘉兴市') > -1 ? 'active' : ''" @click="selectGrade('嘉兴市', 2)">嘉兴</span></li>
          <li><span :class="area.indexOf('金华市') > -1 ? 'active' : ''" @click="selectGrade('金华市', 2)">金华</span></li>
          <li><span :class="area.indexOf('衢州市') > -1 ? 'active' : ''" @click="selectGrade('衢州市', 2)">衢州</span></li>
          <li><span :class="area.indexOf('台州市') > -1 ? 'active' : ''" @click="selectGrade('台州市', 2)">台州</span></li>
          <li><span :class="area.indexOf('丽水市') > -1 ? 'active' : ''" @click="selectGrade('丽水市', 2)">丽水</span></li>
          <li><span :class="area.indexOf('舟山市') > -1 ? 'active' : ''" @click="selectGrade('舟山市', 2)">舟山</span></li>
        </ul>
        <div class="btns">
          <span @click="btnClick()">重置</span>
          <span @click="btnClick(1)">确定</span>
        </div>
      </div>
    </van-popup>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: '',
      listCount: 0,
      userInfo: '',
      searchBox: true,
      grade: [],
      subject: [],
      area: [],
      condition: [],
      CourseTypeList: [],
      CourseTypeText: [],
    }
  },
  created() {
    var userInfo = localStorage.getItem('userInfo')
    if (userInfo) {
      this.userInfo = JSON.parse(userInfo)
    }
    var id = this.$route.query.id
    this.GetCourseTypeList()
  },
  mounted() {
    var box = document.getElementsByClassName('searchBox')
    box[0].style.height = window.innerHeight + 'px'
    console.log(window.innerHeight + 'px')
  },
  methods: {
    goCourseDetail(id) {
      this.$router.push({ path: '/CourseDetail', query: { id: id } })
    },
    onClickLeft() {
      history.back()
    },
    selectGrade(text, type, name) {
      var that = this
      var arr = ''
      if (type == 0) {
        arr = this.grade
      } else if (type == 1) {
        arr = this.subject
      } else if (type == 2) {
        arr = this.area
      }
      if (arr.indexOf(text) == -1) {
        arr.push(text)
      } else {
        arr.forEach(function (n, i) {
          if (n == text) {
            arr.splice(i, 1)
          }
        })
      }
      if (name) {
        if (this.CourseTypeText.indexOf(name) == -1) {
          this.CourseTypeText.push(name)
        } else {
          this.CourseTypeText.forEach(function (n, i) {
            if (n == name) {
              that.CourseTypeText.splice(i, 1)
            }
          })
        }
      }
    },
    btnClick(t) {
      if (t) {
        this.GetCourseList(1)
        this.searchBox = false
        this.condition = this.grade.concat(this.CourseTypeText).concat(this.area)
      } else {
        this.grade = []
        this.subject = []
        this.area = []
      }
    },
    GetCourseTypeList() {
      var that = this
      this.http
        .GetCourseTypeList({
          page: 1,
          pageSize: 999,
        })
        .then(function (res) {
          if (res.status == 1) {
            that.CourseTypeList = res.data.list
          }
        })
    },
    GetCourseList(page) {
      var that = this
      this.$toast.loading({
        message: '请求中...',
      })
      this.http
        .GetCourseList({
          pageIndex: page,
          pageSize: 99999,
          courseType: this.subject.join(','),
          area: this.area.join(','),
          suitableAges: this.grade.join(','),
        })
        .then(function (res) {
          that.$toast.clear()
          if (res.status == 1) {
            that.listCount = res.data.count
            that.list = res.data.items
          }
        })
    },
  },
}
</script>
<style lang="stylus" scoped>
.evaluateDetail{
	background-color #FBFBFB
	position fixed
	left 0
	top 0
	right 0
	bottom 0
	overflow auto
}
.searchBtn{
	color #6BCFAD
	font-size 1.4rem
	i{
		color #6BCFAD
		display inline-block
		vertical-align middle
	}
	span{
		display inline-block
		vertical-align middle
	}
}
.searchCont{
	margin-top 100px
	font-size 1.2rem
	padding-left 40px
}
.condition{
	padding 0 40px
	box-sizing border-box
	dd{
		display inline-block
		padding 10px 30px
		border-radius 100px
		background #B6F3D8
		color #02924C
		margin 0 20px 10px 0
	}
}
.searchBox{
	width 600px
	height 100%
	overflow auto
	padding-bottom 200px
	box-sizing: border-box;
	h3{
		padding-left 40px
		font-size 1.6rem
	}
	p{
		padding-left 40px
		font-size 1.4rem
	}
	.grades{
		padding 0 20px
		box-sizing border-box
		overflow hidden
		li{
			padding 20px
			float left
			width 33.33%
			box-sizing border-box
			span{
				display inline-block
				width 100%
				padding 20px 0
				text-align center
				font-size 1.4rem
				border-radius 6px
				position relative
				background-color #EEEEEE
			}
			span.active{
				background-color #92EFC9
				color #0d6e44
			}
			span.active::after{
				content 'x'
				position absolute
				color white
				right 6px
				bottom 0
				font-size 1.2rem
				z-index 100
			}
			span.active::before{
				content 'x'
				position absolute
				color white
				right 0
				bottom 0
				z-index 50
				width 0
				height 0
				border-bottom 40px solid #1CD988
				border-left 40px solid transparent
			}
		}
	}
	.btns{
		position absolute
		bottom 0
		left 0
		right 0
		background-color white
		text-align center
		padding 40px 0
		box-shadow 0 -6px 10px #EEEEEE
		span{
			display inline-block
			padding 20px 60px
			background-color #A6A6A6
			border-radius 100px 0 0 100px
			color white
			font-size 1.6rem
		}
		span:last-child{
			background linear-gradient(138deg, #29E576 0%, #14CFB0 100%)
			border-radius 0 100px 100px 0
		}
	}
}
.list{
	overflow hidden
	padding 0 40px
	box-sizing border-box
	li{
		float left
		width 50%
		box-sizing border-box
		margin-bottom 20px
		margin-top 20px
		min-height 480px
		.top{
			position relative
			img{
				width 100%
				height 336px
				border-radius 20px 20px 0 0
				object-fit cover
			}
			span{
				position absolute
				background-color rgba(0,0,0,0.5)
				color white
				left 20px
				padding 6px 10px
			}
			span.lookNum{
				bottom 20px
				border-radius 100px
			}
			span.title{
				top 20px
			}
		}
		.bottom{
			background-color white
			border-radius 0 0 10px 10px
			min-height 130px
			padding 0 20px
			box-sizing border-box
			h3{
				word-break: break-all;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				overflow: hidden;
				margin 0
				font-size 1.6rem
			}
			p{
				color #0EDBA1
				font-size 1.2rem
				margin 0
				padding 10px 0
			}
		}
	}
	li:nth-child(2n){
		padding-left 20px
	}
	li:nth-child(2n+1){
		padding-right 20px
	}
}
</style>