subMenu.vue 9.5 KB

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