123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- <template>
- <!-- 商城首页 -->
- <nav class="shop_nav clearfix">
- <div class="shop_nav_head">
- <NuxtLink class="shop_nav_head_a" to="/xiangcunshangcheng/index.html" title="商城首页"></NuxtLink>
- </div>
- <div class="shop_nav_in clearfix">
- <NuxtLink
- :class="['shop_nav_in_a', { 'shop_nav_in_a_active': item.category_id == navId }]"
- :to="`/xiangcunshangcheng/${item.aLIas_pinyin}/index.html`"
- v-for="item in shopNav"
- :title="item.alias"
- >
- {{item.alias}}
- </NuxtLink>
- </div>
- </nav>
- <!-- 商城首页 -->
- <!-- 地区选择 -->
- <div class="shop_name_out">
- <div class="shop_name_box clearfix">
- <div class="shop_name">地区选择</div>
- <div class="shop_name_right">
- <div class="shop_name_in clearfix" ref="shop_name_parent">
- <div class=" clearfix" v-show="shop_name_num == 1">
- <NuxtLink
- :to="`/xiangcunshangcheng/${shopNavOnePinyin}/index.html?cityid=${item.id}`"
- :title="item.name"
- v-for="item in provinceList1"
- :class="['shop_name_a', { 'shop_name_a_only': item.id == cityId }]"
- >
- {{ item.abbreviation }}
- </NuxtLink>
- </div>
- <div class=" clearfix" v-show="shop_name_num == 2">
- <NuxtLink
- :class="['shop_name_a', { 'shop_name_a_only': item.id == cityId }]"
- :to="`/xiangcunshangcheng/${shopNavOnePinyin}/index.html?cityid=${item.id}`"
- :title="item.name"
- v-for="item in provinceList2"
- >
- {{ item.abbreviation }}
- </NuxtLink>
- </div>
- <div class=" clearfix" v-show="shop_name_num == 3">
- <NuxtLink
- :class="['shop_name_a', { 'shop_name_a_only': item.id == cityId }]"
- :to="`/xiangcunshangcheng/${shopNavOnePinyin}/index.html?cityid=${item.id}`"
- :title="item.name"
- v-for="item in provinceList3"
- >
- {{ item.abbreviation }}
- </NuxtLink>
- </div>
- </div>
- <div class="shop_name_btn hand"
- @click="shop_name_num >= shop_name_leng ? shop_name_num = 1 : shop_name_num++">
- </div>
- </div>
- </div>
- </div>
- <!-- 地区选择 -->
- </template>
- <script setup>
- import { ref, onMounted ,watch } from 'vue'
- //1.获得商城导航 start ---------------------------------------->
- //1.1 获得商城导航
- const shopNav = ref("")
- const shopNavOnePinyin = ref("")//获得商城导航的第一个 作为默认的跳转链接
- let getShowNav = async () => {
- const responseStatus = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- placeid:0,
- pid:346,
- num:8
- },
- });
- shopNav.value = responseStatus.data
- shopNavOnePinyin.value = responseStatus.data[0].aLIas_pinyin
- }
- getShowNav();
- //1.2 标记当前选择的地区
- const route = useRoute();
- //获得详情id
- const cityId = ref(route.query.cityid)
- watch(route, () => {
- cityId.value = route.query.cityid
- })
- //1.3 获得频道导航的id,并且标记导航
- //获得当前的完整路径
- const fullPath = route.path;
- //拆分,取出来中间这一段,然后提取数字部分
- const segments = fullPath.split('/');
- const targetSegment = segments[2];
- const navId = ref(0)//当前导航标记哪个
- //通过导航路径反向查询导航id
- const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
- method: 'GET',
- query: {
- 'pinyin': targetSegment,
- },
- });
- if (getRouteId.code == 200) {
- navId.value = parseInt(getRouteId.data.category_id)
- } else {
- console.log("错误位置:通过url路径查询导航池id")
- }
- //1.获得商城导航 end ---------------------------------------->
- //2.获得省列表 start ---------------------------------------->
- const provinceList1 = ref([]);//省列表1
- const provinceList2 = ref([]);//省列表2
- const provinceList3 = ref([]);//省列表3
- onMounted(async () => {
- //获得所有的省
- try {
- const { $webUrl, $CwebUrl } = useNuxtApp();
- const response = await fetch($webUrl + '/web/selectWebsiteArea', {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const result = await response.json();
- for(let index in result.data){
- if(index < 15){
- provinceList1.value.push(result.data[index])
- }else if(index > 14 && index < 30){
- provinceList2.value.push(result.data[index])
- }else if(index > 29){
- provinceList3.value.push(result.data[index])
- }
- }
- } catch (error) {
- console.error('获取行政区划数据失败:', error);
- }
-
- })
- //2.获得商城导航 start ---------------------------------------->
- //3.地区滚动 start ---------------------------------------->
- // 地区选择
- const shop_name_num = ref(1)
- const shop_name_parent = ref(null)
- const shop_name_leng = ref(1)
- onMounted(() => {
- const shop_name_son = shop_name_parent.value.querySelectorAll("div")
- shop_name_leng.value = shop_name_son.length
- })
- //3.地区滚动 end ---------------------------------------->
- </script>
- <style lang="less" scoped>
- .shop_name_out {
- margin-top: 20px;
- }
- .shop_name_box {
- border-top: solid 1px #fff;
- .shop_name_box_a {
- height: 44px;
- line-height: 44px;
- color: #fff;
- font-weight: bold;
- font-size: 20px;
- }
- .shop_name {
- float: left;
- height: 44px;
- line-height: 44px;
- color: #fff;
- font-weight: bold;
- position: relative;
- z-index: 11;
- text-align: center;
- font-size: 20px;
- background: #A01C0E;
- padding: 0px 14px;
- }
- .shop_name_right {
- height: 40px;
- border-bottom: 1px solid #E8E9EC;
- margin-top: 4px;
- background: #F8F8F8;
- position: relative;
- z-index: 2;
- }
- .shop_name_right::after {
- content: '';
- display: block;
- position: absolute;
- top: 0px;
- right: 0px;
- height: 100%;
- width: 16px;
- background: url(@/public/img/9.png) no-repeat 0px bottom #fff;
- background-size: 100% auto;
- }
- .shop_name_btn {
- width: 24px;
- height: 24px;
- float: right;
- margin: 10px 22px 0px 0px;
- background: url(@/public/img/8.png) no-repeat center center;
- border-radius: 50%;
- background-size: 100% 100%;
- }
- }
- .shop_name_in {
- float: left;
- height: 40px;
- width: 1046px;
- float: left;
- box-sizing: border-box;
- .shop_name_a {
- float: left;
- height: 27px;
- line-height: 27px;
- color: #222;
- font-size: 20px;
- position: relative;
- margin: 7px 14.5px 0;
- padding: 0px 10px;
- }
- .shop_name_a::after {
- content: '/';
- display: block;
- position: absolute;
- top: 0px;
- right: -18px;
- height: 100%;
- line-height: 27px;
- color: #E9E9E9;
- font-size: 20px;
- }
- .shop_name_a:nth-last-of-type(1)::after {
- content: '';
- display: none;
- }
- .shop_name_a_only {
- background: #A01C0E;
- color: #fff;
- }
- }
- .shop_name_out {
- margin-top: 20px;
- }
- .shop_name_box {
- border-top: solid 1px #fff;
- .shop_name_box_a {
- height: 44px;
- line-height: 44px;
- color: #fff;
- font-weight: bold;
- font-size: 20px;
- }
- .shop_name {
- float: left;
- height: 44px;
- line-height: 44px;
- color: #fff;
- font-weight: bold;
- position: relative;
- z-index: 11;
- text-align: center;
- font-size: 20px;
- background: #A01C0E;
- padding: 0px 14px;
- }
- .shop_name_right {
- height: 40px;
- border-bottom: 1px solid #E8E9EC;
- margin-top: 4px;
- background: #F8F8F8;
- position: relative;
- z-index: 2;
- }
- .shop_name_right::after {
- content: '';
- display: block;
- position: absolute;
- top: 0px;
- right: 0px;
- height: 100%;
- width: 16px;
- background: url(@/public/img/9.png) no-repeat 0px bottom #fff;
- background-size: 100% auto;
- }
- .shop_name_btn {
- width: 24px;
- height: 24px;
- float: right;
- margin: 10px 22px 0px 0px;
- background: url(@/public/img/8.png) no-repeat center center;
- border-radius: 50%;
- background-size: 100% 100%;
- }
- }
- .shop_nav {
- border: solid 1px #E9E9E9;
- background: #fafafa;
- margin-top: 20px;
- .shop_nav_head {
- float: left;
- height: 28px;
- width: 138px;
- margin: 30px 52px 0px 25px;
- }
- .shop_nav_head_a {
- display: block;
- height: 28px;
- width: 138px;
- background: url(@/public/img/7.png) no-repeat left top;
- background-size: 100% 100%;
- }
- }
- .clearfix {
- overflow: hidden;
- }
- .shop_nav_in_a {
- float: left;
- height: 75px;
- line-height: 75px;
- color: #333;
- font-size: 16px;
- background: #f8f5f5;
- width: 118px;
- border-bottom: solid 5px #A01C0E;
- font-weight: bold;
- margin: 5px 0;
- text-align: center;
- }
- .shop_nav_in_a:nth-of-type(4) {
- margin-right: 8px;
- }
- .shop_nav_in_a:hover {
- color: #A01C0E;
- }
- .shop_nav_in_a_active {
- color: #A01C0E;
- }
- </style>
|