list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <template>
  2. <!-- 企业列表 company -->
  3. <main class="index_main" v-if="routeType == 6">
  4. <!-- 三农市场网-商城-资讯分类页 1-->
  5. <section class="index_1 clearfix phone_none">
  6. <div class="shop_head_1 clearfix">
  7. <div class="shop_head_1_name">{{ parent_name }}</div>
  8. </div>
  9. <div class="categ_color_box clearfix">
  10. <div class="categ_color_name clearfix">直达:</div>
  11. <div class="categ_color_in clearfix">
  12. <NuxtLink class="categ_color_a" :href="`/${item.aLIas_pinyin}/list-1.html`" :title="item.title"
  13. v-for="(item, index) in companyData" :key="index"
  14. :class="{ categ_color_a_only: navCid == item.cid }">
  15. {{ item.alias }}
  16. </NuxtLink>
  17. </div>
  18. </div>
  19. </section>
  20. <div class="phone_nav pc_none">
  21. <div class="phone_nav_in">
  22. <NuxtLink class="phone_nav_a" :href="`/${item.aLIas_pinyin}/list-1.html`"
  23. v-for="(item, index) in companyData" :key="index">
  24. {{ item.alias }}
  25. </NuxtLink>
  26. </div>
  27. </div>
  28. <!-- 三农市场网-商城-资讯分类页2 -->
  29. <!-- 三农市场网-商城-资讯列表 1-->
  30. <section class="clearfix">
  31. <div class="info_1_left">
  32. <div class="breadcrumb phone_none">
  33. <div class="inner">
  34. <span class="location">当前位置:</span>
  35. <el-breadcrumb :separator-icon="ArrowRight">
  36. <el-breadcrumb-item>
  37. <NuxtLink to="/">首页</NuxtLink>
  38. </el-breadcrumb-item>
  39. <el-breadcrumb-item v-if="p_parent_name != ''">
  40. <NuxtLink :to="`/${targetSegment}/index.html`"> {{ p_parent_name }}</NuxtLink>
  41. </el-breadcrumb-item>
  42. <el-breadcrumb-item v-if="parent_name != ''">
  43. <NuxtLink :to="`/${targetSegment}/${targetSegment1}/index.html`"> {{ parent_name }}
  44. </NuxtLink>
  45. </el-breadcrumb-item>
  46. <el-breadcrumb-item>{{ navTitle }}</el-breadcrumb-item>
  47. </el-breadcrumb>
  48. </div>
  49. </div>
  50. <div class="breadcrumb_box pc_none">
  51. <span class=" ">当前位置:</span>
  52. <NuxtLink to="/">首页</NuxtLink>
  53. <span class=" " v-if="p_parent_name != ''">&gt;</span>
  54. <NuxtLink :to="`/${targetSegment}/index.html`" v-if="p_parent_name != ''"> {{ p_parent_name }}</NuxtLink>
  55. <span class="" v-if="parent_name != ''">&gt;</span>
  56. <NuxtLink :to="`/${targetSegment}/${targetSegment1}/index.html`" v-if="parent_name != ''"> {{ parent_name }}</NuxtLink>
  57. <span class="" >&gt;</span>
  58. <span class="" >{{ navTitle }}</span>
  59. </div>
  60. <div class="info_ul_1 clearfix">
  61. <div class="info_li_1 clearfix" v-for="(item, index) in newsList" :key="index">
  62. <NuxtLink class="info_li_1_a dot1"
  63. :href="`/${targetSegment}/${targetSegment1}/${targetSegment2}/${item.id}.html`" title="">
  64. {{ item.title }}
  65. </NuxtLink>
  66. <time class="info_li_1_time phone_none">{{ getTime(item.updated_at, 'month', 1) }}</time>
  67. </div>
  68. <div class="empty" v-if="newsList == false">
  69. <img src="@/public/topic/empty.png" alt="" class="empty_img">
  70. <span class="empty_text">当前暂无数据</span>
  71. </div>
  72. </div>
  73. <!-- 分页器 -->
  74. <div class="pagination pagination_phone_none" v-if="newstotal">
  75. <el-pagination background layout="prev, pager, next" :total="newstotal" :page-size="pageSize_news"
  76. :current-page="page_news" prev-text="上一页" next-text="下一页" @current-change="changePage" />
  77. </div>
  78. <!-- 分页器 phone -->
  79. <div class="pagination pagination_pc_none" v-if="newstotal">
  80. <el-pagination size="small" background layout=" pager "
  81. :total="newstotal" class="mt-4" pager-count="5"
  82. :page-size="pageSize" :current-page="pageNum" @current-change="changePage" />
  83. </div>
  84. </div>
  85. <aside class="info_1_aside phone_none">
  86. <DetailHotNews></DetailHotNews>
  87. <DetailHotNews2></DetailHotNews2>
  88. </aside>
  89. </section>
  90. </main>
  91. </template>
  92. <script setup>
  93. //0.加载页面依赖 start ---------------------------------------->
  94. import { ref, onMounted } from 'vue';
  95. import { ElMessage, ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus';
  96. import { ArrowRight } from '@element-plus/icons-vue'
  97. import { NuxtLink } from '#components';
  98. //0.加载页面依赖 end ---------------------------------------->
  99. //1.获得路由id start ---------------------------------------->
  100. const targetSegment = getRoutePath(1);
  101. const targetSegment1 = getRoutePath(2);
  102. const targetSegment2 = getRoutePath(3);
  103. //1.1 获得当前的路由id
  104. let routeId;
  105. let routeType;
  106. let navTitle = ref('')//二级导航标题
  107. let navCid = ref('')//二级导航id
  108. //通过导航路径反向查询导航id
  109. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  110. method: 'GET',
  111. query: {
  112. 'pinyin': targetSegment + '/' + targetSegment1 + '/' + targetSegment2,
  113. },
  114. });
  115. console.log("getRouteId", getRouteId);
  116. if (getRouteId.code == 200) {
  117. navTitle.value = getRouteId.data.alias
  118. navCid.value = getRouteId.data.category_id
  119. } else {
  120. console.log("获得路由id出错!", getRouteId.message)
  121. }
  122. //1.2 获取二级栏目
  123. let parent_name = ref('');//父级名称
  124. let parent_id = ref('');//父级id
  125. let parent_pinyin = ref('');//父级拼音
  126. const getRoutePName = await requestDataPromise('/web/getWebsiteRoute', {
  127. method: 'GET',
  128. query: {
  129. 'pinyin': targetSegment + '/' + targetSegment1,
  130. },
  131. });
  132. console.log("getRoutePName", getRoutePName);
  133. if (getRoutePName.code == 200) {
  134. routeId = getRoutePName.data.category_id
  135. parent_id.value = getRoutePName.data.category_id
  136. parent_name.value = getRoutePName.data.alias
  137. routeType = getRoutePName.data.type
  138. } else {
  139. console.log("获得路由id出错!", getRoutePName.message)
  140. }
  141. //1.3 获取一级栏目
  142. let p_parent_name = ref('');//父级名称
  143. let p_parent_id = ref('');//父级id
  144. let p_parent_pinyin = ref('');//父级拼音
  145. const getRoutePName_parent = await requestDataPromise('/web/getWebsiteRoute', {
  146. method: 'GET',
  147. query: {
  148. 'pinyin': targetSegment,
  149. },
  150. });
  151. console.log("getRoutePName_parent", getRoutePName_parent);
  152. if (getRoutePName_parent.code == 200) {
  153. p_parent_id.value = getRoutePName_parent.data.category_id
  154. p_parent_name.value = getRoutePName_parent.data.alias
  155. // p_parent_pinyin.value = getRoutePName_parent.data.aLIas_pinyin
  156. } else {
  157. console.log("获得路由id出错!", getRoutePName_parent.message)
  158. }
  159. //1.4 获取某个栏目
  160. const getParentId = await requestDataPromise('/web/getOneWebsiteCategory', {
  161. method: 'GET',
  162. query: {
  163. 'catid': parent_id.value,
  164. },
  165. });
  166. console.log("getParentId", getParentId);
  167. if (getParentId.code == 200) {
  168. parent_pinyin.value = getParentId.data.aLIas_pinyin
  169. } else {
  170. console.log("获得路由id出错!", getParentId.message)
  171. }
  172. //1.获得路由id end ---------------------------------------->
  173. //2.分页 start ---------------------------------------->
  174. let changePage = (value) => {
  175. console.log("当前页码", value);
  176. navigateTo(`/${targetSegment}/${targetSegment1}/${targetSegment2}/list-${value}.html`)
  177. }
  178. //2.分页 end ---------------------------------------->
  179. //3.广告 start ---------------------------------------->
  180. let adImg1 = ref({})
  181. let adImg2 = ref({})
  182. onMounted(async () => {
  183. //从客户端获取行政职能部门 加快打开速度
  184. const { $webUrl, $CwebUrl } = useNuxtApp();
  185. //广告1
  186. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snscw_list_0001`
  187. const responseAd1 = await fetch(url, {
  188. headers: {
  189. 'Content-Type': 'application/json',
  190. 'Userurl': $CwebUrl,
  191. 'Origin': $CwebUrl
  192. }
  193. });
  194. const resultAd1 = await responseAd1.json();
  195. adImg1.value = resultAd1.data[0];
  196. //广告2
  197. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snscw_list_0002`
  198. const responseAd2 = await fetch(url2, {
  199. headers: {
  200. 'Content-Type': 'application/json',
  201. 'Userurl': $CwebUrl,
  202. 'Origin': $CwebUrl
  203. }
  204. });
  205. const resultAd2 = await responseAd2.json();
  206. adImg2.value = resultAd2.data[0];
  207. })
  208. //3.广告 end ---------------------------------------->
  209. //4.页面数据 start ---------------------------------------->
  210. const pageData = ref([
  211. //示例:
  212. // {
  213. // id: 1,
  214. // title: "", //该导航的标题
  215. // data: [], //数据1
  216. // data1: [], //数据2
  217. // data2: [], //数据3
  218. // data3: [], //数据4
  219. // data4: [], //数据5
  220. // category_id1: "", //子导航id1
  221. // category_id2: "",
  222. // category_id3: "",
  223. // category_id4: "",
  224. // title1: "", //子导航标题1
  225. // title2: "",
  226. // title3: "",
  227. // title4: "",
  228. // cid: "" //该导航的id
  229. // },
  230. ])
  231. const companyData = ref([])
  232. //4.1 获取所有导航
  233. try {
  234. const navigateData = await requestDataPromise('/web/getWebsiteModelCategory', {
  235. method: 'GET',
  236. query: {
  237. 'placeid': 1,
  238. 'pid': routeId,
  239. 'num': 8,
  240. 'type': 1
  241. },
  242. });
  243. // console.log('获取三级导航1111111', navigateData);
  244. if (navigateData.code == 200) {
  245. // 遍历可用的导航池放到页面中
  246. for (let index in navigateData.data) {
  247. let data = {
  248. title: navigateData.data[index].name,
  249. cid: navigateData.data[index].category_id,
  250. children_count: navigateData.data[index].children_count,
  251. alias: navigateData.data[index].alias,
  252. aLIas_pinyin: targetSegment + "/" + targetSegment1 + "/" + navigateData.data[index].aLIas_pinyin,
  253. type: navigateData.data[index].type,
  254. // data: [],
  255. // data1: [],
  256. // data2: [],
  257. // data3: [],
  258. // data4: [],
  259. // category_id1: "",
  260. // category_id2: "",
  261. // category_id3: "",
  262. // category_id4: "",
  263. // title1: "",
  264. // title2: "",
  265. // title3: "",
  266. // title4: ""
  267. };
  268. if (navigateData.data[index].is_url == 1) {
  269. // 处理 URL 的逻辑
  270. } else {
  271. if (navigateData.data[index].type == 6) {
  272. companyData.value.push(data);
  273. }
  274. //每个页面最多8个模块
  275. pageData.value.push(data);
  276. }
  277. }
  278. // console.log('获取三级导航pageData', pageData.value);
  279. // console.log('获取三级导航company', companyData.value);
  280. } else {
  281. console.log("错误:渲染8个模块环节出错,请检查是否存在没有数据的模块!")
  282. }
  283. } catch (error) {
  284. console.log("错误:导航池渲染执行接口出错!请检查频道页渲染的模块数据是否完整!")
  285. }
  286. // 获取企业数据列表 start--------------------------------------->
  287. const route = useRoute();
  288. const newsList = ref()
  289. const page_news = ref(1)
  290. const pageSize_news = ref(20)
  291. const newstotal = ref('')
  292. page_news.value = parseInt(route.params.id);
  293. const getNewsList = await requestDataPromise('/web/getWebsiteCompanyList', {
  294. method: 'GET',
  295. query: {
  296. 'page': page_news.value,
  297. 'pageSize': pageSize_news.value,
  298. 'category_id': navCid.value,
  299. },
  300. });
  301. console.log("获取企业列表company", getNewsList.data);
  302. if (getNewsList.code == 200) {
  303. newsList.value = getNewsList.data.data
  304. newstotal.value = getNewsList.data.count
  305. }
  306. // 获取企业数据 end----------------------------------------->
  307. //4.页面数据 end ---------------------------------------->
  308. //5.设置seo信息 start---------------------------------------->
  309. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  310. method: 'GET',
  311. query: {
  312. 'catid': navCid.value
  313. },
  314. });
  315. if (setData.code == 200) {
  316. let seoTitle = setData.data.seo_title;
  317. let seoDescription = setData.data.seo_description;
  318. let seoKeywords = setData.data.seo_keywords;
  319. let seoSuffix = setData.data.suffix;
  320. let seoName = setData.data.website_name;
  321. useSeoMeta({
  322. title: seoTitle + "_" + seoSuffix,
  323. meta: [
  324. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  325. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  326. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
  327. ]
  328. });
  329. } else {
  330. console.log("设置频道页SEO出错!", setData.message)
  331. }
  332. //5.设置seo信息 end---------------------------------------->
  333. </script>
  334. <style lang="less" scoped>
  335. @import url("@/assets/css/shop/newsList.less");
  336. @import url("@/assets/css/shop/goodsList.less");
  337. .empty {
  338. width: 100%;
  339. height: 300px;
  340. line-height: 300px;
  341. text-align: center;
  342. }
  343. .empty_img {
  344. vertical-align: -30px;
  345. margin-right: 20px;
  346. }
  347. .empty_text {
  348. font-size: 26px;
  349. color: #999;
  350. }
  351. .pagination {
  352. height: 100px;
  353. margin-top: 20px;
  354. }
  355. .pagination1 {
  356. height: 100px;
  357. margin-top: 20px;
  358. }
  359. </style>
  360. <style lang="less" scoped>
  361. @media screen and (min-width:801px){/*pc*/
  362. .index_2{overflow:hidden;}
  363. .pagination_pc_none {
  364. display: none !important;
  365. }
  366. .pc_none{display:none;}
  367. }
  368. @media screen and (max-width:800px){/*ipad_phone*/
  369. .index_main{ width: 100%; margin:0px auto 22px!important;}
  370. .phone_nav{
  371. width:100%; box-sizing:border-box;background:#fafafa;
  372. margin:10px auto;height:33px;
  373. .phone_nav_in{ width:92%;margin:0px auto;
  374. overflow-x:auto;overflow-y:hidden;
  375. word-break: keep-all; white-space: nowrap;
  376. line-height:33px;
  377. height:33px;
  378. }
  379. .phone_nav_in::-webkit-scrollbar{height:0px;}
  380. .phone_nav_a{display:inline-block;line-height:33px;height:33px;
  381. color:#333;font-size:14px;margin:0px 10px;
  382. }
  383. .phone_nav_a:nth-of-type(1){margin-left:0px;}
  384. }
  385. .phone_nav_a.router-link-exact-active{
  386. color:#255590;
  387. }
  388. .breadcrumb_box {
  389. height: 22px;
  390. width: 92%;
  391. margin: 10px auto;
  392. word-break: keep-all;
  393. white-space: nowrap;
  394. overflow: hidden;
  395. text-overflow: ellipsis;
  396. font-size: 14px;
  397. color: #666;
  398. * {
  399. font-size: 14px;
  400. display: inline;
  401. color: #666;
  402. line-height: 22px;
  403. height: 22px;
  404. margin-right: 5px;
  405. }
  406. }
  407. .info_1_left{width:100%;float:none;overflow:hidden;}
  408. .info_ul_1{
  409. width:92%;border-top: solid 1px #255590;
  410. padding-top: 10px;
  411. margin:0px auto 10px;
  412. min-height: 493px
  413. }
  414. .info_li_1{
  415. display: block;
  416. margin:0px!important;
  417. width: 100%;padding:0!important;}
  418. .info_li_1_a{display:block;width:100%;height:40px!important;
  419. line-height:40px!important;font-size:16px!important;
  420. font-weight:normal!important;max-width:100%!important;
  421. float:none!important;padding:0!important;
  422. }
  423. .info_ul_1 .info_li_1:nth-of-type(5n){
  424. padding-bottom:11px!important;margin-bottom:11px!important;
  425. }
  426. :deep(.pagination .el-pagination){
  427. margin:0px 4px;
  428. }
  429. :deep(.pagination){
  430. width:100%; margin-top:0px;
  431. height:34px;
  432. }
  433. .pagination_phone_none {
  434. display: none !important;
  435. }
  436. .phone_none{display:none;}
  437. }
  438. </style>