mobile.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div class="collections">
  3. <div class="slebar">
  4. <div>分类:</div>
  5. <ul>
  6. <li @click="menuActive = item.id" :class="{ active: menuActive == item.id }" v-for="(item, i) in menu" :key="i">
  7. {{ item.name }}
  8. </li>
  9. </ul>
  10. </div>
  11. <div class="masonrycon">
  12. <div v-if="list && list.length > 0" class="masonry" v-infinite-scroll="getData" infinite-scroll-disabled="busy"
  13. :infinite-scroll-immediate-check="true" infinite-scroll-distance="30" v-masonry="containerId" fit-width="true"
  14. gutter="10" initLayout="true" transition-duration="0.3s" item-selector=".item">
  15. <div @click="onClickCollection(item)" v-masonry-tile class="item" :class="{ odd: index % 2 != 0 }"
  16. v-for="(item, index) in list" :key="index">
  17. <div class="itemimg">
  18. <div :style="`background-image:url(${item.thumb})`"></div>
  19. </div>
  20. <p class="goodBotInfo">{{ item.name }}</p>
  21. </div>
  22. </div>
  23. <div class="searchNone" style="padding-top: 40%" v-else>
  24. <img src="@/assets/images/resource/searchNone.svg" alt="" />
  25. <p>暂时没有数据</p>
  26. </div>
  27. </div>
  28. </div>
  29. <teleport to='body'>
  30. <div class="fnbar">
  31. <div class="barsub">
  32. <mb_select :noradius="true" class="mb_select" @handleOption="handleTab" :value="activeId" :options="yearlist" />
  33. </div>
  34. <div class="barsub">
  35. <mb_select :noradiusAll="true" class="mb_select" @handleOption="handleTab" :value="activeId"
  36. :options="yearlist" />
  37. </div>
  38. <div class="searchimg" v-show="!showInput">
  39. <img @click="showInput=true" :src="require('@/assets/images/icon/label_search.png')" alt="">
  40. </div>
  41. <transition name="fade">
  42. <div class="searchcon" v-if="showInput">
  43. <img :src="require('@/assets/images/icon/label_search.png')" alt="">
  44. <input v-model="searchKey" type="text" placeholder="请输入藏品名称">
  45. <span @click="showInput=false">取消</span>
  46. </div>
  47. </transition>
  48. </div>
  49. </teleport>
  50. <teleport to='body'>
  51. <div class="fnbar">
  52. <div class="barsub">
  53. <mb_select :noradius="true" class="mb_select" @handleOption="data=>currentMuseum=data.id" :value="currentMuseum"
  54. :options="museumList" />
  55. </div>
  56. <div class="barsub">
  57. <mb_select :noradiusAll="true" class="mb_select" @handleOption="data=>currentAge=data.id" :value="currentAge"
  58. :options="ages" />
  59. </div>
  60. <div class="barsub">
  61. <mb_select :noradiusAll="true" class="mb_select" @handleOption="data=>currentType=data.id" :value="currentType"
  62. :options="types" />
  63. </div>
  64. <div class="searchimg" v-show="!showInput">
  65. <img @click="showInput=true" :src="require('@/assets/images/icon/label_search.png')" alt="">
  66. </div>
  67. <transition name="fade">
  68. <div class="searchcon" v-if="showInput">
  69. <img :src="require('@/assets/images/icon/label_search.png')" alt="">
  70. <input v-model="searchKey" type="text" placeholder="请输入展览名称">
  71. <span @click="showInput=false,searchKey=''">取消</span>
  72. </div>
  73. </transition>
  74. </div>
  75. </teleport>
  76. <transition name="fade">
  77. <teleport to='body'>
  78. <showCollection v-if="activeCollection" :item="activeCollection" />
  79. </teleport>
  80. </transition>
  81. </template>
  82. <script>
  83. import { defineProps, getCurrentInstance, onMounted, watch, nextTick, ref } from "vue";
  84. import mb_select from "@/components/mb_select";
  85. import { getCollectionList, getMuseumList, getAge, getType } from "@/config/api";
  86. import showCollection from "@/components/showCollection/index.vue";
  87. import emitter from "@/mitt/index";
  88. export default {
  89. setup(props) {
  90. const containerId = ref("vuemasonry");
  91. const searchKey = ref("");
  92. const currentAge = ref("");
  93. const currentType = ref("");
  94. const currentMuseum = ref("");
  95. const busy = ref(false)
  96. const ages = ref([]);
  97. const types = ref([]);
  98. const museumList = ref([]);
  99. const menu = ref([
  100. {
  101. id: "",
  102. name: "全部",
  103. },
  104. {
  105. id: "model",
  106. name: "三维模型",
  107. },
  108. {
  109. id: "img",
  110. name: "图片",
  111. },
  112. {
  113. id: "video",
  114. name: "视频",
  115. },
  116. {
  117. id: "audio",
  118. name: "音频",
  119. },
  120. ]);
  121. const menuActive = ref("");
  122. onMounted(() => {
  123. getAge(data => {
  124. ages.value = data.data.data.map(item => {
  125. return {
  126. ...item,
  127. label: item.name,
  128. value: item.id
  129. }
  130. })
  131. })
  132. getType(data => {
  133. types.value = data.data.data.map(item => {
  134. return {
  135. ...item,
  136. label: item.name,
  137. value: item.id
  138. }
  139. })
  140. })
  141. getMuseumList({
  142. "cityId": '',
  143. "pageNum": 1,
  144. "pageSize": 1000,
  145. }, data => {
  146. museumList.value = data.data.records.map(item => {
  147. return {
  148. ...item,
  149. label: item.name,
  150. value: item.id
  151. }
  152. })
  153. if (!currentMuseum.value) {
  154. currentMuseum.value = museumList.value[0].value
  155. }
  156. })
  157. })
  158. return { ages, types, currentMuseum, museumList, menu, currentAge, menuActive, currentType, searchKey, busy }
  159. },
  160. components: { showCollection, mb_select },
  161. data() {
  162. return {
  163. showInput: false,
  164. list: [],
  165. activeCollection: null,
  166. paging: {
  167. pageSize: 10,
  168. pageNum: 1,
  169. showSize: 4,
  170. current: 1,
  171. }
  172. }
  173. },
  174. watch: {
  175. searchKey() {
  176. this.getData(true)
  177. },
  178. currentAge() {
  179. this.getData(true)
  180. },
  181. currentMuseum() {
  182. this.getData(true)
  183. this.$emit('updateMuseum', this.museumList.find((item => item.id == this.currentMuseum)))
  184. },
  185. currentType() {
  186. this.getData(true)
  187. },
  188. menuActive() {
  189. this.getData(true)
  190. }
  191. },
  192. methods: {
  193. handleTab() {
  194. },
  195. getData(reset) {
  196. if (reset) {
  197. this.list = []
  198. }
  199. this.busy = true
  200. getCollectionList({
  201. "ageId": this.currentAge,
  202. "museumId": this.currentMuseum,
  203. "type": this.menuActive,
  204. "pageNum": this.paging.pageNum,
  205. "pageSize": this.paging.pageSize,
  206. "searchKey": this.searchKey,
  207. "textureId": this.currentType,
  208. }, data => {
  209. this.busy = false
  210. if (data.data.total <= this.list.length) {
  211. this.busy = true
  212. return
  213. }
  214. this.list = this.list.concat(data.data.records)
  215. this.paging.pageNum += 1
  216. this.$nextTick(() => {
  217. this.$redrawVueMasonry(this.containerId);
  218. });
  219. })
  220. // console.log(this);
  221. // this.list = this.list.concat([]);
  222. // // list.value = list.value.concat(list.value);
  223. // this.$nextTick(() => {
  224. // this.$redrawVueMasonry(this.containerId);
  225. // });
  226. },
  227. onClickCollection(data) {
  228. this.activeCollection = data
  229. }
  230. },
  231. mounted() {
  232. emitter.on('closeCollection', () => {
  233. this.activeCollection = ''
  234. })
  235. },
  236. };
  237. </script>
  238. <style lang="scss" scoped>
  239. .collections {
  240. width: 100vw;
  241. padding-top: 10px;
  242. background: #e8e3d1;
  243. .slebar {
  244. display: flex;
  245. color: #333;
  246. align-items: center;
  247. width: 90vw;
  248. margin: 0 auto;
  249. font-size: 14px;
  250. padding-bottom: 20px;
  251. >ul {
  252. display: flex;
  253. align-items: center;
  254. >li {
  255. text-align: center;
  256. margin: 0 6px;
  257. cursor: pointer;
  258. white-space: nowrap;
  259. &.active {
  260. height: 30px;
  261. color: var(--main-color);
  262. line-height: 30px;
  263. border-radius: 60px;
  264. padding: 0 8px;
  265. border: 1px solid var(--main-color);
  266. }
  267. }
  268. }
  269. }
  270. .masonrycon {
  271. height: calc(100vh - 60px);
  272. overflow-y: auto;
  273. .masonry {
  274. width: 90vw;
  275. margin: 0 auto 16px;
  276. .item {
  277. width: calc(45vw - 5px);
  278. height: 200px;
  279. border-radius: 10px;
  280. margin-bottom: 10px;
  281. overflow: hidden;
  282. cursor: pointer;
  283. .itemimg {
  284. background: linear-gradient(180deg, #d9d9d9 0%, #b9b9b9 100%);
  285. font-size: 0;
  286. height: calc(100% - 40px);
  287. width: 100%;
  288. >div {
  289. height: 100%;
  290. width: 100%;
  291. background-repeat: no-repeat;
  292. background-size: cover;
  293. background-position: center;
  294. }
  295. }
  296. p {
  297. background: #fffef6;
  298. color: #999;
  299. height: 40px;
  300. line-height: 40px;
  301. padding: 0 10px;
  302. &.active {
  303. color: var(--main-color);
  304. }
  305. }
  306. }
  307. .odd {
  308. height: 310px;
  309. }
  310. }
  311. }
  312. }
  313. .fnbar {
  314. position: absolute;
  315. bottom: 20px;
  316. right: 5%;
  317. background: var(--main-color);
  318. z-index: 99;
  319. width: 90%;
  320. display: flex;
  321. align-items: center;
  322. border-radius: 50px;
  323. font-size: 0;
  324. .barsub {
  325. width: calc((100% - 5% - 16px) / 3);
  326. flex-shrink: 0;
  327. }
  328. .searchimg {
  329. position: absolute;
  330. right: 5%;
  331. >img {
  332. width: 16px;
  333. height: 16px;
  334. }
  335. }
  336. .searchcon {
  337. width: 100%;
  338. position: absolute;
  339. left: 0;
  340. top: 0;
  341. height: 100%;
  342. z-index: 999;
  343. background: var(--main-color);
  344. border-radius: 50px;
  345. display: flex;
  346. align-items: center;
  347. font-size: 14px;
  348. padding: 0 10px;
  349. justify-content: space-around;
  350. >img {
  351. width: 20px;
  352. height: 20px;
  353. }
  354. >input {
  355. width: 100%;
  356. height: 100%;
  357. padding-left: 16px;
  358. color: #fff;
  359. &::placeholder {
  360. color: #D2D2D2;
  361. }
  362. }
  363. >span {
  364. display: inline-block;
  365. color: var(--font-active);
  366. width: 30px;
  367. white-space: nowrap;
  368. }
  369. }
  370. }
  371. </style>