SubMenu2.vue 9.4 KB

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