提交 58813a3a authored 作者: 王鹏飞's avatar 王鹏飞

修改搜索页面

上级 49505039
<template> <template>
<div class="search-bar"> <div class="search-bar">
<form action @submit.prevent="onSearch"> <el-input
<div class="inner"> prefix-icon="el-icon-search"
<input size="medium"
type="search" clearable
class="search-input" v-model="currentValue"
:placeholder="placeholder" @change="onChange"
v-model="currentValue" @keyup.enter.native="onSearch"
v-bind="$attrs" ref="formInput"
@input="onChange" ></el-input>
ref="formInput" <el-button type="text" size="medium" @click="onSearch">搜索</el-button>
/>
<input type="button" value="搜索" class="search-button" @click="onSearch" />
</div>
</form>
</div> </div>
</template> </template>
...@@ -21,8 +17,7 @@ ...@@ -21,8 +17,7 @@
export default { export default {
props: { props: {
value: String, value: String,
focus: { type: Boolean, default: false }, focus: { type: Boolean, default: false }
placeholder: { type: String, default: '全国道路运输安全生产管理培训' }
}, },
data() { data() {
return { return {
...@@ -45,7 +40,6 @@ export default { ...@@ -45,7 +40,6 @@ export default {
this.focus && this.formInput.focus() this.focus && this.formInput.focus()
}, },
onChange() { onChange() {
this.$emit('input', this.currentValue)
this.$emit('change', this.currentValue) this.$emit('change', this.currentValue)
}, },
onSearch() { onSearch() {
...@@ -60,30 +54,16 @@ export default { ...@@ -60,30 +54,16 @@ export default {
<style lang="scss"> <style lang="scss">
.search-bar { .search-bar {
padding: 0.4rem 0;
}
.search-input {
display: block;
width: 100%;
padding: 0.2rem 0.2rem 0.2rem 0.9rem;
height: 0.66rem;
font-size: 0.26rem;
line-height: 0.26rem;
background: #f7f7f7 url('~@/assets/images/icon_search.png') no-repeat 0.4rem
center;
background-size: 0.31rem;
border: 0;
border-radius: 0.1rem;
outline: none;
}
.search-button {
margin-left: 0.2rem;
color: #222;
font-size: 0.3rem;
appearance: none;
background-color: transparent;
}
.inner {
display: flex; display: flex;
.el-input {
width: 240px;
}
.el-button {
margin-left: 10px;
font-size: 18px;
font-weight: 400;
color: #333;
}
} }
</style> </style>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
</template> </template>
<template v-else> <template v-else>
<slot name="empty"> <slot name="empty">
<p class="empty-tips">暂无内容</p> <p class="empty">暂无内容</p>
</slot> </slot>
</template> </template>
</div> </div>
......
<template> <template>
<div class="app-header"> <div class="app-header">
<div class="title">{{ title }}</div> <div class="title">
<router-link to="/">{{ title }}</router-link>
</div>
<div class="tool"> <div class="tool">
<app-search-bar @search="handleSearch" />
<nav class="nav"> <nav class="nav">
<router-link to="/">首页</router-link> <router-link to="/">首页</router-link>
<router-link to="/my">我的</router-link> <router-link to="/my">我的</router-link>
...@@ -12,12 +15,19 @@ ...@@ -12,12 +15,19 @@
</template> </template>
<script> <script>
import AppSearchBar from '@/components/AppSearchBar'
export default { export default {
name: 'AppHeader', name: 'AppHeader',
components: { AppSearchBar },
data() { data() {
return { return {
title: '金融数字化营销职业技能培训' title: '金融数字化营销职业技能培训'
} }
},
methods: {
handleSearch(value) {
this.$router.replace({ path: '/search', query: { keywords: value } })
}
} }
} }
</script> </script>
...@@ -31,6 +41,11 @@ export default { ...@@ -31,6 +41,11 @@ export default {
padding: 0 30px; padding: 0 30px;
background-color: #fff; background-color: #fff;
.tool {
display: flex;
align-items: center;
}
.title { .title {
font-size: 24px; font-size: 24px;
font-weight: 600; font-weight: 600;
...@@ -38,6 +53,7 @@ export default { ...@@ -38,6 +53,7 @@ export default {
} }
.nav { .nav {
margin-left: 20px;
font-size: 18px; font-size: 18px;
color: #333; color: #333;
a { a {
......
<template> <template>
<div class="main-list" v-show="loaded"> <div class="main-list" element-loading-text="加载中..." v-loading="!loaded">
<ul v-if="list.length"> <ul v-if="list.length">
<li v-for="item in list" :key="item.course_id" @click="onClick(item)">{{item.course_name}}</li> <li v-for="item in list" :key="item.course_id">
<router-link :to="{ name: 'courseLearnItem', params: { id: item.id } }">{{ item.course_name }}</router-link>
</li>
</ul> </ul>
<template v-else> <template v-else>
<slot name="empty"> <slot name="empty">
...@@ -38,11 +40,6 @@ export default { ...@@ -38,11 +40,6 @@ export default {
} }
} }
}, },
computed: {
isWeapp() {
return this.$store.state.isWeapp
}
},
methods: { methods: {
getList() { getList() {
this.loaded = false this.loaded = false
...@@ -54,16 +51,6 @@ export default { ...@@ -54,16 +51,6 @@ export default {
// 刷新 // 刷新
refresh() { refresh() {
this.getList() this.getList()
},
onClick(data) {
if (this.isWeapp) {
// const url = data.free
// ? `/pages/course/free?id=${data.id}`
// : `/pages/web/index?src=${window.location.origin}/course/learn/${data.id}`
wx.miniProgram.navigateTo({ url: `/pages/web/index?src=${window.location.origin}/course/learn/${data.id}` })
} else {
this.$router.push({ name: 'courseLearnItem', params: { id: data.id } })
}
} }
}, },
beforeMount() { beforeMount() {
...@@ -73,13 +60,16 @@ export default { ...@@ -73,13 +60,16 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.main-list ul {
display: flex;
flex-wrap: wrap;
}
.main-list li { .main-list li {
padding: 0.3rem 0; width: 33%;
font-size: 0.3rem; padding: 10px 0;
color: #222; &:hover {
border-bottom: 1px solid #f1f1f1; color: #c01540;
&:last-child { text-decoration: underline;
border-bottom: 0;
} }
} }
</style> </style>
<template> <template>
<div class="main-list" v-show="loaded"> <div class="main-list" element-loading-text="加载中..." v-loading="!loaded">
<ul v-if="list.length"> <ul v-if="list.length">
<li <li v-for="item in list" :key="item.id">
v-for="item in list" <router-link :to="{ name: 'courseTagItem', params: { id: item.id } }">{{ item.title }}</router-link>
:key="item.id" </li>
@click="onClick(item)"
>{{item.title}}{{item.free ? '(免费)': ''}}</li>
</ul> </ul>
<template v-else> <template v-else>
<slot name="empty"> <slot name="empty">
...@@ -58,14 +56,6 @@ export default { ...@@ -58,14 +56,6 @@ export default {
// 刷新 // 刷新
refresh() { refresh() {
this.getList() this.getList()
},
onClick(data) {
if (this.isWeapp) {
const url = `/pages/web/index?src=${window.location.origin}/course/tag/${data.id}`
wx.miniProgram.navigateTo({ url })
} else {
this.$router.push({ name: 'courseTagItem', params: { id: data.id } })
}
} }
}, },
beforeMount() { beforeMount() {
...@@ -75,13 +65,16 @@ export default { ...@@ -75,13 +65,16 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.main-list ul {
display: flex;
flex-wrap: wrap;
}
.main-list li { .main-list li {
padding: 0.3rem 0; width: 33%;
font-size: 0.3rem; padding: 10px 0;
color: #222; &:hover {
border-bottom: 1px solid #f1f1f1; color: #c01540;
&:last-child { text-decoration: underline;
border-bottom: 0;
} }
} }
</style> </style>
<template> <template>
<div class="main-list" v-show="loaded"> <div class="main-list" element-loading-text="加载中..." v-loading="!loaded">
<template v-if="dataList.length"> <template v-if="dataList.length">
<ul> <ul>
<li v-for="item in dataList" :key="item.id" @click="onClick(item)"> <li v-for="item in dataList" :key="item.id" @click="onClick(item)">
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<img :src="item.url" /> <img :src="item.url" />
<div class="cover"></div> <div class="cover"></div>
</div> </div>
<div class="text">{{item.chapter_name}}{{item.free ? '(免费)': ''}}</div> <div class="text">{{ item.chapter_name }}</div>
</li> </li>
</ul> </ul>
</template> </template>
...@@ -67,16 +67,7 @@ export default { ...@@ -67,16 +67,7 @@ export default {
refresh() { refresh() {
this.getList() this.getList()
}, },
onClick(data) { onClick(data) {}
if (this.isWeapp) {
// const url = data.free
// ? `/pages/course/free?id=${data.course_id}&chapter_id=${data.id}`
// : `/pages/course/item?id=${data.course_id}&chapter_id=${data.id}`
wx.miniProgram.navigateTo({ url: `/pages/course/item?id=${data.course_id}&chapter_id=${data.id}` })
} else {
window.alert('请在微信小程序中打开')
}
}
}, },
beforeMount() { beforeMount() {
this.getList() this.getList()
...@@ -86,18 +77,16 @@ export default { ...@@ -86,18 +77,16 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.main-list ul { .main-list ul {
margin-top: 0.58rem;
display: flex; display: flex;
justify-content: space-between;
flex-wrap: wrap; flex-wrap: wrap;
} }
.main-list li { .main-list li {
width: 3rem; width: 33%;
margin-bottom: 0.4rem; margin-bottom: 40px;
.pic { .pic {
position: relative; position: relative;
width: 3rem; width: 160px;
height: 1.7rem; height: 90px;
border-radius: 6px; border-radius: 6px;
img { img {
width: 100%; width: 100%;
...@@ -112,14 +101,11 @@ export default { ...@@ -112,14 +101,11 @@ export default {
right: 0; right: 0;
bottom: 0; bottom: 0;
background: rgba(1, 1, 1, 0.2) url(../../../assets/images/icon_play.png) no-repeat center center; background: rgba(1, 1, 1, 0.2) url(../../../assets/images/icon_play.png) no-repeat center center;
background-size: 0.56rem 0.7rem; background-size: 38px 50px;
z-index: 10; z-index: 10;
} }
.text { .text {
margin: 0.1rem 0; margin: 5px 0;
font-size: 0.3rem;
color: #222;
line-height: 0.4rem;
display: -webkit-box; display: -webkit-box;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
......
<template> <template>
<div class="main-container"> <div class="main-container">
<app-search-bar v-model="searchValue" @search="onSearch" />
<div class="search-tips" v-if="!searchValue"> <div class="search-tips" v-if="!searchValue">
<div class="search-tips-item" v-if="historyList.length && isLogin"> <div class="search-tips-item" v-if="historyList.length && isLogin">
<h3 class="search-tips__title">搜索历史</h3> <h3 class="search-tips__title">搜索历史</h3>
<ul class="search-tips__list"> <ul class="search-tips__list">
<li <li v-for="(item, index) in historyList" :key="index" @click="changeSearchValue(item)">{{ item }}</li>
v-for="(item, index) in historyList"
:key="index"
@click="changeSearchValue(item)"
>{{item}}</li>
</ul> </ul>
</div> </div>
<div class="search-tips-item" v-if="featureList.length"> <div class="search-tips-item" v-if="featureList.length">
<h3 class="search-tips__title">搜索发现</h3> <h3 class="search-tips__title">搜索发现</h3>
<ul class="search-tips__list"> <ul class="search-tips__list">
<li <li v-for="(item, index) in featureList" :key="index" @click="changeSearchValue(item)">{{ item }}</li>
v-for="(item, index) in featureList"
:key="index"
@click="changeSearchValue(item)"
>{{item}}</li>
</ul> </ul>
</div> </div>
</div> </div>
<div class="search-main" v-if="searchValue"> <div class="search-main" v-if="searchValue">
<van-tabs <el-tabs v-model="tabActive" @tab-click="onTabClick">
class="main-tabs" <el-tab-pane label="考点" name="0">
v-model="tabActive"
color="#C62245"
:line-height="2"
:animated="true"
:swipeable="true"
@click="onTabClick"
>
<van-tab title="考点" name="0">
<tag-list :params="{ keywords: searchValue }" ref="list" v-if="tabActive === '0'"></tag-list> <tag-list :params="{ keywords: searchValue }" ref="list" v-if="tabActive === '0'"></tag-list>
</van-tab> </el-tab-pane>
<van-tab title="视频课程" name="1"> <el-tab-pane label="视频课程" name="1">
<video-list :params="{ keywords: searchValue }" ref="list" v-if="tabActive === '1'"></video-list> <video-list :params="{ keywords: searchValue }" ref="list" v-if="tabActive === '1'"></video-list>
</van-tab> </el-tab-pane>
<van-tab title="课程" name="2"> <el-tab-pane label="课程" name="2">
<course-list :params="{ keywords: searchValue }" ref="list" v-if="tabActive === '2'"></course-list> <course-list :params="{ keywords: searchValue }" ref="list" v-if="tabActive === '2'"></course-list>
</van-tab> </el-tab-pane>
</van-tabs> </el-tabs>
</div> </div>
</div> </div>
</template> </template>
...@@ -105,9 +88,10 @@ export default { ...@@ -105,9 +88,10 @@ export default {
}, },
changeSearchValue(value) { changeSearchValue(value) {
this.searchValue = value this.searchValue = value
this.$router.push({ query: { tab: this.tabActive, keywords: this.searchValue } })
}, },
onTabClick(name) { onTabClick() {
this.$router.replace({ query: { tab: name, keywords: this.searchValue } }) this.$router.replace({ query: { tab: this.tabActive, keywords: this.searchValue } })
}, },
onSearch() { onSearch() {
if (!this.searchValue.trim()) { if (!this.searchValue.trim()) {
...@@ -125,14 +109,23 @@ export default { ...@@ -125,14 +109,23 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.main-container {
height: 100%;
padding: 30px;
background-color: #fff;
border-radius: 8px;
box-sizing: border-box;
}
.search-tips-item { .search-tips-item {
clear: both; clear: both;
overflow: hidden; overflow: hidden;
} }
.search-tips__title { .search-tips__title {
font-size: 0.3rem; font-size: 18px;
font-weight: 400; font-weight: 400;
color: #222; color: #222;
padding-bottom: 8px;
border-bottom: 1px solid #ccc;
} }
.search-tips__list { .search-tips__list {
padding-top: 0.37rem; padding-top: 0.37rem;
...@@ -140,12 +133,13 @@ export default { ...@@ -140,12 +133,13 @@ export default {
.search-tips__list li { .search-tips__list li {
display: inline-block; display: inline-block;
max-width: 100%; max-width: 100%;
font-size: 0.26rem; font-size: 14px;
color: #999; color: #222;
margin-right: 0.4rem; margin-right: 20px;
margin-bottom: 0.4rem; margin-bottom: 20px;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
cursor: pointer;
} }
</style> </style>
...@@ -90,7 +90,7 @@ body { ...@@ -90,7 +90,7 @@ body {
background-color: #f9f9f9; background-color: #f9f9f9;
} }
.empty-tips { .empty {
padding: 120px; padding: 120px;
text-align: center; text-align: center;
font-size: 18px; font-size: 18px;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论