123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- <template>
- <div class="collections">
- <div class="slebar">
- <div>分类:</div>
- <ul>
- <li @click="menuActive = item.id" :class="{ active: menuActive == item.id }" v-for="(item, i) in menu" :key="i">
- {{ item.name }}
- </li>
- </ul>
- </div>
- <div class="masonrycon">
- <div v-if="list && list.length > 0" class="masonry" v-infinite-scroll="getData" infinite-scroll-disabled="busy"
- :infinite-scroll-immediate-check="true" infinite-scroll-distance="30" v-masonry="containerId" fit-width="true"
- gutter="10" initLayout="true" transition-duration="0.3s" item-selector=".item">
- <div @click="onClickCollection(item)" v-masonry-tile class="item" :class="{ odd: index % 2 != 0 }"
- v-for="(item, index) in list" :key="index">
- <div class="itemimg">
- <div :style="`background-image:url(${item.thumb})`"></div>
- </div>
- <p class="goodBotInfo">{{ item.name }}</p>
- </div>
- </div>
- <div class="searchNone" style="padding-top: 40%" v-else>
- <img src="@/assets/images/resource/searchNone.svg" alt="" />
- <p>暂时没有数据</p>
- </div>
- </div>
- </div>
- <teleport to='body'>
- <div class="fnbar">
- <div class="barsub">
- <mb_select :noradius="true" class="mb_select" @handleOption="handleTab" :value="activeId" :options="yearlist" />
- </div>
- <div class="barsub">
- <mb_select :noradiusAll="true" class="mb_select" @handleOption="handleTab" :value="activeId"
- :options="yearlist" />
- </div>
- <div class="searchimg" v-show="!showInput">
- <img @click="showInput=true" :src="require('@/assets/images/icon/label_search.png')" alt="">
- </div>
- <transition name="fade">
- <div class="searchcon" v-if="showInput">
- <img :src="require('@/assets/images/icon/label_search.png')" alt="">
- <input v-model="searchKey" type="text" placeholder="请输入藏品名称">
- <span @click="showInput=false">取消</span>
- </div>
- </transition>
- </div>
- </teleport>
- <teleport to='body'>
- <div class="fnbar">
- <div class="barsub">
- <mb_select :noradius="true" class="mb_select" @handleOption="data=>currentMuseum=data.id" :value="currentMuseum"
- :options="museumList" />
- </div>
- <div class="barsub">
- <mb_select :noradiusAll="true" class="mb_select" @handleOption="data=>currentAge=data.id" :value="currentAge"
- :options="ages" />
- </div>
- <div class="barsub">
- <mb_select :noradiusAll="true" class="mb_select" @handleOption="data=>currentType=data.id" :value="currentType"
- :options="types" />
- </div>
- <div class="searchimg" v-show="!showInput">
- <img @click="showInput=true" :src="require('@/assets/images/icon/label_search.png')" alt="">
- </div>
- <transition name="fade">
- <div class="searchcon" v-if="showInput">
- <img :src="require('@/assets/images/icon/label_search.png')" alt="">
- <input v-model="searchKey" type="text" placeholder="请输入展览名称">
- <span @click="showInput=false,searchKey=''">取消</span>
- </div>
- </transition>
- </div>
- </teleport>
- <transition name="fade">
- <teleport to='body'>
- <showCollection v-if="activeCollection" :item="activeCollection" />
- </teleport>
- </transition>
- </template>
- <script>
- import { defineProps, getCurrentInstance, onMounted, watch, nextTick, ref } from "vue";
- import mb_select from "@/components/mb_select";
- import { getCollectionList, getMuseumList, getAge, getType } from "@/config/api";
- import showCollection from "@/components/showCollection/index.vue";
- import emitter from "@/mitt/index";
- export default {
- setup(props) {
- const containerId = ref("vuemasonry");
- const searchKey = ref("");
- const currentAge = ref("");
- const currentType = ref("");
- const currentMuseum = ref("");
- const busy = ref(false)
- const ages = ref([]);
- const types = ref([]);
- const museumList = ref([]);
- const menu = ref([
- {
- id: "",
- name: "全部",
- },
- {
- id: "model",
- name: "三维模型",
- },
- {
- id: "img",
- name: "图片",
- },
- {
- id: "video",
- name: "视频",
- },
- {
- id: "audio",
- name: "音频",
- },
- ]);
- const menuActive = ref("");
- onMounted(() => {
- getAge(data => {
- ages.value = data.data.data.map(item => {
- return {
- ...item,
- label: item.name,
- value: item.id
- }
- })
- })
- getType(data => {
- types.value = data.data.data.map(item => {
- return {
- ...item,
- label: item.name,
- value: item.id
- }
- })
- })
- getMuseumList({
- "cityId": '',
- "pageNum": 1,
- "pageSize": 1000,
- }, data => {
- museumList.value = data.data.records.map(item => {
- return {
- ...item,
- label: item.name,
- value: item.id
- }
- })
- if (!currentMuseum.value) {
- currentMuseum.value = museumList.value[0].value
- }
- })
- })
- return { ages, types, currentMuseum, museumList, menu, currentAge, menuActive, currentType, searchKey, busy }
- },
- components: { showCollection, mb_select },
- data() {
- return {
- showInput: false,
- list: [],
- activeCollection: null,
- paging: {
- pageSize: 10,
- pageNum: 1,
- showSize: 4,
- current: 1,
- }
- }
- },
- watch: {
- searchKey() {
- this.getData(true)
- },
- currentAge() {
- this.getData(true)
- },
- currentMuseum() {
- this.getData(true)
- this.$emit('updateMuseum', this.museumList.find((item => item.id == this.currentMuseum)))
- },
- currentType() {
- this.getData(true)
- },
- menuActive() {
- this.getData(true)
- }
- },
- methods: {
- handleTab() {
- },
- getData(reset) {
- if (reset) {
- this.list = []
- }
- this.busy = true
- getCollectionList({
- "ageId": this.currentAge,
- "museumId": this.currentMuseum,
- "type": this.menuActive,
- "pageNum": this.paging.pageNum,
- "pageSize": this.paging.pageSize,
- "searchKey": this.searchKey,
- "textureId": this.currentType,
- }, data => {
- this.busy = false
- if (data.data.total <= this.list.length) {
- this.busy = true
- return
- }
- this.list = this.list.concat(data.data.records)
- this.paging.pageNum += 1
- this.$nextTick(() => {
- this.$redrawVueMasonry(this.containerId);
- });
- })
- // console.log(this);
- // this.list = this.list.concat([]);
- // // list.value = list.value.concat(list.value);
- // this.$nextTick(() => {
- // this.$redrawVueMasonry(this.containerId);
- // });
- },
- onClickCollection(data) {
- this.activeCollection = data
- }
- },
- mounted() {
- emitter.on('closeCollection', () => {
- this.activeCollection = ''
- })
- },
- };
- </script>
-
- <style lang="scss" scoped>
- .collections {
- width: 100vw;
- padding-top: 10px;
- background: #e8e3d1;
- .slebar {
- display: flex;
- color: #333;
- align-items: center;
- width: 90vw;
- margin: 0 auto;
- font-size: 14px;
- padding-bottom: 20px;
- >ul {
- display: flex;
- align-items: center;
- >li {
- text-align: center;
- margin: 0 6px;
- cursor: pointer;
- white-space: nowrap;
- &.active {
- height: 30px;
- color: var(--main-color);
- line-height: 30px;
- border-radius: 60px;
- padding: 0 8px;
- border: 1px solid var(--main-color);
- }
- }
- }
- }
- .masonrycon {
- height: calc(100vh - 60px);
- overflow-y: auto;
- .masonry {
- width: 90vw;
- margin: 0 auto 16px;
- .item {
- width: calc(45vw - 5px);
- height: 200px;
- border-radius: 10px;
- margin-bottom: 10px;
- overflow: hidden;
- cursor: pointer;
- .itemimg {
- background: linear-gradient(180deg, #d9d9d9 0%, #b9b9b9 100%);
- font-size: 0;
- height: calc(100% - 40px);
- width: 100%;
- >div {
- height: 100%;
- width: 100%;
- background-repeat: no-repeat;
- background-size: cover;
- background-position: center;
- }
- }
- p {
- background: #fffef6;
- color: #999;
- height: 40px;
- line-height: 40px;
- padding: 0 10px;
- &.active {
- color: var(--main-color);
- }
- }
- }
- .odd {
- height: 310px;
- }
- }
- }
- }
- .fnbar {
- position: absolute;
- bottom: 20px;
- right: 5%;
- background: var(--main-color);
- z-index: 99;
- width: 90%;
- display: flex;
- align-items: center;
- border-radius: 50px;
- font-size: 0;
- .barsub {
- width: calc((100% - 5% - 16px) / 3);
- flex-shrink: 0;
- }
- .searchimg {
- position: absolute;
- right: 5%;
- >img {
- width: 16px;
- height: 16px;
- }
- }
- .searchcon {
- width: 100%;
- position: absolute;
- left: 0;
- top: 0;
- height: 100%;
- z-index: 999;
- background: var(--main-color);
- border-radius: 50px;
- display: flex;
- align-items: center;
- font-size: 14px;
- padding: 0 10px;
- justify-content: space-around;
- >img {
- width: 20px;
- height: 20px;
- }
- >input {
- width: 100%;
- height: 100%;
- padding-left: 16px;
- color: #fff;
- &::placeholder {
- color: #D2D2D2;
- }
- }
- >span {
- display: inline-block;
- color: var(--font-active);
- width: 30px;
- white-space: nowrap;
- }
- }
- }
- </style>
|