maside.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <div class="aside">
  3. <transition name="fade">
  4. <div class="vlist" v-if="isShow">
  5. <img class="guanbi" @click="isShow=false" :src="require('@/assets/images/icon/guanbi.png')" alt="">
  6. <div class="vtitle">{{currentId === 'museum' ? '博物馆列表' : '虚拟场景列表'}}</div>
  7. <div class="search">
  8. <input v-model="searchkey" type="text" placeholder="请输入关键字查询">
  9. <img @click="search" :src="require('@/assets/images/icon/search_red.png')" alt="">
  10. </div>
  11. <div class="list">
  12. <p class="gd" @click="router.push({name:'gdmuseum'})">广东省博物馆</p>
  13. <section>
  14. <ul v-if="list.length > 0">
  15. <li v-for="(sub, idx) in list" :key="idx">
  16. <p :id="'aside-list-sidebar-' + sub.type">{{ sub.type }}</p>
  17. <ul v-if="sub.arr.length > 0">
  18. <li @click="onClickItem(son)" v-for="(son, sonidx) in sub.arr" :key="sonidx">
  19. {{ son.name }}
  20. </li>
  21. </ul>
  22. </li>
  23. </ul>
  24. </section>
  25. <div class="sidebar">
  26. <ul>
  27. <li v-for="(item, i) in charStrs" :key="i" @click="onClickSidebarItem(item)">
  28. {{ item }}
  29. </li>
  30. </ul>
  31. </div>
  32. <div class="sanjiao"></div>
  33. </div>
  34. </div>
  35. </transition>
  36. <ul class="select">
  37. <li @click="onClickSelect({id:'museum'})" :class="{ active: currentId == 'museum' }">
  38. <span></span>
  39. <span>博物馆</span>
  40. </li>
  41. <li @click="onClickSelect({id:'scene'})" :class="{ active: currentId == 'scene' }">
  42. <span></span>
  43. <span>虚拟场景</span>
  44. </li>
  45. </ul>
  46. </div>
  47. </template>
  48. <script setup>
  49. import { ref, onMounted, computed,watch, nextTick } from "vue";
  50. import { getMuseumList,getExhibitionList } from "@/config/api";
  51. import { useRouter, useRoute } from "vue-router";
  52. const router = useRouter();
  53. const route = useRoute();
  54. const isShow = ref(false)
  55. const currentId = ref('museum')
  56. const searchkey = ref('')
  57. const charStrs = ref('')
  58. const list = ref([]);
  59. const onClickSelect = (data) => {
  60. isShow.value = true
  61. currentId.value = data.id
  62. }
  63. const onClickSidebarItem = (item) => {
  64. const targetNode = document.getElementById('aside-list-sidebar-' + item)
  65. if (targetNode) {
  66. targetNode.scrollIntoView()
  67. }
  68. }
  69. const onClickItem = data => {
  70. if (currentId.value=='museum') {
  71. router.push({name:'exhibition',query:{id:data.id}})
  72. }else{
  73. router.push({name:'zhanlan',params:{id:data.id}})
  74. }
  75. }
  76. const getList = () => {
  77. let getData = currentId.value == 'museum' ? getMuseumList : getExhibitionList
  78. list.value = []
  79. getData({
  80. "cityId": '',
  81. "pageNum": 1,
  82. "pageSize": 1000,
  83. "searchKey": searchkey.value
  84. }, data => {
  85. console.log(data);
  86. data.data.records.forEach(item => {
  87. let ele = list.value.findIndex(sub => sub.type == item.initial.toUpperCase())
  88. if (ele < 0) {
  89. list.value.push({
  90. type: item.initial.toUpperCase(),
  91. arr: [
  92. { ...item }
  93. ],
  94. })
  95. } else {
  96. list.value[ele].arr.push({ ...item })
  97. }
  98. })
  99. list.value = list.value.sort((a, b) => {
  100. if (a.type < b.type) {
  101. return -1;
  102. }
  103. if (a.type > b.type) {
  104. return 1;
  105. }
  106. return 0;
  107. })
  108. charStrs.value = list.value.map(item => item.type)
  109. })
  110. }
  111. const search = ()=>{
  112. getList()
  113. }
  114. watch(currentId,()=>{
  115. getList()
  116. })
  117. onMounted(() => {
  118. getList()
  119. })
  120. </script>
  121. <style lang="scss" scoped>
  122. .aside {
  123. width: 90%;
  124. height: 94%;
  125. margin: 0 auto;
  126. pointer-events: none;
  127. .vlist {
  128. pointer-events: auto;
  129. background: rgba(255, 254, 246, 0.94);
  130. backdrop-filter: blur(20px);
  131. padding: 18px;
  132. border-radius: 8px;
  133. height: calc(100% - 60px);
  134. position: relative;
  135. .guanbi {
  136. position: absolute;
  137. right: 6px;
  138. top: 6px;
  139. width: 40px;
  140. z-index: 1;
  141. }
  142. .vtitle {
  143. color: var(--main-color);
  144. font-size: 18px;
  145. font-weight: bold;
  146. }
  147. .list {
  148. background-color: #fffef6;
  149. border-radius: 5px;
  150. height: calc(100% - 60px);
  151. color: #333333;
  152. text-align: left;
  153. position: relative;
  154. padding: 18px 10px;
  155. .gd {
  156. color: var(--main-color);
  157. font-size: 16px;
  158. }
  159. >section {
  160. height: 95%;
  161. overflow-y: auto;
  162. &::-webkit-scrollbar { display: none; } /*宽度是对垂直滚动条而言,高度是对水平滚动条而言*/
  163. >p {
  164. color: var(--main-color);
  165. font-size: 16px;
  166. font-weight: bold;
  167. padding-left: 16px;
  168. position: relative;
  169. &::before {
  170. content: "";
  171. display: inline-block;
  172. width: 10px;
  173. height: 10px;
  174. background: var(--main-color);
  175. border-radius: 50%;
  176. position: absolute;
  177. left: 0;
  178. top: 50%;
  179. transform: translateY(-50%);
  180. }
  181. }
  182. >ul {
  183. >li {
  184. margin: 14px 0;
  185. cursor: pointer;
  186. >p {
  187. font-weight: bold;
  188. }
  189. >ul {
  190. >li {
  191. color: #999999;
  192. margin: 10px 0;
  193. }
  194. }
  195. }
  196. }
  197. }
  198. .sidebar {
  199. width: 20px;
  200. height: 94%;
  201. background: #f3f2e8;
  202. border-radius: 50px;
  203. position: absolute;
  204. right: 10px;
  205. top: 18px;
  206. >ul {
  207. text-align: center;
  208. display: flex;
  209. flex-direction: column;
  210. justify-content: space-around;
  211. align-items: center;
  212. height: 100%;
  213. >li {
  214. color: #999999;
  215. font-size: 12px;
  216. cursor: pointer;
  217. }
  218. }
  219. }
  220. .sanjiao {
  221. position: absolute;
  222. left: 50%;
  223. transform: translateX(-50%);
  224. bottom: 2px;
  225. border: 8px solid transparent;
  226. border-top-color: var(--main-color);
  227. }
  228. }
  229. .search {
  230. width: 100%;
  231. height: 40px;
  232. border-radius: 8px;
  233. background: #EBEAE7;
  234. margin-top: 16px;
  235. position: relative;
  236. >input {
  237. line-height: 40px;
  238. text-align: left;
  239. width: 100%;
  240. padding: 0 40px 0 10px;
  241. }
  242. >img {
  243. position: absolute;
  244. right: 10px;
  245. top: 50%;
  246. transform: translateY(-50%);
  247. width: 20px;
  248. }
  249. }
  250. }
  251. .select {
  252. pointer-events: auto;
  253. width: 100%;
  254. display: flex;
  255. padding: 10px 0;
  256. justify-content: center;
  257. background: var(--main-color);
  258. border-radius: 50px;
  259. position: absolute;
  260. bottom: 0;
  261. left: 0;
  262. >li {
  263. display: flex;
  264. align-items: center;
  265. margin: 0 10px;
  266. cursor: pointer;
  267. >span {
  268. margin-right: 6px;
  269. display: inline-block;
  270. &:first-of-type {
  271. width: 20px;
  272. height: 20px;
  273. position: relative;
  274. border-radius: 50%;
  275. background: #fff;
  276. }
  277. }
  278. &.active {
  279. >span {
  280. &:first-of-type {
  281. &::before {
  282. content: "";
  283. position: absolute;
  284. width: 10px;
  285. height: 10px;
  286. background: var(--font-active);
  287. border-radius: 50%;
  288. top: 50%;
  289. left: 50%;
  290. transform: translate(-50%, -50%);
  291. }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. }
  298. </style>