<template>
|
<div class="contentBox">
|
<div class="crumbs">
|
<el-breadcrumb separator-class="el-icon-arrow-right">
|
<el-breadcrumb-item :to="{ name: '/' }">首页</el-breadcrumb-item>
|
<el-breadcrumb-item>搜索结果</el-breadcrumb-item>
|
</el-breadcrumb>
|
</div>
|
<el-row>
|
<el-button
|
size="small"
|
:type="defaultType == 1 ? 'primary' : ''"
|
@click="switchType(1)"
|
>教学服务</el-button
|
>
|
<el-button
|
size="small"
|
:type="defaultType == 2 ? 'primary' : ''"
|
@click="switchType(2)"
|
>书城</el-button
|
>
|
</el-row>
|
<List
|
:channel="channel"
|
:searchFields="searchFields"
|
:searchValue="searchValue"
|
:detailRoute="detailRoute"
|
></List>
|
</div>
|
</template>
|
<script>
|
import List from "@/components/list/data";
|
export default {
|
name: "search",
|
components: {
|
List,
|
},
|
data() {
|
return {
|
searchFields: "",
|
detailRoute: "bookStore-detail",
|
channel: "caupress_bookMall",
|
defaultType: 2, // 默认搜索书城
|
searchValue: "",
|
};
|
},
|
created() {
|
this.searchValue = this.$route.query.searchValue;
|
},
|
methods: {
|
switchType(type) {
|
if (type == 1) {
|
this.defaultType = 1;
|
this.channel = "caupress_teachingResource";
|
this.detailRoute = "teachingServices-detail";
|
} else {
|
this.defaultType = 2;
|
this.channel = "caupress_bookMall";
|
this.detailRoute = "bookStore-detail";
|
}
|
},
|
},
|
watch: {
|
$route: {
|
handler: function (val, oldval) {
|
if (val.name == "search") {
|
if (this.searchValue != this.$route.query.searchValue) {
|
this.searchValue = this.$route.query.searchValue;
|
}
|
// 如果搜索的选项卡位于教学服务,则默认搜索教学服务
|
if (this.$route.query.searchPath == "caupress_teachingResource") {
|
this.switchType(1);
|
}
|
switch (this.$route.query.searchType) {
|
case "bookName":
|
this.searchFields = "Name";
|
break;
|
case "isbn":
|
this.searchFields = "caupress_ISBN";
|
break;
|
case "author":
|
this.searchFields = "caupress_author";
|
break;
|
case "projectTitle":
|
this.searchFields = "caupress_projectTitle";
|
break;
|
}
|
}
|
},
|
immediate: true,
|
deep: true,
|
},
|
},
|
// 如果跳转页面不是详情,则将当前页面不缓存
|
beforeRouteLeave(to, from, next) {
|
if (to.name != "teachingServices-detail" && to.name != "bookStore-detail") {
|
this.$store.commit("delKeepAlive", from.name);
|
}
|
next();
|
},
|
};
|
</script>
|
<style lang="less" scoped>
|
.contentBox {
|
padding-bottom: 120px;
|
|
.el-row {
|
margin-bottom: 10px;
|
}
|
|
.crumbs {
|
padding: 35px 0 25px 0;
|
line-height: 70px;
|
}
|
}
|
</style>
|