瀏覽代碼

完成首页封装

完成首页封装
dangyunlong 1 月之前
父節點
當前提交
1167247d62

+ 1 - 1
.nuxt/imports.d.ts

@@ -28,7 +28,7 @@ export { useRuntimeHook } from '#app/composables/runtime-hook';
 export { onBeforeRouteLeave, onBeforeRouteUpdate, useLink } from 'vue-router';
 export { withCtx, withDirectives, withKeys, withMemo, withModifiers, withScopeId, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, computed, customRef, isProxy, isReactive, isReadonly, isRef, markRaw, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, watch, watchEffect, watchPostEffect, watchSyncEffect, isShallow, effect, effectScope, getCurrentScope, onScopeDispose, defineComponent, defineAsyncComponent, resolveComponent, getCurrentInstance, h, inject, hasInjectionContext, nextTick, provide, mergeModels, toValue, useModel, useAttrs, useCssModule, useCssVars, useSlots, useTransitionState, useId, useTemplateRef, useShadowRoot, Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue';
 export { injectHead, useHead, useSeoMeta, useHeadSafe, useServerHead, useServerSeoMeta, useServerHeadSafe } from '@unhead/vue';
-export { requestData, requestDataPromise } from '../composables/getData';
+export { requestData, requestDataPromise, requestDataWebUrl } from '../composables/getData';
 export { getTime, getTitleLength } from '../composables/publicFunction';
 export { seoSetup } from '../composables/useSeo';
 export { default as proxy } from '../utils/proxy';

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

@@ -1 +1 @@
-{"id":"dev","timestamp":1740472205815}
+{"id":"dev","timestamp":1740529133238}

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

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

+ 3 - 3
.nuxt/nitro.json

@@ -1,5 +1,5 @@
 {
-  "date": "2025-02-25T08:30:16.154Z",
+  "date": "2025-02-26T00:19:04.085Z",
   "preset": "nitro-dev",
   "framework": {
     "name": "nuxt",
@@ -9,9 +9,9 @@
     "nitro": "2.10.4"
   },
   "dev": {
-    "pid": 15492,
+    "pid": 6260,
     "workerAddress": {
-      "socketPath": "\\\\.\\pipe\\nitro\\worker-15492-1.sock"
+      "socketPath": "\\\\.\\pipe\\nitro\\worker-6260-1.sock"
     }
   }
 }

+ 1 - 1
.nuxt/nuxt.d.ts

@@ -1,6 +1,6 @@
 // Generated by nuxi
-/// <reference types="@nuxt/devtools" />
 /// <reference types="@nuxt/telemetry" />
+/// <reference types="@nuxt/devtools" />
 /// <reference path="types/builder-env.d.ts" />
 /// <reference types="nuxt" />
 /// <reference path="types/app-defaults.d.ts" />

+ 2 - 0
.nuxt/types/imports.d.ts

@@ -91,6 +91,7 @@ declare global {
   const reloadNuxtApp: typeof import('../../node_modules/nuxt/dist/app/composables/chunk')['reloadNuxtApp']
   const requestData: typeof import('../../composables/getData')['requestData']
   const requestDataPromise: typeof import('../../composables/getData')['requestDataPromise']
+  const requestDataWebUrl: typeof import('../../composables/getData')['requestDataWebUrl']
   const requestIdleCallback: typeof import('../../node_modules/nuxt/dist/app/compat/idle-callback')['requestIdleCallback']
   const resolveComponent: typeof import('vue')['resolveComponent']
   const seoSetup: typeof import('../../composables/useSeo')['seoSetup']
@@ -285,6 +286,7 @@ declare module 'vue' {
     readonly reloadNuxtApp: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/composables/chunk')['reloadNuxtApp']>
     readonly requestData: UnwrapRef<typeof import('../../composables/getData')['requestData']>
     readonly requestDataPromise: UnwrapRef<typeof import('../../composables/getData')['requestDataPromise']>
+    readonly requestDataWebUrl: UnwrapRef<typeof import('../../composables/getData')['requestDataWebUrl']>
     readonly requestIdleCallback: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app/compat/idle-callback')['requestIdleCallback']>
     readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
     readonly seoSetup: UnwrapRef<typeof import('../../composables/useSeo')['seoSetup']>

+ 39 - 0
assets/css/foot.less

@@ -0,0 +1,39 @@
+.index_foot{box-sizing:border-box;width: 1200px;margin: 0 auto;}
+.index_foot_name_box{margin:40px auto 0px; text-align:center;font-size:0px;}
+.index_foot_name{display:inline-block;height:67px;line-height:67px;color:#f2f9f4;font-size:51px;font-weight:bold;overflow:hidden;}
+.index_foot_name:nth-of-type(even){color:#333;font-size:32px;}
+.foot_img_box{overflow:hidden;display:block;margin:40px auto 0;width:100%; }
+.foot_img_box>*{float: left;width:150px;height:50px;overflow:hidden;box-sizing:border-box;border:solid 1px #D7EDD4;margin:0px 25px 10px 0px;}
+.foot_img_box>* *{display: block;width:100%;height:100%;}
+.foot_img_box>*:nth-of-type(7n){margin-right:0px; }
+.foot_frind_box{ display:block;margin:11px auto;overflow:hidden;display:flex;width:100%;border-bottom:solid 2px #49A769;padding-bottom:35px;}
+.foot_frind_box span{word-break: keep-all; white-space: nowrap;line-height:22px;font-size:16px;color:#333;font-weight:bold;}
+.foot_frind_box div{width:100%;overflow:hidden; }
+.foot_frind_box div *{float:left;line-height:22px;height:22px;color:#333;font-size:16px;margin:0 30px;}
+.call_us_box{
+    display:block;width:100%;margin:40px auto 0;overflow:hidden;text-align:center;font-size:0px;background:#49A769; 
+    a {
+        color: #fff;
+    }
+}
+.call_us_box>*{height:12px;line-height:12px;color:#fff;font-size:14px;display:inline-block;box-sizing:border-box;padding:0 19px;font-weight:bold;border-left:solid 1px #5B8D54;margin:18px 0;}
+.call_us_box>*:nth-of-type(1){border-left:0px;}
+.foot_text_box{
+    margin:40px auto 0px;text-align:center;color:#333;font-size:14px;line-height:25px;
+    p {
+        a {
+            color: #333;
+            font-size: 14px;
+        }
+    }
+}
+.foot_text_box_green{color:#40663B;}   
+.foot_text_box img{display:inline-block;height:20px;vertical-align:middle;}   
+.foot_logo_out{position:relative;margin:0px auto;width:100%;height:0px;}
+.foot_logo_out *{width:120px;display:block; }
+.foot_logo_out>*{position:absolute;top:-166px;}
+.foot_logo_out>*:nth-of-type(1){left:0px;}
+.foot_logo_out>*:nth-of-type(2){right:0px;}               
+.foot_last_img_box {margin:40px auto 10px;text-align:center;overflow:hidden;width:100%;font-size:0px;padding-bottom: 40px;}
+.foot_last_img_box>*{height:50px;width:150px;margin:0px 12px;display:inline-block;overflow:hidden;}
+.foot_last_img_box>* *{display:block;height:100%;width:100%;overflow:hidden;}

+ 0 - 23
components/home/Advertising.vue

@@ -8,36 +8,13 @@
                 <img :src="imgurl.image_src" v-if="imgurl.image_src">
             </a>
         </div>
-        <p>{{ message }}</p>
     </div>
 </template>
 
 <script setup>
-import { onMounted } from 'vue'
-
-const nuxtApp = useNuxtApp();
-const axios = nuxtApp.$axios;
-
 const props = defineProps({
     imgurl: String
 });
-
-
-let image = useState("image", () => "")
-let getWebsiteAdvertisement = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteAdvertisement?adPlace=${9}`);
-        console.log(response);
-        image.value = response.data;
-    } catch (error) {
-        console.error(error);
-    }
-}
-
-onMounted(() => {
-    getWebsiteAdvertisement()
-})
-
 </script>
 
 <style lang="less">

+ 21 - 27
components/home/BigSwiper.vue

@@ -20,31 +20,33 @@
 
 <script setup>
 import { ElCarousel, ElCarouselItem } from 'element-plus'
-import { onMounted } from 'vue'
-
-const nuxtApp = useNuxtApp();
-const axios = nuxtApp.$axios;
-
+//获取焦点图数据 start---------------------------------------->
 let imagelist = useState("imageList", () => "")
-let lunbo = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${5}&level=${2}&placeid=${0}`);
-        // console.log(response.data);
-        imagelist.value = response.data;
-    } catch (error) {
-        console.error(error);
+async function getModelData1() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteArticlett', {
+        method: 'GET',
+        query: {
+            'pageSize': 5,
+            'level': 2,
+            'placeid': 0
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            //console.log('模块1数据上部分请求成功!', mkdata.value.data);
+            imagelist.value = mkdata.value.data;
+        }
     }
 }
-
-onMounted(() => {
-    lunbo()
-})
+getModelData1()
+//获取焦点图数据 end---------------------------------------->
 
 let currentIndex = ref(0)
 let handleIndicatorChange = (val) => {
     currentIndex.value = val
 }
-
 </script>
 
 <style lang="less" scoped>
@@ -54,13 +56,13 @@ let handleIndicatorChange = (val) => {
     position: relative;
 
     img {
-        width: 790px;
+        width: 720px;
         height: 405px;
     }
 
     span {
         display: inline-block;
-        width: 790px;
+        width: 720px;
         height: 118px;
         padding-top: 20px;
         padding-left: 23px;
@@ -77,40 +79,32 @@ let handleIndicatorChange = (val) => {
     }
 }
 
-
-
 .el-carousel {
-
     // 左右箭头按钮
     .el-carousel__arrow--right :deep(.class-name),
     .el-carousel__arrow--left :deep(.class-name) {
         width: 68px;
         height: 68px;
     }
-
     //左右箭头图片
     /deep/.el-icon svg {
         height: 1em;
         width: 1em;
         background-color: transparent;
     }
-
     /deep/.el-carousel__arrow {
         border-radius: 0;
         background-color: transparent;
     }
-
     /deep/.el-carousel__arrow i {
         font-size: 68px !important;
     }
-
     /deep/ .el-carousel__indicators {
         // 指示器
         left: unset;
         transform: unset;
         right: 41%;
     }
-
     /deep/ .el-carousel__button {
         // 指示器按钮
         width: 20px;

+ 18 - 16
components/home/BigTitle_List.vue

@@ -13,24 +13,26 @@
 </template>
 
 <script setup>
-import { ref, onMounted } from "vue"
-const nuxtApp = useNuxtApp();
-const axios = nuxtApp.$axios;
-//小头条
-const headlinelist1 = useState("headlinelist1", () => "");
-const headline1 = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${2}&level=${1}&placeid=${2}`);
-        console.log('headlinelist1', response.data);
-        headlinelist1.value = response.data;
-    } catch (error) {
-        console.error(error);
+const headlinelist1 = ref("")
+async function getModelData1() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteArticlett', {
+        method: 'GET',
+        query: {
+            'pageSize': 2,
+            'level': 1,
+            'placeid': 2
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            //console.log('模块1数据上部分请求成功!', mkdata.value.data);
+            headlinelist1.value = mkdata.value.data;
+        }
     }
 }
-onMounted(() => {
-    // 小标题
-    headline1()
-})
+getModelData1()
 </script>
 
 

+ 60 - 94
components/home/PageMessage.vue

@@ -2,7 +2,6 @@
 <template>
     <div class="message">
         <div class="inner">
-
             <!-- 大标题 -->
             <div class="bigTitle">
                 <div class="inner" v-for="(item, index) in headlinelist" :key="index">
@@ -17,33 +16,16 @@
                     </NuxtLink>
                 </div>
             </div>
-
             <!-- 大标题下的列表 -->
             <HomeBigTitleList></HomeBigTitleList>
-
-
             <div class="messageLeft">
                 <!-- 轮播图 -->
                 <HomeBigSwiper></HomeBigSwiper>
-
-                <!-- 小图列表 -->
-                <!-- <ul class="smallList">
-                    <li v-for="(item, index) in recommendImage" :key="index">
-                        <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
-                            <img :src="item.imgurl" alt="">
-                            <p>{{ item.title }}</p>
-                        </NuxtLink>
-                    </li>
-                </ul> -->
             </div>
-
             <div class="messageRight">
                 <!-- 列表 -->
                 <div class="hotTop">
-                    <h3>
-                        今日热点
-                        <!-- <span>查看更多</span> -->
-                    </h3>
+                    <h3>今日热点</h3>
                     <ul>
                         <li v-for="(item, index) in hotNewsList" :key="index">
                             <strong>{{ index + 1 }}</strong>
@@ -52,18 +34,6 @@
                         </li>
                     </ul>
                 </div>
-                <!-- <div class="suggest">
-                    <h3>
-                        资讯推荐
-                        
-                    </h3>
-                    <ul>
-                        <li v-for="(item, index) in messageList" :key="index">
-                            <em></em>
-                            <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">{{ item.title }}</NuxtLink>
-                        </li>
-                    </ul>
-                </div> -->
             </div>
         </div>
     </div>
@@ -75,71 +45,71 @@ import { ref, onMounted } from "vue"
 const nuxtApp = useNuxtApp();
 const axios = nuxtApp.$axios;
 
-//大头条
-const headlinelist = useState("headlinelist", () => "");
-const headline = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${1}&level=${1}&placeid=${0}`);
-        console.log('大标题', response.data);
-        headlinelist.value = response.data;
-    } catch (error) {
-        console.error(error);
-    }
-}
-
-//获取推荐图
-const recommendImage = useState("recommendImage", () => "");
-const recommendList = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${3}&level=${3}&placeid=${0}`);
-        // console.log(response.data);
-        recommendImage.value = response.data;
-    } catch (error) {
-        console.error(error);
+//1.获得板块数据 start ---------------------------------------->
+//大标题
+const headlinelist = ref("")
+async function getModelData1() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteArticlett', {
+        method: 'GET',
+        query: {
+            'pageSize': 1,
+            'level': 1,
+            'placeid': 0
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            //console.log('模块1数据上部分请求成功!', mkdata.value.data);
+            headlinelist.value = mkdata.value.data;
+        }
     }
 }
-
-
-//热点资讯
-const hotNewsList = useState("hotNews", () => "");
-const hotNews = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${8}&level=${4}&placeid=${0}`);
-        console.log('hotNewsList', response.data);
-        hotNewsList.value = response.data;
-    } catch (error) {
-        console.error(error);
+getModelData1()
+
+const recommendImage = ref("")
+async function getModelData2() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteArticlett', {
+        method: 'GET',
+        query: {
+            'pageSize': 3,
+            'level': 3,
+            'placeid': 0
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            //console.log('模块1数据上部分请求成功!', mkdata.value.data);
+            recommendImage.value = mkdata.value.data;
+        }
     }
 }
-
-//资讯推荐
-const messageList = useState("messagelist", () => "");
-const message = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${6}&level=${5}&placeid=${0}`);
-        // console.log(response.data);
-        messageList.value = response.data;
-    } catch (error) {
-        console.error(error);
+getModelData2()
+
+const hotNewsList = ref("")
+async function getModelData3() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteArticlett', {
+        method: 'GET',
+        query: {
+            'pageSize': 8,
+            'level': 4,
+            'placeid': 0
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            //console.log('模块1数据上部分请求成功!', mkdata.value.data);
+            hotNewsList.value = mkdata.value.data;
+        }
     }
 }
-
-
-
-onMounted(() => {
-    // 头条
-    headline()
-
-    //推荐图
-    recommendList()
-
-    // 热点资讯
-    hotNews()
-
-    //资讯推荐
-    message()
-})
-
+getModelData3()
+//1.获得板块数据 end ---------------------------------------->
 </script>
 
 <style lang="less" scoped>
@@ -355,16 +325,12 @@ onMounted(() => {
                 }
             }
         }
-
         .hotTop {
             width: 450px;
         }
-
         .suggest {
             margin-top: 32px;
         }
     }
-
-    
 }
 </style>

+ 62 - 178
components/home/Slider.vue

@@ -1,30 +1,21 @@
 <template>
-    <!-- 滑块 -->
-     <!-- v-if="navigation1[2]" -->
-    <div class="slider" v-if="navigation1[2]">
-        <!-- 标题部分 -->
-        <div class="scienceTitle" v-if="navigation1[2]">
-            <h5 v-if="navigation1[2].category_id">
+    <div class="slider" v-if="message">
+        <div class="scienceTitle" v-if="message">
+            <h5 v-if="message.cid">
                 <NuxtLink
-                    :to="{ path: `/newsList/${navigation1[2].category_id}`}"
-                    target="_blank" v-if="navigation1[2].category_id&&message.children_count!=0" class="active">
-                    {{navigation1[2].alias}}
+                    :to="{ path: `/newsList/${message.cid}`}"
+                    target="_blank" v-if="message.children_count!=0" class="active">
+                    {{message.title}}
                 </NuxtLink>
                 <NuxtLink
-                    :to="{ path: `/primaryNavigation/${navigation1[2].category_id}`}"
-                    target="_blank" v-else-if="navigation1[2].category_id&&message.children_count==0" class="active">
-                    {{navigation1[2].alias}}
+                    :to="{ path: `/primaryNavigation/${message.cid}`}"
+                    target="_blank" v-else-if="message.children_count==0" class="active">
+                    {{message.title}}
                 </NuxtLink>
             </h5>
-            <NuxtLink :to="`/newsList/${navigation1[2].category_id}`" target="_blank">
+            <NuxtLink :to="`/newsList/${message.cid}`" target="_blank">
                 查看更多
             </NuxtLink>
-            <!-- <span>查看更多</span> -->
-            <!-- <p class="title">
-                <span v-for="(item, index) in scienceTitleList" :key="index" @mousemove="changeUl(index)">
-                    <a href="#">{{ item.title }}</a>
-                </span>
-            </p> -->
         </div>
         <!-- 标题下内容列表 -->
         <div class="box">
@@ -35,7 +26,7 @@
                             <img :src="boxData1[0].imgurl">
                             <div>
                                 <p><span>专题</span>{{ boxData1[0].title }}</p>
-                                <span>{{ getDays(boxData1[0].created_at) }}</span>
+                                <span>{{getTime(boxData1[0].updated_at,'month',1)}}</span>
                             </div>
                         </NuxtLink>
                     </div>
@@ -43,15 +34,15 @@
                         <NuxtLink :to="`/newsDetail/${boxData1[1].id}`" target="_blank" class="imgbg">
                             <img :src="boxData1[1].imgurl">
                             <div>
-                                <p>{{ boxData1[1].title }}</p>
-                                <span>{{ getDays(boxData1[1].created_at) }}</span>
+                                <p>{{boxData1[1].title}}</p>
+                                <span>{{getTime(boxData1[1].updated_at,'month',1)}}</span>
                             </div>
                         </NuxtLink>
                         <NuxtLink :to="`/newsDetail/${boxData1[2].id}`" target="_blank" class="imgbg">
                             <img :src="boxData1[2].imgurl">
                             <div>
-                                <p>{{ boxData1[2].title }}</p>
-                                <span>{{ getDays(boxData1[2].created_at) }}</span>
+                                <p>{{boxData1[2].title}}</p>
+                                <span>{{getTime(boxData1[2].updated_at,'month',1)}}</span>
                             </div>
                         </NuxtLink>
                     </div>
@@ -59,8 +50,8 @@
                         <NuxtLink :to="`/newsDetail/${boxData1[3].id}`" target="_blank" class="imgbg">
                             <img :src="boxData1[3].imgurl">
                             <div>
-                                <p>{{ boxData1[3].title }}</p>
-                                <span>{{ getDays(boxData1[3].created_at) }}</span>
+                                <p>{{boxData1[3].title}}</p>
+                                <span>{{getTime(boxData1[3].updated_at,'month',1)}}</span>
                             </div>
                         </NuxtLink>
                     </div>
@@ -69,179 +60,72 @@
                    <ul>
                         <li v-for="item in boxData2">
                             <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
-                                <p class="title">{{ item.title }}</p>
-                                <p class="time">{{ getDays(item.created_at) }}</p>
+                                <p class="title">{{item.title}}</p>
+                                <p class="time">{{getTime(boxData1[3].updated_at,'month',1)}}</p>
                             </NuxtLink> 
                         </li>
                    </ul>
                 </div>
             </div>
-            <!-- <ul class="scienceList">
-                <li v-for="item in boxData2">
-                    <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
-                        <img :src="item.imgurl">
-                        <p>{{ item.title }}</p>
-                    </NuxtLink>
-                </li>
-            </ul> -->
-
-            <!-- <transition name="fade">
-                <div class="scienceListBox">
-                    <ul class="scienceList">
-                        <li v-for="item in boxData1">
-                            <NuxtLink
-                                :to="{ path: `/newsDetail/${item.id}`, query: { listId: routeId, listName: routeName } }"
-                                target="_blank">
-                                <img :src="item.imgurl">
-                                <p>{{ item.title }}</p>
-                            </NuxtLink>
-
-                        </li>
-                    </ul>
-                    <ul class="scienceList">
-                        <li v-for="item in 6">
-                            <img src="../../static/images/sgbhsihfgisdfaasda45632113_A_Chinese_farmer_carrying_a_hoe_is_h_1ba32eee-c498-4dd7-9cd9-013568c09db7.png"
-                                alt="">
-                            <p>市农业农村局关于印发连云港市市级…</p>
-                        </li>
-                    </ul>
-                    <ul class="scienceList">
-                        <li v-for="item in 6">
-                            <img src="../../static/images/rgmezdvz_19982_On_a_vast_and_boundless_wheat_field_many_harvest_5b5cfeda-ef17-4551-a935-5f8e3f799b69.png"
-                                alt="">
-                            <p>市农业农村局关于印发连云港市市级…</p>
-                        </li>
-                    </ul>
-                    <ul class="scienceList">
-                        <li v-for="item in 6">
-                            <img src="../../static/images/rgmezdvz_19982_A_Chinese_farmer_carrying_a_hoe_is_hoeing_the_fi_a036c7b3-b05e-4d3d-a371-0bed91ec1ff8(1).png"
-                                alt="">
-                            <p>市农业农村局关于印发连云港市市级…</p>
-                        </li>
-                    </ul>
-                </div>
-            </transition> -->
         </div>
     </div>
-
 </template>
 
 <script setup>
-
-const nuxtApp = useNuxtApp();
-const axios = nuxtApp.$axios;
-
-const radio1 = ref('1')
-
+//1.获得传入的数据 start---------------------------------------->
 const props = defineProps({
     message: Array,
 });
+//1.获得传入的数据 end---------------------------------------->
 
+//2.获得本页的数据 start---------------------------------------->
+const boxData1 = ref([]);
+const boxData2 = ref([]);
 
-//获取导航一的栏目
-const navigation1 = ref("");
-const navigateList = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteModelCategory?placeid=${1}&pid=${0}&num=${24}`);
-        console.log('一级导航', response.data);
-        navigation1.value = response.data;
-        getWebsiteModelArticles()
-        getWebsiteModelArticles2()
-    } catch (error) {
-        console.error(error);
-    }
-}
-
-const boxData1 = ref("");
-const getWebsiteModelArticles = async () => {
-    try {
-        // console.log(99999999);
-        // console.log(navigation1.value[2].category_id)
-        let cid = navigation1.value[2].category_id
-        const response = await axios.get(`/web/getWebsiteModelArticles?catid=${cid}&level=${1}&pagesize=${4}`);
-        boxData1.value = response.data;
-    } catch (error) {
-        console.error(error);
-    }
+if(props.message){
+    getPageData3()
+    getPageData1_data3()
 }
 
-const boxData2 = ref("");
-const getWebsiteModelArticles2 = async () => {
-    try {
-        // console.log(99999999);
-        // console.log(navigation1.value[2].category_id)
-        let cid = navigation1.value[2].category_id
-        const response = await axios.get(`/web/getWebsiteModelArticles?catid=${cid}&level=${3}&pagesize=${6}`);
-        boxData2.value = response.data;
-    } catch (error) {
-        console.error(error);
+//模块3 该模块是一个组件
+async function getPageData3() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteModelArticles', {
+        method: 'GET',
+        query: {
+            'catid': props.message.cid,
+            'level': 1,
+            'pagesize': 4
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        console.log(props.message.cid)
+        if (mkdata.value) {
+            //console.log('模块1数据上部分请求成功!', mkdata.value.data);
+            boxData1.value = mkdata.value.data;
+        }
     }
 }
-
-function getTime(time) {
-    const date = new Date(time);
-    const year = date.getFullYear();
-    const month = date.getMonth() + 1;
-    const day = date.getDate();
-    return `${year}-${month}-${day}`;
-}
-
-onMounted(() => {
-    // 一级导航
-    navigateList()
-
-})
-
-
-let scienceTitleList = [
-    {
-        id: 1,
-        title: "农产畅销"
-    },
-    {
-        id: 2,
-        title: "农业在线"
-    },
-    {
-        id: 3,
-        title: "农产行情"
-    },
-    {
-        id: 4,
-        title: "名优特产"
+async function getPageData1_data3() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteModelArticles', {
+        method: 'GET',
+        query: {
+            'catid': props.message.cid,
+            'level': 3,
+            'pagesize': 6
+        },
+    });
+    if (mkdataError.value) {
+        //console.log()
+    } else {
+        if (mkdata.value) {
+            //console.log()
+            boxData2.value = mkdata.value.data;
+        }
     }
-]
-
-
-//鼠标移入标题时,下方内容会发生变化
-// let changeUl = (index) => {
-//     // console.log(index);
-//     if (process.browser) {
-//         let scienceListBox = document.querySelector('.scienceListBox');
-//         let titleList = document.querySelectorAll('.title>span>a')
-//         for (let i = 0; i < titleList.length; i++) {
-//             titleList[i].className = ''
-//         }
-//         titleList[index].setAttribute('class', 'current')
-//         if (index == 0) {
-//             scienceListBox.style.left = 0
-//         } else if (index == 1) {
-//             scienceListBox.style.left = "-790px"
-//         } else if (index == 2) {
-//             scienceListBox.style.left = "-1580px"
-//         } else if (index == 3) {
-//             scienceListBox.style.left = "-2370px"
-//         }
-//     }
-// }
-function getDays(time) {
-    const date = new Date(time);
-    const year = date.getFullYear();
-    const month = date.getMonth() + 1;
-    const day = date.getDate();
-    return `${month}-${day}`;
 }
-
+//2.获得本页的数据 end---------------------------------------->
 </script>
 
 <style lang="less" scoped>

+ 86 - 88
components/home/foot.vue

@@ -53,67 +53,101 @@
 </template>
 
 <script setup>
-import { onMounted } from 'vue';
-const nuxtApp = useNuxtApp();
-const axios = nuxtApp.$axios;
+//获得底部基本信息 start---------------------------------------->
 
-// const props = defineProps({
-//     bottomLink: Array,
-//     bottomMenu: Array,
-//     bottomBase: Object
-// });
-
-//获得友情链接 图片
+//1.获得友情链接图片
 const bottomLink = ref([])
-const getBottomLink = async () => {
-    const response = await axios.get(`/web/selectWebsiteLinks?&type=${1}&num=${7}`);
-    bottomLink.value = response.data;
-    console.log(bottomLink.value)
+async function getModelData1() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/selectWebsiteLinks', {
+        method: 'GET',
+        query: {
+            'type':1,
+            'num':7,
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            bottomLink.value = mkdata.value.data;
+        }
+    }
 }
-//文字
+getModelData1();
+//2.获得友情链接文字
 const bottomText = ref([])
-const getBottomLink2 = async () => {
-    const response = await axios.get(`/web/selectWebsiteLinks?&type=${2}&num=${8}`);
-    bottomText.value = response.data;
-    console.log(bottomLink.value)
+async function getModelData2() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/selectWebsiteLinks', {
+        method: 'GET',
+        query: {
+            'type':2,
+            'num':8,
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            bottomText.value = mkdata.value.data;
+        }
+    }
 }
-//底部
+getModelData2();
+//3.获得底部图片
 const bottomphoto = ref([])
-const getBottomLink1 = async () => {
-    const response = await axios.get(`/web/selectWebsiteLinks?&type=${3}&num=${4}`);
-    bottomphoto.value = response.data;
-    console.log(bottomphoto.value)
+async function getModelData3() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/selectWebsiteLinks', {
+        method: 'GET',
+        query: {
+            'type':3,
+            'num':4,
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            bottomphoto.value = mkdata.value.data;
+        }
+    }
 }
-
-//获得底部导航
+getModelData3();
+//4.获得底部导航
 const bottomMenu = ref([])
-const getBottomMenu = async () => {
-    const response = await axios.get(`/web/getWebsiteFooterCategory`);
-    bottomMenu.value = response.data;
-    console.log(bottomMenu.value)
+async function getModelData4() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteFooterCategory', {
+        method: 'GET',
+        query: {
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            bottomMenu.value = mkdata.value.data;
+        }
+    }
 }
-
-//获得底部基本信息
+getModelData4();
+//5.获得底部基本信息
 const bottomBase = ref({})
-const getBottomBase = async () => {
-    const response = await axios.get(`/web/getWebsiteFootInfo`);
-    bottomBase.value = response.data.website_foot;
-    console.log(7777777)
-    console.log('bottomBase', bottomBase.value)
+async function getModelData5() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteFootInfo', {
+        method: 'GET',
+        query: {
+        },
+    });
+    if (mkdataError.value) {
+        //console.error('模块1数据上部分请求失败!', mkdataError.value);
+    } else {
+        if (mkdata.value) {
+            bottomBase.value = mkdata.value.data.website_foot;
+        }
+    }
 }
+getModelData5();
 
-
-onMounted(() => {
-    getBottomLink();
-    getBottomLink1();
-    getBottomLink2();
-    getBottomMenu();
-    getBottomBase();
-    //获取域名
-    getDomain()
-})
-
-//获取当前域名
+//6.获取当前域名
 const currentDomain = ref('')
 const currentDomainUrl = ref('')
 
@@ -124,46 +158,10 @@ const getDomain = () => {
         currentDomain.value = url.origin //协议和域名
     }
 }
+getDomain();
+//获得底部基本信息 end---------------------------------------->
 </script>
 
 <style lang="less" scoped>
-.index_foot{box-sizing:border-box;width: 1200px;margin: 0 auto;}
-.index_foot_name_box{margin:40px auto 0px; text-align:center;font-size:0px;}
-.index_foot_name{display:inline-block;height:67px;line-height:67px;color:#f2f9f4;font-size:51px;font-weight:bold;overflow:hidden;}
-.index_foot_name:nth-of-type(even){color:#333;font-size:32px;}
-.foot_img_box{overflow:hidden;display:block;margin:40px auto 0;width:100%; }
-.foot_img_box>*{float: left;width:150px;height:50px;overflow:hidden;box-sizing:border-box;border:solid 1px #D7EDD4;margin:0px 25px 10px 0px;}
-.foot_img_box>* *{display: block;width:100%;height:100%;}
-.foot_img_box>*:nth-of-type(7n){margin-right:0px; }
-.foot_frind_box{ display:block;margin:11px auto;overflow:hidden;display:flex;width:100%;border-bottom:solid 2px #49A769;padding-bottom:35px;}
-.foot_frind_box span{word-break: keep-all; white-space: nowrap;line-height:22px;font-size:16px;color:#333;font-weight:bold;}
-.foot_frind_box div{width:100%;overflow:hidden; }
-.foot_frind_box div *{float:left;line-height:22px;height:22px;color:#333;font-size:16px;margin:0 30px;}
-.call_us_box{
-    display:block;width:100%;margin:40px auto 0;overflow:hidden;text-align:center;font-size:0px;background:#49A769; 
-    a {
-        color: #fff;
-    }
-}
-.call_us_box>*{height:12px;line-height:12px;color:#fff;font-size:14px;display:inline-block;box-sizing:border-box;padding:0 19px;font-weight:bold;border-left:solid 1px #5B8D54;margin:18px 0;}
-.call_us_box>*:nth-of-type(1){border-left:0px;}
-.foot_text_box{
-    margin:40px auto 0px;text-align:center;color:#333;font-size:14px;line-height:25px;
-    p {
-        a {
-            color: #333;
-            font-size: 14px;
-        }
-    }
-}
-.foot_text_box_green{color:#40663B;}   
-.foot_text_box img{display:inline-block;height:20px;vertical-align:middle;}   
-.foot_logo_out{position:relative;margin:0px auto;width:100%;height:0px;}
-.foot_logo_out *{width:120px;display:block; }
-.foot_logo_out>*{position:absolute;top:-166px;}
-.foot_logo_out>*:nth-of-type(1){left:0px;}
-.foot_logo_out>*:nth-of-type(2){right:0px;}               
-.foot_last_img_box {margin:40px auto 10px;text-align:center;overflow:hidden;width:100%;font-size:0px;padding-bottom: 40px;}
-.foot_last_img_box>*{height:50px;width:150px;margin:0px 12px;display:inline-block;overflow:hidden;}
-.foot_last_img_box>* *{display:block;height:100%;width:100%;overflow:hidden;}
+    @import '@/assets/css/foot.less';
 </style>

+ 62 - 92
components/home/pageHead.vue

@@ -76,19 +76,14 @@
 </template>
 
 <script setup>
+//1.加载基本依赖 start ---------------------------------------->
 import { ref, onMounted, watch } from 'vue'
 import { ElPopover, ElDialog } from 'element-plus'
 import { getToken, setToken, removeToken } from '@/store/useCookieStore'
 import { setTicket, removeTicket } from '@/store/useticketStore'
-import { fa } from 'element-plus/es/locale/index.mjs';
-// import { navigateTo } from '@nuxtjs/composables';
-
-
-
-const nuxtApp = useNuxtApp();
-console.log("===:", nuxtApp) // 输出: someValue
-const axios = nuxtApp.$axios;
+//1.加载基本依赖 end ---------------------------------------->
 
+//1.登录逻辑 start ---------------------------------------->
 let ticket = ref('')
 let token = ref('')
 let route = useRoute()
@@ -101,24 +96,32 @@ if (token.value) {
     setToken(token.value)
 }
 
-
-console.log('查询参数:', ticket.value);
-console.log('查询参数:', token.value);
-
 definePageMeta({
     middleware: 'auth'
 });
 
+//搜索框
 let keyword = useState('keyword', () => '')
+//用户名
 let username = useState('username', () => '')
+//是否删除
 let isDel = useState('isDel', () => 1)
+//是否显示用户中心
 let isShow = useState('isShow', () => false)
 
+let token1 = useState("token1", () => '')
+let showToken = useState("showToken", () => '')
+token1.value = getToken()
+
+//检测登录状态
+let tokenStatus = ref('');
+tokenStatus.value = getToken()
+console.log(tokenStatus.value);
+
 //点击登录按钮
 let goLogin = () => {
     isDel.value = 0
     token1.value = getToken()
-    // window.location.href = ("http://adminpre.bjzxtw.org.cn/#/login?backurl=http%3a%2f%2fnwdev.bjzxtw.org.cn%2f")
     window.location.href = ("http://adminpre.bjzxtw.org.cn/auth/login.php?backurl=http://nwpre.bjzxtw.org.cn")
     token1.value = getToken()
     // navigateTo.back()
@@ -130,6 +133,7 @@ let goRegister = () => {
     dialogTableVisible.value = true
 }
 
+//点击用户中心
 let userCenter = () => {
     if(isShow.value){
         isShow.value = false
@@ -140,59 +144,77 @@ let userCenter = () => {
     }
 }
 
+//获取用户登录信息
+let getUserInfo = async () => {
+    const responseStatus =  await requestDataPromise('/user/getUserInfo', {
+        method: 'GET',
+        query: {},
+    });
+    console.log('用户信息:', responseStatus);
+    //如果能拿到信息,就赋值给username
+    if(responseStatus.data){
+        username.value = responseStatus.data.nickname
+    }
+}
+getUserInfo();
 
+//获取登录状态
+let getLoginStatus = async () => {
+    const responseStatus =  await requestDataWebUrl('http://nwpre.bjzxtw.org.cn/auth/loginstatus.php', {
+        method: 'GET',
+        query: {
+            'token': tokenStatus
+        },
+    });
+    console.log('登录状态', responseStatus);
+    if(responseStatus.data.code == 200){
+        if(responseStatus.data.data.islogin == true){
+            showToken.value = true 
+        }else{
+            showToken.value = false
+            exit()
+        }
+    }else if(responseStatus.data.code == 0){
+        //退出登录
+        exit();
+    }
+}
+getLoginStatus();
+
+//2.登录逻辑 end ---------------------------------------->
+
+
+
+//3.跳转菜单逻辑 start ---------------------------------------->
 let gotosystem = () => {
     window.location.href = ("http://adminpre.bjzxtw.org.cn/#/login?userurl=http://nwpre.bjzxtw.org.cn")
-    // window.location.href = ("http://adminpre.bjzxtw.org.cn/#/dashboard")
 }
 
 //点击退出按钮
 let exit = () => {
     window.location.href = ('http://nwpre.bjzxtw.org.cn/')
-    // console.log('退出1111111111111111111111');
 
     isDel.value = 1
     token1.value = getToken()
-    // const currentUrl = window.location.href;
-    // console.log('currentUrl', currentUrl);
-
-    // // 查找参数部分起始位置(?符号位置)
-    // const index = currentUrl.indexOf('?');
-    // if (index !== -1) {
-    //     // 截取去除参数后的URL
-    //     var newUrl = currentUrl.slice(0, index);
-    //     // 重新加载页面(赋值给location.href会触发页面刷新)
-    //     window.location.href = newUrl;
-    // }
-    // axios.get(`http://adminpre.bjzxtw.org.cn/auth/logoutapi.php?token=${token}`).then(response => {
-    //     console.log("退出登录", response);
-    //     isDel.value = response.data.isDel
-    // })
+
     window.location.href = (`http://adminpre.bjzxtw.org.cn/auth/logout.php?backurl=http://nwpre.bjzxtw.org.cn&admintoken=${token1}`)
     removeToken()
     removeTicket()
 }
 
+//点击返回首页
 let backHome = () => {
-    // window.location.href = ('http://localhost:3000/')
     window.location.href = ('http://nwpre.bjzxtw.org.cn/')
 }
 
 //点击搜索按钮
 let goSearch = () => {
-    // navigateTo({
-    //     path: '/search/search',
-    //     query: {
-    //         keyword: keyword.value
-    //     }
-    // })
     const route = `/search/search?keyword=${keyword.value}`;
     window.open(route, '_blank');
 }
 
 // 点击广告服务
 let goAdvertising = () => {
-    // window.open(`http://localhost:3000/advertising?activeName=${1}`, '_blank');
     if (getToken()) {
         window.open(`http://nwpre.bjzxtw.org.cn/advertising?activeName=${1}`, '_blank');
     } else {
@@ -202,7 +224,6 @@ let goAdvertising = () => {
 
 //点击商圈
 let goTopic = () => {
-    // window.open(`http://localhost:3000/topic`, '_blank');
     if (getToken()) {
         window.open('http://nwpre.bjzxtw.org.cn/topic', '_blank');
     } else {
@@ -210,23 +231,7 @@ let goTopic = () => {
     }
 }
 
-
-//获取用户信息
-let getUserInfo = async () => {
-    try {
-        const response = await axios.get("/user/getUserInfo");
-        console.log('获取用户信息', response);
-        username.value = response.data.nickname
-
-    } catch (error) {
-        console.error(error);
-    }
-}
-
-let token1 = useState("token1", () => '')
-let showToken = useState("showToken", () => '')
-token1.value = getToken()
-
+//监听token状态
 watch(token1, (newval, oldval) => {
     console.log(newval, oldval);
     showToken.value = newval
@@ -234,42 +239,7 @@ watch(token1, (newval, oldval) => {
     deep: true,
     immediate: true,
 })
-
-onMounted(() => {
-
-    //获取用户信息
-    //getUserInfo()
-
-    //获取登录状态
-    //getLoginStatus()
-})
-
-//检测登录状态
-//http://adminpre.bjzxtw.org.cn/auth/loginstatus.php?token=XXXXXXXXXXXX
-let tokenStatus = ref('');
-tokenStatus.value = getToken()
-console.log(tokenStatus.value);
-//获取用户信息
-let getLoginStatus = async () => {
-    try {
-        const response = await axios.get(`http://nwpre.bjzxtw.org.cn/auth/loginstatus.php?token=${tokenStatus}`);
-        console.log('登录状态', response);
-        if(response.data.code == 200){
-            if(response.data.data.islogin == true){
-                showToken.value = true 
-            }else{
-                showToken.value = false
-                exit()
-            }
-        }else if(response.data.code == 0){
-            //退出登录
-            exit();
-        }
-    } catch (error) {
-        console.error(error);
-    }
-}
-
+//3.跳转菜单逻辑 end ---------------------------------------->
 </script>
 
 <style lang="less" scoped>

+ 116 - 234
components/home/pageNavigation.vue

@@ -1,9 +1,7 @@
 <template>
-    <!-- 导航 -->
     <div class="navigate">
         <div class="partOne">
             <div class="inner">
-                <!-- 导航一 -->
                 <div class="navLeft">
                     <div class="navIndex">
                         <NuxtLink to="/" target="_blank" title="首页">
@@ -21,14 +19,11 @@
                 </div>
                 <ul class="navigationOne">
                     <li v-for="(item, index) in navigation1" :key="index">
-                        <!-- <NuxtLink :to="`/primaryNavigation/${item.alias}`" target="_blank">{{ item.alias }}</NuxtLink> -->
-                        <!-- <NuxtLink :to="{ path: `/primaryNavigation/${item.category_id}`, query: { name: item.name } }" -->
                         <NuxtLink :to="{ path: `/primaryNavigation/${item.category_id}`}"
                             target="_blank" v-if="item.children_count != 0">
                             <span class="active" v-if="item.category_id == routeId">{{ item.name }}</span>
                             <span v-else>{{ item.name }}</span>
                         </NuxtLink>
-                        <!-- <NuxtLink :to="{ path: `/newsList/${item.category_id}`, query: { name: item.name } }" -->
                         <NuxtLink :to="{ path: `/newsList/${item.category_id}` }"
                             target="_blank" v-if="item.children_count == 0 && item.is_url != 1">
                             <span class="active" v-if="item.category_id == routeId">{{ item.name }}</span>
@@ -43,28 +38,6 @@
                 </ul>
             </div>
         </div>
-
-
-        <!-- <div class="partThree">
-            地方频道
-            <div class="inner">
-                channel 频道
-                <h5 class="channel">地方频道</h5>
-                <p class="areaChannel">
-                    <span v-for="(item, index) in areaList" :key="index">
-                        <a href="#">{{ item.name }}</a>
-                    </span>
-                </p>
-            </div>
-        </div> -->
-
-        <!-- 导航栏下的大图 -->
-        <!-- <div class="logo">
-            <div class="inner">
-                <img src="../../static/image/banner1.png" alt="">
-            </div>
-        </div> -->
-
         <!-- 展示地区 -->
         <div class="cityBox">
             <div class="cityMain">
@@ -73,15 +46,11 @@
                 </div>
                 <ul class="cityList">
                     <li v-for="(item, index) in provinceList" :key="index" @click="goToSearch(item.id)">
-                        <!-- <NuxtLink :to="{path:`/search/search?catids=${item.id}`}" target="_blank">
-                            {{item.abbreviation}}
-                        </NuxtLink> -->
                         {{item.abbreviation}}
                     </li>
                 </ul>
             </div>
         </div>
-
         <!-- 行政查询 -->
         <div class="select">
             <div class="inner">
@@ -125,136 +94,130 @@
 </template>
 
 <script setup>
+//1.加载依赖 start ---------------------------------------->
 import { ElMessage } from 'element-plus'
-
 import { ref, onMounted } from 'vue';
 import { ElSelect, ElOption } from 'element-plus'
+
 const nuxtApp = useNuxtApp();
 const axios = nuxtApp.$axios;
-//获得route
+
 const route = useRoute();
 const routeId = route.params.id; //获得该页面的id
-const pageName = route.query.name;//获得页面名称
+//1.加载依赖 end ---------------------------------------->
 
-//获取导航一的栏目
+//2.加载模块数据 start ---------------------------------------->
 const navigation1 = ref("");
-const navigateList = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteModelCategory?placeid=${1}&pid=${0}&num=${35}`);
-        console.log(response.data);
-        navigation1.value = response.data;
-    } catch (error) {
-        console.error(error);
-    }
-}
-
-// const navigateList = async () => {
-//     try {
-//         const response = await axios.get(`/web/getWebsiteCategory?pageSize=${24}`);
-//         console.log(response.data);
-//         navigation1.value = response.data;
-//     } catch (error) {
-//         console.error(error);
-//     }
-// }
-
-//获取导航二的栏目
-const navigation2 = ref("");
-const navigate2List = async () => {
-    try {
-        const response = await axios.get(`/web/getWebsiteModelCategory?placeid=${2}&pid=${1}&num=${13}`);
-        // console.log(response.data);
-        navigation2.value = response.data;
-    } catch (error) {
-        console.error(error);
+async function getPageData2() {
+    const { data: mkdata, error: mkdataError } =  requestData('/web/getWebsiteModelCategory', {
+        method: 'GET',
+        query: {
+            'placeid': 1,
+            'pid': 0,
+            'num': 35
+        },
+    });
+    if (mkdataError.value) {
+       //console.log()
+    } else {
+        if (mkdata.value) {
+            navigation1.value = mkdata.value.data;
+        }
     }
 }
+getPageData2();
+//2.加载模块数据 end ---------------------------------------->
 
-//职能部门 搜索
+//3.职能部门 start ---------------------------------------->
 let department = ref("安全")
 const depValue = ref("")
 const typeValue = ref("")
 let departmentList = async () => {
-    try {
-        const response = await axios.get(`/web/selectWebsiteDepartment?keyword=${department.value}`);
-        // console.log(response.data.department);
-        department.value = response.data.department
-        // console.log(department.value);
-    } catch (error) {
-        console.error(error);
+    const { data: mkdata, error: mkdataError } =  requestData('/web/selectWebsiteDepartment', {
+        method: 'GET',
+        query: {
+            'keyword': department.value,
+        },
+    });
+    if (mkdataError.value) {
+       //console.log()
+    } else {
+        console.log(department.value)
+        if (mkdata.value) {
+            console.log(mkdata.value.data.department)
+            department.value = mkdata.value.data.department;
+        }
     }
 }
+//获得所有部门
+departmentList();
+//3.职能部门 end ---------------------------------------->
 
-
-//获取地区各省名称
+//4.展示行政区划 start ---------------------------------------->
 let areaList = ref("")
-//获取省名称
-let province = useState("province", () => "")
-let provinceid = useState("provinceid", () => null)
-let provinceList = useState("provinceList", () => "")
+//4.1 省
+let province = ref("")
+let provinceid = ref("")
+let provinceList = ref("")
+//4.2 市
+let city = ref("")
+let cityid = ref("")
+let cityList = ref("")
+//4.3 县
+let region = ref("")
+let regionid = ref("")
+let regionList = ref("")
+
+//选择省
 let areaArrList = async () => {
-    try {
-        const response = await axios.get('/web/getWebsiteDistrit');
-        console.log(response.data);
-        areaList.value = response.data;
-        provinceList.value = response.data
-    } catch (error) {
-        console.error(error);
+    const { data: mkdata, error: mkdataError } =  requestData('/web/selectWebsiteArea', {
+        method: 'GET',
+        query: {},
+    });
+    if (mkdataError.value) {
+       //console.log()
+    } else {
+        console.log(department.value)
+        if (mkdata.value) {
+            console.log(mkdata.value)
+            areaList.value = mkdata.value.data;
+            provinceList.value = mkdata.value.data;
+        }
     }
 }
-
-// 获取城市名称
-let city = useState("city", () => "")
-let cityid = useState("cityid", () => "")
-let cityList = useState("cityList", () => "")
-
-//选择省份后省份的id
-let change = (id) => {
-    console.log(id);
-    provinceid.value = id
-    console.log(provinceid.value);
-
-    //根据省id获取对应的市名称
-    axios.get(`web/selectWebsiteArea?province=${provinceid.value}&city=0`).then(response => {
-        // console.log("response", response.data.city);
-        cityList.value = response.data.city;
-        // console.log("cityList", cityList.value);
-    }).catch(error => {
-        console.error(error);
-    })
-
+//一开始只需要获取一下省
+areaArrList();
+
+//选择市
+let change = async (id) => {
+    provinceid.value = id;
+    const shengData =  await requestDataPromise('/web/selectWebsiteArea', {
+        method: 'GET',
+        query: {
+            'province': id,
+            'city': 0
+        },
+    });
+    cityList.value = shengData.data.city;
 }
 
-// 获取区/县名称
-let region = useState("region", () => "")
-let regionid = useState("regionid", () => "")
-let regionList = useState("regionList", () => "")
-
-//选择市后市的id
-let change1 = (id) => {
-    console.log(id);
-    cityid.value = id
-    console.log(cityid.value);
-
-    //根据市id获取对应的区/县名称
-    axios.get(`web/selectWebsiteArea?province=${provinceid.value}&city=${cityid.value}`).then(response => {
-        // console.log("response", response.data);
-        regionList.value = response.data.region;
-        // console.log("regionList", regionList.value);
-    }).catch(error => {
-        console.error(error);
-    })
+//选择县
+let change1 = async (id) => {
+    cityid.value = id;
+    const xianData =  await requestDataPromise('/web/selectWebsiteArea', {
+        method: 'GET',
+        query: {
+            'province': provinceid.value,
+            'city': cityid.value
+        },
+    });
+    regionList.value = xianData.data.region;
 }
+//4.展示行政区划 end ---------------------------------------->
 
-//depValue.value 行政区划
-//二级导航id
-//province.value 省id
-//city.value 市id
-//region.value 县id
+//5.执行搜索 start ---------------------------------------->
 const getcityid = ref("")
-
-
-
+//跳转到搜索页面
 let goToSearch = (id) => {
     console.log(id)
     const route = `/search/search?catids=${id}`;
@@ -262,55 +225,41 @@ let goToSearch = (id) => {
 }
 
 //获得cityid和
-let goToPrimary = () => {
-    // console.log(depValue.value)
-    // console.log(routeId)
+let goToPrimary = async () => {
     if (province.value != "") { getcityid.value = province.value }
     if (city.value != "") { getcityid.value = city.value }
     if (region.value != "") { getcityid.value = region.value }
-    console.log(getcityid.value)
-    //console.log(pageName)
-
-    //跳转过去
-    // navigateTo({
-    //     path: `/primaryNavigation/${routeId}`,
-    //     query: {
-    //         cityid: getcityid.value,
-    //         name: pageName,
-    //         department_id: depValue.value
-    //     }
-    // })
 
     if (province.value == ""&&city.value == ""&&region.value == ""&&depValue.value=="") {
         ElMessage.error('请选择行政区划或者职能部门!')
     }else{
-        //根据市id获取对应的区/县名称
-        axios.get(`/web/selectWebsiteCategory?cityid=${getcityid.value}&department_id=${depValue.value}`).then(response => {
-            if (response.data.catid && response.data.catid.length > 0) {
-                const catids = response.data.catid.join(',');
-                const route = `/search/search?catids=${catids}`;
-                window.open(route, '_blank');
-            } else {
-                // 可以在这里处理数组为空的情况
-                console.log('没有可用的分类ID');
-                const route = `/search/search`;
-                window.open(route, '_blank');
-            }
 
-        })
-    }
-        
+        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.open(route, '_blank');
+        } else {
+            // 可以在这里处理数组为空的情况
+            console.log('没有可用的分类ID');
+            const route = `/search/search`;
+            window.open(route, '_blank');
+        }
 
+    }
 }
 
 let searchDepartment = () => {
     //搜索职能部门
-    //console.log(typeValue.value)
-    //console.log(department.value)
     let status = false;
     for (let item of department.value) {
         if (item.name == typeValue.value) {
-            console.log(item.name)
             //如果有就赋值过去
             depValue.value = item.id
             status = true; //说明有可用的结果
@@ -320,25 +269,7 @@ let searchDepartment = () => {
         //弹出提示告诉用户不存在
     }
 }
-
-//挂载成功钩子函数
-onMounted(() => {
-    //导航一栏目
-    navigateList()
-
-    //导航二栏目
-    navigate2List()
-
-    //获取地区各省名称
-    areaArrList()
-
-    //获取职能部门
-    departmentList()
-
-
-})
-
-
+//5.执行搜索 end ---------------------------------------->
 </script>
 
 <style lang="less" scoped>
@@ -404,8 +335,6 @@ onMounted(() => {
         flex-wrap: wrap;
         padding-top: 20px;
         
-        //justify-content: space-around;
-
         li {
             width: 68px;
             font-family: PingFang SC;
@@ -419,9 +348,6 @@ onMounted(() => {
             margin: 0 10px;
             text-align: center;
 
-            // &:nth-last-child(1) {
-            //     margin-right: 0px;
-            // }
 
             a {
                 color: #fff;
@@ -435,44 +361,10 @@ onMounted(() => {
 
         .active{
             color: #ABE874;
-            // display: inline-block;
-            // height: 50px;
-            // border-bottom: 2px solid #139602
         }
     }
 }
 
-// .partTwo {
-//     width: 100%;
-//     height: 57px;
-//     line-height: 57px;
-//     border-bottom: 1px solid #e3e3e3;
-
-//     .navigationTwo {
-//         width: 1207px;
-//         height: 57px;
-//         color: #333333;
-//         border-bottom: 1px solid #e3e3e3;
-
-//         li {
-//             font-weight: 600;
-//             font-size: 20px;
-//             height: 56px;
-//             margin-right: 21px;
-
-//             &:nth-last-child(1) {
-//                 margin-right: 0px;
-//             }
-//         }
-
-//         li:hover {
-//             color: #139602;
-//             border-bottom: 2px solid #139602;
-//         }
-
-//     }
-// }
-
 .partThree {
     width: 100%;
     height: 105px;
@@ -569,9 +461,6 @@ onMounted(() => {
         height: 62px;
         margin-top: 10px;
         background-color: #fafafa;
-
-        
-        
     }
 
     .role,
@@ -743,13 +632,6 @@ onMounted(() => {
                 &:hover {
                     color: #ABE874;
                 }
-                // a {
-                //     color: #fff;
-                //     margin-right: 14px;
-                //     &:hover {
-                //         color: #ABE874;
-                //     }
-                // }
             }
         }
     }

+ 42 - 1
composables/getData.js

@@ -74,4 +74,45 @@ function requestDataPromise(url, options = {}) {
     });
 }
 
-export { requestData, requestDataPromise };
+// requestDataWebUrl 请求非本网地址时 使用这个方法
+function requestDataWebUrl(url, options = {}) {
+    return new Promise(async (resolve, reject) => {
+        let fullUrl = `${url}`;
+
+        // 生成唯一的 key
+        const key = `${url}-${JSON.stringify(options.query || options.body)}`;
+
+        // 设置默认的请求头
+        const headers = {
+            'Content-Type': 'application/json',
+            'Userurl': 'nwpre.bjzxtw.org.cn',
+            'token': getToken(),
+            'Origin': 'http://nwpre.bjzxtw.org.cn',
+        };
+
+        // 确定请求方法
+        const method = options.method || 'GET';
+
+        try {
+            // 使用 useAsyncData 进行数据获取
+            const { data, error } = await useAsyncData(key, () => {
+                return $fetch(fullUrl, {
+                    method,
+                    headers,
+                    body: method === 'POST' ? options.body : undefined, // 仅在 POST 请求时设置 body
+                    query: method === 'GET' ? options.query : undefined, // 仅在 GET 请求时设置 query
+                });
+            }, { lazy: true }); // 禁用缓存
+
+            if (error.value) {
+                reject(error.value); // 如果有错误,拒绝 Promise
+            } else {
+                resolve(data.value); // 如果成功,返回数据
+            }
+        } catch (err) {
+            reject(err); // 捕获异常并拒绝 Promise
+        }
+    });
+}
+
+export { requestData, requestDataPromise ,requestDataWebUrl };

+ 4 - 0
composables/publicFunction.ts

@@ -15,6 +15,10 @@ const getTime = function(time:string,type:string,style:Number){
   if(type == 'year'&& style == 2){
     return `${year}-${month}`;
   }
+  //返回 年
+  if(type == 'year'&& style == 3){
+    return `${year}`;
+  }
   //返回 月-日
   if(type == 'month'&& style == 1){
     return `${month}-${day}`;

文件差異過大導致無法顯示
+ 567 - 406
pages/index.vue


部分文件因文件數量過多而無法顯示