list_one.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <HomePageHead></HomePageHead>
  3. <HomePageNavigation></HomePageNavigation>
  4. <HomeAdvertising :imgurl="adImg1"></HomeAdvertising>
  5. <!-- 商品列表 goods-->
  6. <main class="index_main">
  7. <section class="index_1 clearfix">
  8. <div class="shop_head_1 clearfix">
  9. <div class="shop_head_1_name">
  10. <NuxtLink :to="`/${targetSegment}/index.html`"> {{ navTitle }}</NuxtLink>
  11. </div>
  12. </div>
  13. <div class="shop_nav_2">
  14. <a class="shop_nav_2_a" :href="`/${targetSegment}/${item.aLIas_pinyin}/list-1.html`" title=""
  15. v-for="(item, index) in secondNav" :key="index">{{ item.alias }}</a>
  16. </div>
  17. </section>
  18. <!-- 地区选择 -->
  19. <GoodsSubMenu></GoodsSubMenu>
  20. <!-- 三农市场网-商城-商品列表 1-->
  21. <section class="">
  22. <div class="breadcrumb">
  23. <div class="inner">
  24. <span class="location">当前位置 :</span>
  25. <el-breadcrumb :separator-icon="ArrowRight">
  26. <el-breadcrumb-item>
  27. <NuxtLink to="/">首页</NuxtLink>
  28. </el-breadcrumb-item>
  29. <el-breadcrumb-item>{{ navTitle }}</el-breadcrumb-item>
  30. </el-breadcrumb>
  31. </div>
  32. </div>
  33. <div class="categ_table clearfix">
  34. <div class="categ_table_head_box">
  35. <div class="categ_table_td_1">产品图片</div>
  36. <div class="categ_table_td_2">供求信息/公司</div>
  37. <div class="categ_table_td_3">发布时间</div>
  38. <div class="categ_table_td_4">地区</div>
  39. </div>
  40. <div class="categ_table_li" v-for="(item, index) in goodsList" :key="index">
  41. <a class="categ_table_li_a" :href="`/${item.pinyin}/${item.id}.html`" title="">
  42. <div class="categ_table_td_1">
  43. <img class="categ_table_td_1_img" :src="item.imgurl" title="" alt="">
  44. </div>
  45. <div class="categ_table_td_2 ">
  46. <div class="categ_table_td_2_in">
  47. <div class="categ_table_td_2_dot1 dot1">
  48. {{ item.name }}
  49. </div>
  50. <div class="categ_table_td_2_dot2 dot2">
  51. {{ item.description }}
  52. </div>
  53. </div>
  54. </div>
  55. <div class="categ_table_td_3">{{ getTime(item.updated_at, 'year', 1) }}</div>
  56. <div class="categ_table_td_4 dot1">{{ item.city_name }}</div>
  57. </a>
  58. </div>
  59. <div class="empty" v-if="goodsList == false">
  60. <img src="@/public/topic/empty.png" alt="" class="empty_img">
  61. <span class="empty_text">当前暂无数据</span>
  62. </div>
  63. </div>
  64. <div class="pagination1" v-if="goodstotal > 0">
  65. <el-pagination background layout="prev, pager, next" :total="goodstotal" :page-size="pageSize_goods"
  66. prev-text="上一页" next-text="下一页" />
  67. </div>
  68. </section>
  69. <!-- 三农市场网-商城-商品列表 2-->
  70. </main>
  71. <HomeAdvertising :imgurl="adImg2"></HomeAdvertising>
  72. <HomeFoot></HomeFoot>
  73. </template>
  74. <script setup>
  75. //0.加载页面依赖 start ---------------------------------------->
  76. import { ref, onMounted } from 'vue';
  77. import { ElMessage, ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus';
  78. import { ArrowRight } from '@element-plus/icons-vue'
  79. import { NuxtLink } from '#components';
  80. //0.加载页面依赖 end ---------------------------------------->
  81. //1.获得路由id start ---------------------------------------->
  82. const targetSegment = getRoutePath(1);
  83. // const targetSegment1 = getRoutePath(2);
  84. //1.1 获得当前的路由id
  85. let routeId;
  86. let navTitle = ref('')//二级导航标题
  87. let navCid = ref('')//二级导航id
  88. //通过导航路径反向查询导航id
  89. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  90. method: 'GET',
  91. query: {
  92. 'pinyin': targetSegment,
  93. },
  94. });
  95. console.log("getRouteId", getRouteId);
  96. if (getRouteId.code == 200) {
  97. navTitle.value = getRouteId.data.alias
  98. navCid.value = getRouteId.data.category_id
  99. } else {
  100. console.log("获得路由id出错!", getRouteId.message)
  101. }
  102. //1.获得路由id end ---------------------------------------->
  103. //2.页面数据 start ---------------------------------------->
  104. const secondNav = ref([]);
  105. let getSecondNav = async () => {
  106. const listData = await requestDataPromise('/web/getWebsiteModelCategory', {
  107. method: 'GET',
  108. query: {
  109. 'placeid': 1,
  110. 'pid': navCid.value,
  111. 'num': 20,
  112. 'type': 1
  113. },
  114. });
  115. console.log('listData', listData);
  116. if (listData.code == 200) {
  117. secondNav.value = listData.data;
  118. } else {
  119. console.log("错误位置:获取二级栏目列表")
  120. }
  121. }
  122. getSecondNav()
  123. // 获取商品数据列表 start--------------------------------------->
  124. const goodsList = ref()
  125. const page_goods = ref(1)
  126. const pageSize_goods = ref(20)
  127. const goodstotal = ref()
  128. const getGoodsList = await requestDataPromise('/web/getWebsiteshopList', {
  129. method: 'GET',
  130. query: {
  131. 'catid': navCid.value,
  132. 'page': page_goods.value,
  133. 'pageSize': pageSize_goods.value,
  134. 'ismix': 1
  135. },
  136. });
  137. console.log("获取数据列表goods", getGoodsList);
  138. if (getGoodsList.code == 200) {
  139. goodsList.value = getGoodsList.data.goods
  140. goodstotal.value = getGoodsList.data.count
  141. }
  142. // 获取商品数据 end----------------------------------------->
  143. //2.页面数据 end ---------------------------------------->
  144. //4.广告 start ---------------------------------------->
  145. let adImg1 = ref({})
  146. let adImg2 = ref({})
  147. onMounted(async () => {
  148. //从客户端获取行政职能部门 加快打开速度
  149. const { $webUrl, $CwebUrl } = useNuxtApp();
  150. //广告1
  151. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_list_0001`
  152. const responseAd1 = await fetch(url, {
  153. headers: {
  154. 'Content-Type': 'application/json',
  155. 'Userurl': $CwebUrl,
  156. 'Origin': $CwebUrl
  157. }
  158. });
  159. const resultAd1 = await responseAd1.json();
  160. adImg1.value = resultAd1.data[0];
  161. //广告2
  162. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_list_0002`
  163. const responseAd2 = await fetch(url2, {
  164. headers: {
  165. 'Content-Type': 'application/json',
  166. 'Userurl': $CwebUrl,
  167. 'Origin': $CwebUrl
  168. }
  169. });
  170. const resultAd2 = await responseAd2.json();
  171. adImg2.value = resultAd2.data[0];
  172. })
  173. //4.广告 end ---------------------------------------->
  174. //5.设置seo信息 start---------------------------------------->
  175. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  176. method: 'GET',
  177. query: {
  178. 'catid': routeId
  179. },
  180. });
  181. if (setData.code == 200) {
  182. let seoTitle = setData.data.seo_title;
  183. let seoDescription = setData.data.seo_description;
  184. let seoKeywords = setData.data.seo_keywords;
  185. let seoSuffix = setData.data.suffix;
  186. let seoName = setData.data.website_name;
  187. useSeoMeta({
  188. title: seoTitle + "_" + seoSuffix,
  189. meta: [
  190. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  191. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  192. ]
  193. });
  194. } else {
  195. console.log("设置频道页SEO出错!", setData.message)
  196. }
  197. //5.设置seo信息 end---------------------------------------->
  198. </script>
  199. <style lang="less" scoped>
  200. @import url("@/assets/css/shop/goodsList.less");
  201. .empty {
  202. width: 100%;
  203. height: 300px;
  204. line-height: 300px;
  205. text-align: center;
  206. }
  207. .empty_img {
  208. vertical-align: -30px;
  209. margin-right: 20px;
  210. }
  211. .empty_text {
  212. font-size: 26px;
  213. color: #999;
  214. }
  215. .pagination {
  216. height: 100px;
  217. margin-top: 20px;
  218. }
  219. .pagination1 {
  220. height: 100px;
  221. margin-top: 20px;
  222. }
  223. </style>