SubMenu2.vue 9.6 KB

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