| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502 |
- <template>
- <HomePageHead></HomePageHead>
- <HomePageNavigation></HomePageNavigation>
- <HomeAdvertising :imgurl="adImg1"></HomeAdvertising>
- <!-- 商品列表 goods-->
- <main class="index_main">
- <section class="index_1 clearfix phone_none">
- <div class="shop_head_1 clearfix">
- <div class="shop_head_1_name">
- <NuxtLink :to="`/${targetSegment}/index.html`"> {{ parent_name }}</NuxtLink>
- </div>
- </div>
- <div class="shop_nav_2">
- <a class="shop_nav_2_a" :href="`/${targetSegment}/${item.aLIas_pinyin}/list-1.html`" :title="item.alias"
- v-for="(item, index) in secondNav" :key="index">{{ item.alias }}</a>
- </div>
- </section>
- <div class="phone_nav pc_none">
- <div class="phone_nav_in">
- <a class="phone_nav_a" :href="`/${targetSegment}/${item.aLIas_pinyin}/list-1.html`" title=""
- v-for="(item, index) in secondNav" :key="index"
- :class="{ 'active': item.aLIas_pinyin == targetSegment1 }">{{ item.alias }}</a>
- </div>
- </div>
- <!-- 地区选择 -->
- <GoodsSubMenu1></GoodsSubMenu1>
- <!-- 三农市场网-商城-商品列表 1-->
- <section class="">
- <div class="breadcrumb phone_none">
- <div class="inner">
- <span class="location">当前位置:</span>
- <el-breadcrumb :separator-icon="ArrowRight">
- <el-breadcrumb-item>
- <NuxtLink to="/">首页</NuxtLink>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="parent_name != ''">
- <NuxtLink :to="`/${targetSegment}/index.html`"> {{ parent_name }}</NuxtLink>
- </el-breadcrumb-item>
- <el-breadcrumb-item>{{ navTitle }}</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- </div>
- <div class="breadcrumb_box pc_none">
-
- <span class=" ">当前位置:</span>
-
- <NuxtLink to="/">首页</NuxtLink>
- <span class=" ">></span>
- <NuxtLink :to="`/${targetSegment}/index.html`" v-if="parent_name != ''"> {{ parent_name }}</NuxtLink>
- <span class=" " v-if="parent_name != ''">></span>
-
- {{ navTitle }}
-
- </div>
- <!-- 商品列表 -->
- <div class="categ_table clearfix">
- <div class="categ_table_head_box">
- <div class="categ_table_td_1">产品图片</div>
- <div class="categ_table_td_2">供求信息/公司</div>
- <div class="categ_table_td_3">发布时间</div>
- <div class="categ_table_td_4">地区</div>
- </div>
- <div class="categ_table_li" v-for="(item, index) in goodsList" :key="index">
- <a class="categ_table_li_a" :href="`/${item.pinyin}/${item.id}.html`" title="">
- <div class="categ_table_td_1">
- <img class="categ_table_td_1_img" :src="item.imgurl" title="" alt="">
- </div>
- <div class="categ_table_td_2 ">
- <div class="categ_table_td_2_in">
- <div class="categ_table_td_2_dot1 dot1">
- {{ item.name }}
- </div>
- <div class="categ_table_td_2_dot2 dot2">
- {{ item.description }}
- </div>
- </div>
- </div>
- <div class="categ_table_td_3">{{ getTime(item.updated_at, 'year', 1) }}</div>
- <div class="categ_table_td_4 dot1">{{ item.city_name }}</div>
- </a>
- </div>
- <div class="empty" v-if="goodsList == false">
- <img src="@/public/topic/empty.png" alt="" class="empty_img">
- <span class="empty_text">当前暂无数据</span>
- </div>
- </div>
- <div class="pagination1 page_phone_none" v-if="goodstotal > 0">
- <el-pagination background layout="prev, pager, next" :total="goodstotal" :page-size="pageSize_goods"
- prev-text="上一页" next-text="下一页" />
- </div>
- <div class="pagination1 page_pc_none" v-if="goodstotal > 0">
- <el-pagination
- pager-count="5"
- size="small"
- background
- layout=" pager "
- :total="goodstotal"
- class="mt-4"
- :page-size="pageSize_goods"
- />
- </div>
- </section>
- <!-- 三农市场网-商城-商品列表 2-->
- </main>
- <HomeAdvertising :imgurl="adImg2"></HomeAdvertising>
- <HomeFoot></HomeFoot>
- </template>
- <script setup>
- //0.加载页面依赖 start ---------------------------------------->
- import { ref, onMounted } from 'vue';
- import { ElMessage, ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus';
- import { ArrowRight } from '@element-plus/icons-vue'
- import { NuxtLink } from '#components';
- //0.加载页面依赖 end ---------------------------------------->
- //1.获得路由id start ---------------------------------------->
- const targetSegment = getRoutePath(1);
- const targetSegment1 = getRoutePath(2);
- const route = useRoute();
- let cityid = route.query.cityid;
- let cityId = ref(0)
- cityId.value = parseFloat(cityid)
- // console.log("cityid1111222", cityid);
- // console.log("cityid1111222", typeof cityId.value);
- //1.1 获得当前的路由id
- let routeId;
- let routeType;
- let navTitle = ref('')//二级导航标题
- let navCid = ref('')//二级导航id
- //通过导航路径反向查询导航id
- const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
- method: 'GET',
- query: {
- 'pinyin': targetSegment + '/' + targetSegment1,
- },
- });
- console.log("getRouteId", getRouteId);
- if (getRouteId.code == 200) {
- navTitle.value = getRouteId.data.alias
- navCid.value = getRouteId.data.category_id
- } else {
- console.log("获得路由id出错!", getRouteId.message)
- }
- //1.2 获取父级栏目
- let parent_name = ref('');//父级名称
- let parent_id = ref('');//父级id
- let parent_pinyin = ref('');//父级拼音
- const getRoutePName = await requestDataPromise('/web/getWebsiteRoute', {
- method: 'GET',
- query: {
- 'pinyin': targetSegment,
- },
- });
- console.log("getRoutePName", getRoutePName);
- if (getRoutePName.code == 200) {
- routeId = getRoutePName.data.category_id
- parent_id.value = getRoutePName.data.category_id
- parent_name.value = getRoutePName.data.alias
- routeType = getRoutePName.data.type
- } else {
- console.log("获得路由id出错!", getRoutePName.message)
- }
- //1.3 获取某个栏目
- const getParentId = await requestDataPromise('/web/getOneWebsiteCategory', {
- method: 'GET',
- query: {
- 'catid': parent_id.value,
- },
- });
- console.log("getParentId", getParentId);
- if (getParentId.code == 200) {
- parent_pinyin.value = getParentId.data.aLIas_pinyin
- } else {
- console.log("获得路由id出错!", getParentId.message)
- }
- //1.获得路由id end ---------------------------------------->
- //2.选项卡 start ---------------------------------------->
- let showTabs = ref(1)
- let qhtabs = function (number) {
- console.log(number)
- showTabs.value = number
- }
- //2.选项卡 end ---------------------------------------->
- //3.广告 start ---------------------------------------->
- let adImg1 = ref({})
- let adImg2 = ref({})
- onMounted(async () => {
- //从客户端获取行政职能部门 加快打开速度
- const { $webUrl, $CwebUrl } = useNuxtApp();
- //广告1
- let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nfcpgxw_list_0001`
- const responseAd1 = await fetch(url, {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const resultAd1 = await responseAd1.json();
- adImg1.value = resultAd1.data[0];
- //广告2
- let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nfcpgxw_list_0002`
- const responseAd2 = await fetch(url2, {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const resultAd2 = await responseAd2.json();
- adImg2.value = resultAd2.data[0];
- })
- //3.广告 end ---------------------------------------->
- //4.页面数据 start ---------------------------------------->
- const secondNav = ref([]);
- let getSecondNav = async () => {
- const listData = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'placeid': 1,
- 'pid': parent_id.value,
- 'num': 20,
- 'type': 1
- },
- });
- console.log('listData', listData);
- if (listData.code == 200) {
- secondNav.value = listData.data;
- } else {
- console.log("错误位置:获取二级栏目列表")
- }
- }
- getSecondNav()
- // 获取商品数据列表 start--------------------------------------->
- const goodsList = ref()
- const page_goods = ref(1)
- const pageSize_goods = ref(20)
- const goodstotal = ref()
- let getshop = async () => {
- let params = {
- 'catid': navCid.value,
- 'city_id': cityId.value,
- 'page': page_goods.value,
- 'pageSize': pageSize_goods.value,
- 'ismix': 1
- }
- if (cityId.value == undefined || cityId.value == '' || cityId.value == 'NaN') {
- //删除变量params中的city_id参数
- delete params.city_id
- } else {
- params.city_id = parseFloat(cityId.value)
- }
- const getGoodsList = await requestDataPromise('/web/getWebsiteshopList', {
- method: 'GET',
- query: params
- });
- console.log("获取数据列表goods", getGoodsList);
- if (getGoodsList.code == 200) {
- goodsList.value = getGoodsList.data.goods
- goodstotal.value = getGoodsList.data.count
- } else {
- goodsList.value = []
- goodstotal.value = 0
- }
- }
- let getshop1 = async () => {
- let params = {
- 'catid': navCid.value,
- 'page': page_goods.value,
- 'pageSize': pageSize_goods.value,
- 'ismix': 1
- }
- const getGoodsList = await requestDataPromise('/web/getWebsiteshopList', {
- method: 'GET',
- query: params
- });
- // console.log("获取数据列表goods", getGoodsList);
- if (getGoodsList.code == 200) {
- goodsList.value = getGoodsList.data.goods
- goodstotal.value = getGoodsList.data.count
- } else {
- goodsList.value = []
- goodstotal.value = 0
- }
- }
- // getshop1()
- //4.4.1 监听cityid
- watch(() => route.query.cityid, (newVal, oldVal) => {
- if (newVal != undefined) {
- cityId.value = parseFloat(newVal)
- getshop()
- } else {
- getshop1()
- }
- }, {
- deep: true,
- immediate: true
- })
- // 获取商品数据 end----------------------------------------->
- //4.页面数据 end ---------------------------------------->
- //5.设置seo信息 start---------------------------------------->
- const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
- method: 'GET',
- query: {
- 'catid': navCid.value
- },
- });
- if (setData.code == 200) {
- let seoTitle = setData.data.seo_title;
- let seoDescription = setData.data.seo_description;
- let seoKeywords = setData.data.seo_keywords;
- let seoSuffix = setData.data.suffix;
- let seoName = setData.data.website_name;
- useSeoMeta({
- title: seoTitle + "_" + seoName + "_" + seoSuffix,
- meta: [
- { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
- { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
- { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
- ]
- });
- } else {
- console.log("设置频道页SEO出错!", setData.message)
- }
- //5.设置seo信息 end---------------------------------------->
- </script>
- <style lang="less" scoped>
- @import url("@/assets/css/shop/goodsList.less");
- .empty {
- width: 100%;
- height: 300px;
- line-height: 300px;
- text-align: center;
- }
- .empty_img {
- vertical-align: -30px;
- margin-right: 20px;
- }
- .empty_text {
- font-size: 26px;
- color: #999;
- }
- .pagination {
- height: 100px;
- margin-top: 20px;
- }
- .pagination1 {
- height: 100px;
- margin-top: 20px;
- }
- </style>
- <style lang="less" scoped>
-
- @media screen and (min-width:801px){/*pc*/
-
- .page_pc_none{display:none!important;}
- .pc_none{display:none;}
- }
- @media screen and (max-width:800px){/*ipad_phone*/
- .index_main{width:100%;margin:0px auto;}
- .phone_nav{
- width:100%; box-sizing:border-box;background:#fafafa;
- margin:10px auto;height:33px;
- .phone_nav_in{ width:92%;margin:0px auto;
- overflow-x:auto;overflow-y:hidden;
- word-break: keep-all; white-space: nowrap;
- line-height:33px;
- height:33px;
- }
- .phone_nav_in::-webkit-scrollbar{height:0px;}
-
- .phone_nav_a{display:inline-block;line-height:33px;height:33px;
- color:#333;font-size:14px;margin:0px 10px;
- }
- .phone_nav_a:nth-of-type(1){margin-left:0px;}
- }
- .phone_nav_a.active{
- color:#004564;
- }
- .breadcrumb_box{
- height:22px;width:100%;margin:10px auto;
- word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
- width:92%;
- font-size:14px;
- color:#666;
-
- *{
- font-size:14px;
-
- display:inline ;
- color:#666;
- line-height:22px;height:22px;
- margin-right:5px;
- }
- }
-
- .categ_table{width:92%;margin:0px auto 0px; }
- .categ_table_li{
- height:auto!important;padding:10px 0px;overflow:hidden;
- a{display:block;overflow:hidden;}
- .categ_table_td_1{height:33vw;width:33vw;margin-right:0px; }
- .categ_table_td_1_img{width:100%;height:100%;}
-
- .categ_table_td_2{width:55vw; margin-right:0;float:right;height:auto;}
- .categ_table_td_2_in{width:100%;display:block;vertical-align:top;height:auto;}
- .categ_table_td_2_dot1{width:100%;margin-top:8px;}
- .categ_table_td_2_dot2{width:100%;margin:8px 0;-webkit-line-clamp:1;height:18px;}
- .categ_table_td_2_dot3{width:100%;-webkit-line-clamp:1;}
- .categ_table_td_3{
- float:left;text-align:right;width:auto;line-height:22px!important;height:22px;margin:0 4vw;font-size:14px;
- border:solid 1px #E9E9E9;
- padding:0px 4px;
- }
- .categ_table_td_4{
- padding:0px 4px;
- border:solid 1px #E9E9E9;
- height:22px;line-height:22px!important;float:left;text-align:right;width:auto;font-size:14px;
- }
- }
- .pagination1{margin:25px auto 0px;width:100%;height:auto;}
- .page_phone_none{display:none!important;}
- .pagination1 /deep/.el-pagination.is-background .el-pager li{margin:0px 4px;}
- .categ_table_head_box{display:none;}
- .phone_none{display:none;}
- }
- </style>
|