From ef37c59e055a990ce247b265b27d3fcef430a243 Mon Sep 17 00:00:00 2001
From: 杨磊 <505174330@qq.com>
Date: 星期五, 15 八月 2025 10:19:18 +0800
Subject: [PATCH] first submit

---
 src/views/home/search.vue |  116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/src/views/home/search.vue b/src/views/home/search.vue
new file mode 100644
index 0000000..5852706
--- /dev/null
+++ b/src/views/home/search.vue
@@ -0,0 +1,116 @@
+<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>

--
Gitblit v1.9.1