subMenu.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <!-- 商城首页 -->
  3. <nav class="shop_nav clearfix phone_none">
  4. <div class="shop_nav_head">
  5. <NuxtLink class="shop_nav_head_a" to="/xiangcunshangcheng/index.html" title="商城首页"></NuxtLink>
  6. </div>
  7. <div class="shop_nav_in clearfix">
  8. <NuxtLink
  9. :class="['shop_nav_in_a', { 'shop_nav_in_a_active': item.category_id == navId }]"
  10. :to="`/xiangcunshangcheng/${item.aLIas_pinyin}/index.html`"
  11. v-for="item in shopNav"
  12. :title="item.alias"
  13. >
  14. {{item.alias}}
  15. </NuxtLink>
  16. </div>
  17. </nav>
  18. <div class="phone_nav pc_none">
  19. <NuxtLink
  20. class="phone_nav_a phone_nav_a_head"
  21. to="/xiangcunshangcheng/index.html" >
  22. 商城首页
  23. </NuxtLink>
  24. <div class="phone_nav_in">
  25. <NuxtLink
  26. :class="['phone_nav_a', { 'phone_nav_a_active': item.category_id == navId }]"
  27. :to="`/xiangcunshangcheng/${item.aLIas_pinyin}/index.html`"
  28. v-for="item in shopNav"
  29. >
  30. {{item.alias}}
  31. </NuxtLink>
  32. </div>
  33. </div>
  34. <!-- 商城首页 -->
  35. <!-- 地区选择 -->
  36. <div class="shop_name_out">
  37. <div class="shop_name_box clearfix">
  38. <div class="shop_name">地区选择</div>
  39. <div class="shop_name_right">
  40. <div class="shop_name_in clearfix" ref="shop_name_parent">
  41. <div class=" clearfix" v-show="shop_name_num == 1">
  42. <NuxtLink
  43. :to="`/xiangcunshangcheng/${shopNavOnePinyin}/index.html?cityid=${item.id}`"
  44. :title="item.name"
  45. v-for="item in provinceList1"
  46. :class="['shop_name_a', { 'shop_name_a_only': item.id == cityId }]"
  47. >
  48. {{ item.abbreviation }}
  49. </NuxtLink>
  50. </div>
  51. <div class=" clearfix" v-show="shop_name_num == 2">
  52. <NuxtLink
  53. :class="['shop_name_a', { 'shop_name_a_only': item.id == cityId }]"
  54. :to="`/xiangcunshangcheng/${shopNavOnePinyin}/index.html?cityid=${item.id}`"
  55. :title="item.name"
  56. v-for="item in provinceList2"
  57. >
  58. {{ item.abbreviation }}
  59. </NuxtLink>
  60. </div>
  61. <div class=" clearfix" v-show="shop_name_num == 3">
  62. <NuxtLink
  63. :class="['shop_name_a', { 'shop_name_a_only': item.id == cityId }]"
  64. :to="`/xiangcunshangcheng/${shopNavOnePinyin}/index.html?cityid=${item.id}`"
  65. :title="item.name"
  66. v-for="item in provinceList3"
  67. >
  68. {{ item.abbreviation }}
  69. </NuxtLink>
  70. </div>
  71. </div>
  72. <div class="shop_name_btn hand"
  73. @click="shop_name_num >= shop_name_leng ? shop_name_num = 1 : shop_name_num++">
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <!-- 地区选择 -->
  79. </template>
  80. <script setup>
  81. import { ref, onMounted ,watch } from 'vue'
  82. //1.获得商城导航 start ---------------------------------------->
  83. //1.1 获得商城导航
  84. const shopNav = ref("")
  85. const shopNavOnePinyin = ref("")//获得商城导航的第一个 作为默认的跳转链接
  86. let getShowNav = async () => {
  87. const responseStatus = await requestDataPromise('/web/getWebsiteModelCategory', {
  88. method: 'GET',
  89. query: {
  90. placeid:0,
  91. pid:346,
  92. num:8
  93. },
  94. });
  95. shopNav.value = responseStatus.data
  96. shopNavOnePinyin.value = responseStatus.data[0].aLIas_pinyin
  97. }
  98. getShowNav();
  99. //1.2 标记当前选择的地区
  100. const route = useRoute();
  101. //获得详情id
  102. const cityId = ref(route.query.cityid)
  103. watch(route, () => {
  104. cityId.value = route.query.cityid
  105. })
  106. //1.3 获得频道导航的id,并且标记导航
  107. //获得当前的完整路径
  108. const fullPath = route.path;
  109. //拆分,取出来中间这一段,然后提取数字部分
  110. const segments = fullPath.split('/');
  111. const targetSegment = segments[2];
  112. const navId = ref(0)//当前导航标记哪个
  113. //通过导航路径反向查询导航id
  114. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  115. method: 'GET',
  116. query: {
  117. 'pinyin': targetSegment,
  118. },
  119. });
  120. if (getRouteId.code == 200) {
  121. navId.value = parseInt(getRouteId.data.category_id)
  122. } else {
  123. console.log("错误位置:通过url路径查询导航池id")
  124. }
  125. //1.获得商城导航 end ---------------------------------------->
  126. //2.获得省列表 start ---------------------------------------->
  127. const provinceList1 = ref([]);//省列表1
  128. const provinceList2 = ref([]);//省列表2
  129. const provinceList3 = ref([]);//省列表3
  130. onMounted(async () => {
  131. //获得所有的省
  132. try {
  133. const { $webUrl, $CwebUrl } = useNuxtApp();
  134. const response = await fetch($webUrl + '/web/selectWebsiteArea', {
  135. headers: {
  136. 'Content-Type': 'application/json',
  137. 'Userurl': $CwebUrl,
  138. 'Origin': $CwebUrl
  139. }
  140. });
  141. const result = await response.json();
  142. for(let index in result.data){
  143. if(index < 15){
  144. provinceList1.value.push(result.data[index])
  145. }else if(index > 14 && index < 30){
  146. provinceList2.value.push(result.data[index])
  147. }else if(index > 29){
  148. provinceList3.value.push(result.data[index])
  149. }
  150. }
  151. } catch (error) {
  152. console.error('获取行政区划数据失败:', error);
  153. }
  154. })
  155. //2.获得商城导航 start ---------------------------------------->
  156. //3.地区滚动 start ---------------------------------------->
  157. // 地区选择
  158. const shop_name_num = ref(1)
  159. const shop_name_parent = ref(null)
  160. const shop_name_leng = ref(1)
  161. onMounted(() => {
  162. const shop_name_son = shop_name_parent.value.querySelectorAll("div")
  163. shop_name_leng.value = shop_name_son.length
  164. })
  165. //3.地区滚动 end ---------------------------------------->
  166. </script>
  167. <style lang="less" scoped>
  168. .shop_name_out {
  169. margin-top: 20px;
  170. }
  171. .shop_name_box {
  172. border-top: solid 1px #fff;
  173. .shop_name_box_a {
  174. height: 44px;
  175. line-height: 44px;
  176. color: #fff;
  177. font-weight: bold;
  178. font-size: 20px;
  179. }
  180. .shop_name {
  181. float: left;
  182. height: 44px;
  183. line-height: 44px;
  184. color: #fff;
  185. font-weight: bold;
  186. position: relative;
  187. z-index: 11;
  188. text-align: center;
  189. font-size: 20px;
  190. background: #A01C0E;
  191. padding: 0px 14px;
  192. }
  193. .shop_name_right {
  194. height: 40px;
  195. border-bottom: 1px solid #E8E9EC;
  196. margin-top: 4px;
  197. background: #F8F8F8;
  198. position: relative;
  199. z-index: 2;
  200. }
  201. .shop_name_right::after {
  202. content: '';
  203. display: block;
  204. position: absolute;
  205. top: 0px;
  206. right: 0px;
  207. height: 100%;
  208. width: 16px;
  209. background: url(@/public/img/9.png) no-repeat 0px bottom #fff;
  210. background-size: 100% auto;
  211. }
  212. .shop_name_btn {
  213. width: 24px;
  214. height: 24px;
  215. float: right;
  216. margin: 10px 22px 0px 0px;
  217. background: url(@/public/img/8.png) no-repeat center center;
  218. border-radius: 50%;
  219. background-size: 100% 100%;
  220. }
  221. }
  222. .shop_name_in {
  223. float: left;
  224. height: 40px;
  225. width: 1046px;
  226. float: left;
  227. box-sizing: border-box;
  228. .shop_name_a {
  229. float: left;
  230. height: 27px;
  231. line-height: 27px;
  232. color: #222;
  233. font-size: 20px;
  234. position: relative;
  235. margin: 7px 14.5px 0;
  236. padding: 0px 10px;
  237. }
  238. .shop_name_a::after {
  239. content: '/';
  240. display: block;
  241. position: absolute;
  242. top: 0px;
  243. right: -18px;
  244. height: 100%;
  245. line-height: 27px;
  246. color: #E9E9E9;
  247. font-size: 20px;
  248. }
  249. .shop_name_a:nth-last-of-type(1)::after {
  250. content: '';
  251. display: none;
  252. }
  253. .shop_name_a_only {
  254. background: #A01C0E;
  255. color: #fff;
  256. }
  257. }
  258. .shop_name_out {
  259. margin-top: 20px;
  260. }
  261. .shop_name_box {
  262. border-top: solid 1px #fff;
  263. .shop_name_box_a {
  264. height: 44px;
  265. line-height: 44px;
  266. color: #fff;
  267. font-weight: bold;
  268. font-size: 20px;
  269. }
  270. .shop_name {
  271. float: left;
  272. height: 44px;
  273. line-height: 44px;
  274. color: #fff;
  275. font-weight: bold;
  276. position: relative;
  277. z-index: 11;
  278. text-align: center;
  279. font-size: 20px;
  280. background: #A01C0E;
  281. padding: 0px 14px;
  282. }
  283. .shop_name_right {
  284. height: 40px;
  285. border-bottom: 1px solid #E8E9EC;
  286. margin-top: 4px;
  287. background: #F8F8F8;
  288. position: relative;
  289. z-index: 2;
  290. }
  291. .shop_name_right::after {
  292. content: '';
  293. display: block;
  294. position: absolute;
  295. top: 0px;
  296. right: 0px;
  297. height: 100%;
  298. width: 16px;
  299. background: url(@/public/img/9.png) no-repeat 0px bottom #fff;
  300. background-size: 100% auto;
  301. }
  302. .shop_name_btn {
  303. width: 24px;
  304. height: 24px;
  305. float: right;
  306. margin: 10px 22px 0px 0px;
  307. background: url(@/public/img/8.png) no-repeat center center;
  308. border-radius: 50%;
  309. background-size: 100% 100%;
  310. }
  311. }
  312. .shop_nav {
  313. border: solid 1px #E9E9E9;
  314. background: #fafafa;
  315. margin-top: 20px;
  316. .shop_nav_head {
  317. float: left;
  318. height: 28px;
  319. width: 138px;
  320. margin: 30px 52px 0px 25px;
  321. }
  322. .shop_nav_head_a {
  323. display: block;
  324. height: 28px;
  325. width: 138px;
  326. background: url(@/public/img/7.png) no-repeat left top;
  327. background-size: 100% 100%;
  328. }
  329. }
  330. .clearfix {
  331. overflow: hidden;
  332. }
  333. .shop_nav_in_a {
  334. float: left;
  335. height: 75px;
  336. line-height: 75px;
  337. color: #333;
  338. font-size: 16px;
  339. background: #f8f5f5;
  340. width: 118px;
  341. border-bottom: solid 5px #A01C0E;
  342. font-weight: bold;
  343. margin: 5px 0;
  344. text-align: center;
  345. }
  346. .shop_nav_in_a:nth-of-type(4) {
  347. margin-right: 8px;
  348. }
  349. .shop_nav_in_a:hover {
  350. color: #A01C0E;
  351. }
  352. .shop_nav_in_a_active {
  353. color: #A01C0E;
  354. }
  355. </style>
  356. <style lang="less" scoped>
  357. @media screen and (min-width:801px){/*pc*/
  358. .pc_none{display:none;}
  359. }
  360. @media screen and (max-width:800px){/*ipad_phone*/
  361. .index_main{width:100%;margin:0px auto;}
  362. .phone_nav{
  363. width:100%; box-sizing:border-box;background:#fafafa;
  364. margin:10px auto;height:33px;padding:0px 4%;
  365. .phone_nav_in{
  366. overflow-x:auto;overflow-y:hidden;word-break: keep-all; white-space: nowrap;
  367. height:33px;line-height:33px;
  368. }
  369. .phone_nav_in::-webkit-scrollbar{height:0px;}
  370. .phone_nav_a_head{float:left;}
  371. .phone_nav_a{display:inline-block;line-height:33px;height:33px;
  372. color:#333;font-size:14px;margin:0px 10px;
  373. }
  374. .phone_nav_a:nth-of-type(1){margin-left:0px;}
  375. }
  376. .router-link-exact-active.phone_nav_a{
  377. color:#A01C0E;
  378. }
  379. .shop_name_out{display:none;}
  380. .phone_none{display:none;}
  381. }
  382. </style>