Преглед на файлове

修改搜索

修改搜索
dangyunlong преди 1 месец
родител
ревизия
8925456d4f
променени са 6 файла, в които са добавени 144 реда и са изтрити 90 реда
  1. 1 1
      .nuxt/manifest/latest.json
  2. 1 1
      .nuxt/manifest/meta/dev.json
  3. 3 3
      .nuxt/nitro.json
  4. 1 1
      assets/css/nav.less
  5. 22 18
      components/home/pageNavigation.vue
  6. 116 66
      pages/search/search.vue

+ 1 - 1
.nuxt/manifest/latest.json

@@ -1 +1 @@
-{"id":"dev","timestamp":1741738204586}
+{"id":"dev","timestamp":1741766035349}

+ 1 - 1
.nuxt/manifest/meta/dev.json

@@ -1 +1 @@
-{"id":"dev","timestamp":1741738204586,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
+{"id":"dev","timestamp":1741766035349,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}

+ 3 - 3
.nuxt/nitro.json

@@ -1,5 +1,5 @@
 {
-  "date": "2025-03-12T00:10:08.775Z",
+  "date": "2025-03-12T07:53:58.267Z",
   "preset": "nitro-dev",
   "framework": {
     "name": "nuxt",
@@ -9,9 +9,9 @@
     "nitro": "2.10.4"
   },
   "dev": {
-    "pid": 2116,
+    "pid": 3128,
     "workerAddress": {
-      "socketPath": "\\\\.\\pipe\\nitro\\worker-2116-1.sock"
+      "socketPath": "\\\\.\\pipe\\nitro\\worker-3128-1.sock"
     }
   }
 }

+ 1 - 1
assets/css/nav.less

@@ -255,7 +255,7 @@
                 height: 29px;
                 margin: 4px;
                 margin-right: 25px;
-                margin-left: 40px;
+                margin-left: 20px;
                 vertical-align: -13px;
                 background: url('../../public/image/Iconly/Broken/Search.png');
                 cursor: pointer;

+ 22 - 18
components/home/pageNavigation.vue

@@ -218,27 +218,31 @@ let goToPrimary = async () => {
         ElMessage.error('请选择行政区划或者职能部门!')
     }else{
 
-        const responseStatus =  await requestDataPromise('/web/selectWebsiteCategory', {
-        method: 'GET',
-            query: {
-                'cityid': getcityid.value,
-                'department_id': depValue.value
-            },
-        });
-
-        if (responseStatus.data.catid && responseStatus.data.catid.length > 0) {
-            const catids = responseStatus.data.catid.join(',');
-            const route = `/search/search?catids=${catids}`;
-            window.location.href = route;
-        } else {
-            // 可以在这里处理数组为空的情况
-            console.log('没有可用的分类ID');
-            const route = `/search/search`;
-            window.location.href = route;
-        }
+        // const responseStatus =  await requestDataPromise('/web/selectWebsiteCategory', {
+        // method: 'GET',
+        //     query: {
+        //         'cityid': getcityid.value,
+        //         'department_id': depValue.value
+        //     },
+        // });
+
+        // if (responseStatus.data.catid && responseStatus.data.catid.length > 0) {
+        //     const catids = responseStatus.data.catid.join(',');
+        //     const route = `/search/search?catids=${catids}`;
+        //     window.location.href = route;
+        // } else {
+        //     // 可以在这里处理数组为空的情况
+        //     console.log('没有可用的分类ID');
+        //     const route = `/search/search`;
+        //     window.location.href = route;
+        // }
+
+        const route = `/search/search?catids=${getcityid.value}&department_id=${depValue.value}`;
+        window.location.href = route;
 
     }
 }
+
 //5.执行搜索 end ---------------------------------------->
 </script>
 

+ 116 - 66
pages/search/search.vue

@@ -62,9 +62,12 @@
 import { ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus'
 import { ArrowRight } from '@element-plus/icons-vue'
 const route = useRoute();
-const category_id = route.query.category_id; //获得该页面的id
-const searchKey = route.query.keyword
-const catids = ref([]);
+const pageCatids = route.query.catids;
+const pageDepartment_id = route.query.department_id;
+
+//const category_id = route.query.category_id; //获得该页面的id
+// const searchKey = route.query.keyword
+// const catids = ref([]);
 
 //关键词
 let total = useState("total", () => 0)
@@ -91,88 +94,135 @@ getAdData();
 const newsList = ref([]);
 let keywordInput = ref("");
 
-//直接搜索
+//搜索
 let goSearch = async () => {
+    console.log(111222)
+    console.log(page.value)
+    console.log(pageSize.value)
+    console.log(keywordInput.value)
+    console.log(pageCatids)
+    console.log(pageDepartment_id)
     const listData =  await requestDataPromise('/web/getWebsiteArticleList', {
         method: 'GET',
         query: {
             'page': page.value,
             'pageSize': pageSize.value,
-            'keyword':keywordInput.value
+            'keyword':keywordInput.value,
+            'cityid':pageCatids,
+            'department_id':pageDepartment_id
         },
     });
+    console.log(112233)
+    console.log(listData)
     newsList.value = listData.data.rows;
     total.value = listData.data.count;
 }
 
+goSearch();
 //基于导航池搜索
-let goSearchFont = async (font) => {
-    const listData =  await requestDataPromise('/web/getWebsiteArticleList', {
-        method: 'GET',
-        query: {
-            'page': page.value,
-            'pageSize': pageSize.value,
-            'catid': font
-        },
-    });
-    newsList.value = listData.data.rows;
-    total.value = listData.data.count;
-}
-
-//基于导航池与关键词搜索
-let goSearchFontandCid = async (font) => {
-    const listData =  await requestDataPromise('/web/getWebsiteArticleList', {
-        method: 'GET',
-        query: {
-            'page': page.value,
-            'pageSize': pageSize.value,
-            'catid': category_id,
-            'keyword':searchKey
-        },
-    });
-    newsList.value = listData.data.rows;
-    total.value = listData.data.count;
-}
-
-const newslists = async () => {
-    try {
-        // 从地区跳转
-        if (route.query.catids && route.query.catids.length > 0) {
-            // 将字符串转换回数组,并过滤掉可能的空值
-            catids.value = route.query.catids.split(',').filter(id => id);
-
-            if (catids.value.length > 0) {
-                // 有效的 catids 数组,可以进行后续操作
-                console.log('接收到的分类ID数组:', catids.value);
-                let font = catids.value.join(",")
-                font = "[" + font + "]"
-
-                goSearchFont(font);
-            } else {
-                // 处理空数组情况
-                console.log('未接收到有效的分类ID');
-            }
-        } else {
-            if (category_id == undefined) {
-                //直接搜索 默认进来没有导航池的话 不执行搜索
-                //goSearch();
-            } else {
-                goSearchFontandCid();
-            }
-        }
-    } catch (error) {
-        console.error(error);
-    }
-}
-
-newslists();
+// let goSearchFont = async (font) => {
+//     const listData =  await requestDataPromise('/web/getWebsiteArticleList', {
+//         method: 'GET',
+//         query: {
+//             'page': page.value,
+//             'pageSize': pageSize.value,
+//             'catid': font
+//         },
+//     });
+//     newsList.value = listData.data.rows;
+//     total.value = listData.data.count;
+// }
+
+// //基于导航池与关键词搜索
+// let goSearchFontandCid = async (font) => {
+//     const listData =  await requestDataPromise('/web/getWebsiteArticleList', {
+//         method: 'GET',
+//         query: {
+//             'page': page.value,
+//             'pageSize': pageSize.value,
+//             'catid': category_id,
+//             'keyword':searchKey
+//         },
+//     });
+//     newsList.value = listData.data.rows;
+//     total.value = listData.data.count;
+// }
+
+
+//直接查新闻
+// const newslists = async () => {
+//     try {
+//         // 从地区跳转
+//         if (route.query.catids && route.query.catids.length > 0) {
+//             // 将字符串转换回数组,并过滤掉可能的空值
+//             catids.value = route.query.catids.split(',').filter(id => id);
+
+//             if (catids.value.length > 0) {
+//                 // 有效的 catids 数组,可以进行后续操作
+//                 console.log('接收到的分类ID数组:', catids.value);
+//                 let font = catids.value.join(",")
+//                 font = "[" + font + "]"
+
+//                 goSearchFont(font);
+//             } else {
+//                 // 处理空数组情况
+//                 console.log('未接收到有效的分类ID');
+//             }
+//         } else {
+//             if (category_id == undefined) {
+//                 //直接搜索 默认进来没有导航池的话 不执行搜索
+//                 goSearch();
+//             } else {
+//                 goSearchFontandCid();
+//             }
+//         }
+//     } catch (error) {
+//         console.error(error);
+//     }
+// }
+// newslists();
+
+
+// 查询导航池的方法
+// const newslists = async () => {
+//     try {
+//         // 从地区跳转
+//         if (route.query.catids && route.query.catids.length > 0) {
+//             // 将字符串转换回数组,并过滤掉可能的空值
+//             catids.value = route.query.catids.split(',').filter(id => id);
+
+//             if (catids.value.length > 0) {
+//                 // 有效的 catids 数组,可以进行后续操作
+//                 console.log('接收到的分类ID数组:', catids.value);
+//                 let font = catids.value.join(",")
+//                 font = "[" + font + "]"
+
+//                 goSearchFont(font);
+//             } else {
+//                 // 处理空数组情况
+//                 console.log('未接收到有效的分类ID');
+//             }
+//         } else {
+//             if (category_id == undefined) {
+//                 //直接搜索 默认进来没有导航池的话 不执行搜索
+//                 goSearch();
+//             } else {
+//                 goSearchFontandCid();
+//             }
+//         }
+//     } catch (error) {
+//         console.error(error);
+//     }
+// }
+
+// newslists();
 
 //分页事件
 let changePage = (value) => {
     console.log("当前页码", value);
     page.value = value
     console.log(page.value);
-    newslists()
+    goSearch()
 }
 //2.页面数据 end ---------------------------------------->