|
|
@@ -1,17 +1,48 @@
|
|
|
<template>
|
|
|
<div class="page" :style="{ backgroundImage: `url(${require('@/assets/searchBg.jpg')})` }">
|
|
|
<van-sticky :offset-top="topHeight + 46">
|
|
|
- <van-search clearable shape="round" left-icon="" v-model="search" placeholder="请输入搜索关键词" />
|
|
|
+ <van-search
|
|
|
+ clearable
|
|
|
+ shape="round"
|
|
|
+ left-icon=""
|
|
|
+ v-model="search"
|
|
|
+ placeholder="请输入搜索关键词"
|
|
|
+ @search="getSearch"
|
|
|
+ />
|
|
|
</van-sticky>
|
|
|
|
|
|
- <van-tabs v-model:active="active" scrollspy sticky :offset-top="topHeight + 106">
|
|
|
- <van-tab v-for="(item, index) in options" :key="index" :title="item.label">
|
|
|
- <div class="tab-title">{{ item.label }}</div>
|
|
|
- <div class="van-list">
|
|
|
- <component :is="item.com" dark :info="info"></component>
|
|
|
- </div>
|
|
|
- </van-tab>
|
|
|
- </van-tabs>
|
|
|
+ <div class="content">
|
|
|
+ <van-tabs v-if="!loading" ref="tabs" v-model:active="active" scrollspy sticky :offset-top="topHeight + 106">
|
|
|
+ <van-tab
|
|
|
+ v-for="(item, index) in options"
|
|
|
+ :title-class="item.listKey && searchInfo[item.listKey].length <= 0 ? 'hideTab' : ''"
|
|
|
+ :key="searchKey + index"
|
|
|
+ :title="item.label"
|
|
|
+ >
|
|
|
+ <div class="tab-title" v-if="item.listKey && searchInfo[item.listKey].length > 0">
|
|
|
+ {{ item.label }}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class="van-list"
|
|
|
+ :class="{
|
|
|
+ list:
|
|
|
+ item.listKey === 'news' || item.listKey === 'mintActivities' || item.listKey === 'users'
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <template v-if="item.listKey">
|
|
|
+ <component
|
|
|
+ :is="item.com"
|
|
|
+ dark
|
|
|
+ v-model:info="searchInfo[item.listKey][infoIndex]"
|
|
|
+ v-for="(info, infoIndex) in searchInfo[item.listKey]"
|
|
|
+ :key="infoIndex"
|
|
|
+ list
|
|
|
+ ></component>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ </van-tab>
|
|
|
+ </van-tabs>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -21,46 +52,69 @@ import NewsRecord from '@/components/product/NewsRecord.vue';
|
|
|
import ActivityRecord from '@/components/product/ActivityRecord.vue';
|
|
|
import ShowInfo from '@/components/asset/showInfo.vue';
|
|
|
import CreatorSmall from '@/components/creator/CreatorSmall.vue';
|
|
|
+import CreatorInfo from '@/components/creator/CreatorInfoList.vue';
|
|
|
+
|
|
|
export default {
|
|
|
+ name: 'searchResult',
|
|
|
inject: ['setKeeps', 'scrollWrapper', 'changeScroll', 'bodyScroll', 'safeTop'],
|
|
|
data() {
|
|
|
return {
|
|
|
search: '',
|
|
|
+ searchKey: '',
|
|
|
active: 0,
|
|
|
+ loading: true,
|
|
|
options: [
|
|
|
{
|
|
|
label: '数字商品',
|
|
|
- com: 'ProductInfo'
|
|
|
+ com: 'ProductInfo',
|
|
|
+ listKey: 'collections'
|
|
|
},
|
|
|
{
|
|
|
label: '元域名',
|
|
|
- com: 'ProductInfo'
|
|
|
+ com: 'ProductInfo',
|
|
|
+ listKey: 'domains'
|
|
|
},
|
|
|
{
|
|
|
label: '个人作品',
|
|
|
- com: 'ProductInfo'
|
|
|
+ com: 'ProductInfo',
|
|
|
+ listKey: 'pictures'
|
|
|
},
|
|
|
{
|
|
|
label: '新闻头条',
|
|
|
- com: 'NewsRecord'
|
|
|
+ com: 'NewsRecord',
|
|
|
+ listKey: 'news'
|
|
|
},
|
|
|
{
|
|
|
label: '铸造中心',
|
|
|
- com: 'ActivityRecord'
|
|
|
+ com: 'ActivityRecord',
|
|
|
+ listKey: 'mintActivities'
|
|
|
},
|
|
|
{
|
|
|
label: '艺术机构',
|
|
|
- com: 'ShowInfo'
|
|
|
+ com: 'CreatorSmall',
|
|
|
+ listKey: 'minters'
|
|
|
},
|
|
|
{
|
|
|
label: '个人用户',
|
|
|
- com: 'CreatorSmall'
|
|
|
+ com: 'CreatorInfo',
|
|
|
+ listKey: 'users'
|
|
|
},
|
|
|
{
|
|
|
label: '数字展览',
|
|
|
- com: 'ProductInfo'
|
|
|
+ com: 'ShowInfo',
|
|
|
+ listKey: 'showrooms'
|
|
|
}
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ searchInfo: {
|
|
|
+ collections: [],
|
|
|
+ domains: [],
|
|
|
+ pictures: [],
|
|
|
+ news: [],
|
|
|
+ mintActivities: [],
|
|
|
+ minters: [],
|
|
|
+ users: []
|
|
|
+ },
|
|
|
+ scrollTop: 0
|
|
|
};
|
|
|
},
|
|
|
components: {
|
|
|
@@ -68,18 +122,75 @@ export default {
|
|
|
ActivityRecord,
|
|
|
ProductInfo,
|
|
|
ShowInfo,
|
|
|
- CreatorSmall
|
|
|
+ CreatorSmall,
|
|
|
+ CreatorInfo
|
|
|
},
|
|
|
computed: {
|
|
|
topHeight() {
|
|
|
let safeTop = this.safeTop.replace(/px/, '');
|
|
|
return Number(safeTop);
|
|
|
+ },
|
|
|
+ showOptions() {
|
|
|
+ let options = [...this.options];
|
|
|
+ return options.filter(item => {
|
|
|
+ return this.searchInfo[item.listKey] && this.searchInfo[item.listKey].length > 0;
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
if (this.$route.query.search) {
|
|
|
this.search = this.$route.query.search;
|
|
|
}
|
|
|
+ this.getSearch();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getSearch() {
|
|
|
+ this.loading = true;
|
|
|
+ this.$toast.loading({
|
|
|
+ message: '加载中...',
|
|
|
+ forbidClick: true
|
|
|
+ });
|
|
|
+ this.searchKey = this.search;
|
|
|
+ this.$http
|
|
|
+ .post('/statistic/globalSearch', {
|
|
|
+ search: this.search
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.loading = false;
|
|
|
+ this.$toast.clear();
|
|
|
+ this.searchInfo = res;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$forceUpdate();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ activated() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.changeScroll(this.scrollTop);
|
|
|
+
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.sort = this.beforeSort;
|
|
|
+ // }, 1000);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ beforeRouteLeave(to, from, next) {
|
|
|
+ if (
|
|
|
+ to.name === 'productDetail' ||
|
|
|
+ to.path === '/newsDetail' ||
|
|
|
+ to.path === '/activityDetail' ||
|
|
|
+ to.path === '/creatorDetail' ||
|
|
|
+ to.path === '/hall'
|
|
|
+ ) {
|
|
|
+ this.beforeSort = this.sort;
|
|
|
+ this.scrollTop = this.scrollWrapper.scrollTop;
|
|
|
+ this.setKeeps(['searchResult']);
|
|
|
+ } else {
|
|
|
+ this.beforeSort = '';
|
|
|
+ this.scrollTop = 0;
|
|
|
+ this.setKeeps(['searchResult'], false);
|
|
|
+ }
|
|
|
+ next();
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
@@ -114,11 +225,28 @@ export default {
|
|
|
background-color: #000;
|
|
|
}
|
|
|
|
|
|
+/deep/.van-tabs__nav {
|
|
|
+ --van-tabs-nav-background-color: transparent;
|
|
|
+}
|
|
|
+
|
|
|
+/deep/.hideTab {
|
|
|
+ display: none;
|
|
|
+}
|
|
|
+
|
|
|
+/deep/.van-tabs__nav {
|
|
|
+ padding-left: 16px;
|
|
|
+ padding-right: 16px;
|
|
|
+}
|
|
|
+
|
|
|
.tab-title {
|
|
|
font-size: 14px;
|
|
|
color: #ffffff;
|
|
|
line-height: 24px;
|
|
|
padding: 10px 16px 7px;
|
|
|
+ // position: sticky;
|
|
|
+ // z-index: 20;
|
|
|
+ // top: calc(var(--safe-top) + 148px);
|
|
|
+ // background-color: #000;
|
|
|
}
|
|
|
|
|
|
.block {
|
|
|
@@ -128,5 +256,28 @@ export default {
|
|
|
|
|
|
.van-list {
|
|
|
padding: 8px;
|
|
|
+ --bg2: #2b2b2c;
|
|
|
+ --text0: #fff;
|
|
|
+ --btnplaintBg: rgba(255, 255, 255, 0.08);
|
|
|
+ --btnplaintBorder: rgba(255, 255, 255, 0.08);
|
|
|
+ --border: rgba(255, 255, 255, 0.08);
|
|
|
+ .news-record {
|
|
|
+ border-radius: 0;
|
|
|
+ }
|
|
|
+ .showInfo {
|
|
|
+ background-color: #2b2b2c;
|
|
|
+ border-radius: 12px;
|
|
|
+ margin: 0 8px;
|
|
|
+ }
|
|
|
+ .showInfo + .showInfo {
|
|
|
+ margin-top: 16px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.list {
|
|
|
+ margin: 16px 16px 0;
|
|
|
+ padding: 0;
|
|
|
+ border-radius: 8px;
|
|
|
+ overflow: hidden;
|
|
|
}
|
|
|
</style>
|