|
@@ -33,7 +33,7 @@
|
|
|
@click="isShowSelections = !isShowSelections"
|
|
|
>
|
|
|
<div class="select">
|
|
|
- {{ typeListForShow[currentTypeIdx].name }}
|
|
|
+ {{ currentDim === 3 ? typeList3d[currentTypeIdx].name : typeList2d[currentTypeIdx].name }}
|
|
|
</div>
|
|
|
<img
|
|
|
src="@/assets/images/expand.png"
|
|
@@ -59,7 +59,7 @@
|
|
|
class="selection-wrap"
|
|
|
>
|
|
|
<li
|
|
|
- v-for="(item, index) in typeListForShow"
|
|
|
+ v-for="(item, index) in (currentDim === 3 ? typeList3d : typeList2d)"
|
|
|
:key="item.id"
|
|
|
:class="{
|
|
|
choosen: currentTypeIdx === index,
|
|
@@ -97,15 +97,17 @@
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
- v-if="currentDim === 3"
|
|
|
+ v-show="currentDim === 3"
|
|
|
+ v-infinite-scroll="fetchMore3d"
|
|
|
+ infinite-scroll-disabled="disableInfinite3d"
|
|
|
class="relics-list-3d"
|
|
|
>
|
|
|
<RelicItem
|
|
|
- v-for="(item, index) in list"
|
|
|
+ v-for="(item, index) in list3d"
|
|
|
:key="index"
|
|
|
:is-odd="!!(index % 2)"
|
|
|
:is-first="index === 1"
|
|
|
- :is-last="index === list.length - 1"
|
|
|
+ :is-last="index === list3d.length - 1"
|
|
|
:relic-image="`${$cdnPath}3D/${item.bs}.png?x-oss-process=image/resize,p_4`"
|
|
|
:relic-title="item.name"
|
|
|
class="relic-item"
|
|
@@ -114,11 +116,13 @@
|
|
|
</div>
|
|
|
|
|
|
<ul
|
|
|
- v-if="currentDim === 2"
|
|
|
+ v-show="currentDim === 2"
|
|
|
+ v-infinite-scroll="fetchMore2d"
|
|
|
+ infinite-scroll-disabled="disableInfinite2d"
|
|
|
class="relics-list-2d"
|
|
|
>
|
|
|
<li
|
|
|
- v-for="(item, index) in list"
|
|
|
+ v-for="(item, index) in list2d"
|
|
|
:key="index"
|
|
|
@click="onClick2dItem(item)"
|
|
|
>
|
|
@@ -160,7 +164,33 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
currentDim: 3,
|
|
|
- typeListRaw: [
|
|
|
+ currentTypeIdx: 0,
|
|
|
+ isShowSelections: false,
|
|
|
+ isShowInput: false,
|
|
|
+ searchKeyword: '',
|
|
|
+ list3d: [],
|
|
|
+ list2d: [],
|
|
|
+ disableInfinite3d: false,
|
|
|
+ disableInfinite2d: false,
|
|
|
+ typeList3d: [
|
|
|
+ {
|
|
|
+ name: '全部',
|
|
|
+ id: 'all',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '书刊',
|
|
|
+ id: 'book',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '用具',
|
|
|
+ id: 'tool',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '服装',
|
|
|
+ id: 'clothign',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ typeList2d: [
|
|
|
{
|
|
|
name: '全部',
|
|
|
id: 'all',
|
|
@@ -190,49 +220,55 @@ export default {
|
|
|
id: 'photo',
|
|
|
},
|
|
|
],
|
|
|
- currentTypeIdx: 0,
|
|
|
- isShowSelections: false,
|
|
|
- isShowInput: false,
|
|
|
- searchKeyword: '',
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- typeListForShow() {
|
|
|
- if (this.currentDim === 3) {
|
|
|
- return this.typeListRaw.slice(0, this.typeListRaw.length - 2)
|
|
|
- } else if (this.currentDim === 2) {
|
|
|
- return this.typeListRaw
|
|
|
- } else {
|
|
|
- return []
|
|
|
- }
|
|
|
- },
|
|
|
- list() {
|
|
|
- let temp = null
|
|
|
+ hasData() {
|
|
|
if (this.currentDim === 3) {
|
|
|
- temp = rawData['3D']
|
|
|
+ return this.list3d.length !== 0
|
|
|
} else {
|
|
|
- temp = rawData['2D']
|
|
|
+ return this.list2d.length !== 0
|
|
|
}
|
|
|
- temp = temp.filter((item) => {
|
|
|
- return item.type === this.typeListForShow[this.currentTypeIdx].id || this.typeListForShow[this.currentTypeIdx].id === 'all'
|
|
|
- }).filter((item) => {
|
|
|
- return item.name.includes(this.searchKeyword)
|
|
|
- })
|
|
|
- return temp
|
|
|
- },
|
|
|
- hasData() {
|
|
|
- return this.list.length !== 0
|
|
|
},
|
|
|
},
|
|
|
watch: {
|
|
|
currentDim: {
|
|
|
- handler(vNew) {
|
|
|
- if (vNew === 3 && this.currentTypeIdx > this.typeListForShow.length - 1) {
|
|
|
- this.currentTypeIdx = 0
|
|
|
+ handler(vNew, vOld) {
|
|
|
+ let idxNew = 0
|
|
|
+ if (vOld === 3) {
|
|
|
+ const idOld = this.typeList3d[this.currentTypeIdx].id
|
|
|
+ const res = this.typeList2d.findIndex((item) => {
|
|
|
+ return item.id === idOld
|
|
|
+ })
|
|
|
+ if (res >= 0) {
|
|
|
+ idxNew = res
|
|
|
+ }
|
|
|
+ } else if (vOld === 2) {
|
|
|
+ const idOld = this.typeList2d[this.currentTypeIdx].id
|
|
|
+ const res = this.typeList3d.findIndex((item) => {
|
|
|
+ return item.id === idOld
|
|
|
+ })
|
|
|
+ if (res >= 0) {
|
|
|
+ idxNew = res
|
|
|
+ }
|
|
|
}
|
|
|
+ this.currentTypeIdx = idxNew
|
|
|
+ this.refetchSmartly()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ currentTypeIdx: {
|
|
|
+ handler(vNew, vOld) {
|
|
|
+ this.refetchSmartly()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ searchKeyword: {
|
|
|
+ handler(vNew, vOld) {
|
|
|
+ this.refetchSmartly()
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ },
|
|
|
methods: {
|
|
|
onClickFakeInput() {
|
|
|
this.isShowInput = true
|
|
@@ -249,6 +285,51 @@ export default {
|
|
|
},
|
|
|
onClick2dItem(item) {
|
|
|
this.$router.push({ name: 'RelicDetail', query: { ...item, ...{ dimNumber: 2 } } })
|
|
|
+ },
|
|
|
+ fetchMore3d: globalUtils.debounce(function() {
|
|
|
+ console.log('fetchMore3d')
|
|
|
+ if (this.list3d.length % 20 !== 0 ) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const res = globalApi.fetchRelicList(3, this.typeList3d[this.currentTypeIdx].id, this.searchKeyword, this.list3d.length / 20)
|
|
|
+ this.list3d = this.list3d.concat(res)
|
|
|
+ }, 333),
|
|
|
+ fetchMore2d: globalUtils.debounce(function() {
|
|
|
+ console.log('fetchMore2d')
|
|
|
+ if (this.list2d.length % 20 !== 0 ) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const res = globalApi.fetchRelicList(2, this.typeList2d[this.currentTypeIdx].id, this.searchKeyword, this.list2d.length / 20)
|
|
|
+ this.list2d = this.list2d.concat(res)
|
|
|
+ }, 333),
|
|
|
+ refetch3d: globalUtils.debounce(function() {
|
|
|
+ console.log('refetch3d')
|
|
|
+ this.disableInfinite3d = true
|
|
|
+ this.list3d = []
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.fetchMore3d()
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.disableInfinite3d = false
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }, 333),
|
|
|
+ refetch2d: globalUtils.debounce(function() {
|
|
|
+ console.log('refetch2d')
|
|
|
+ this.disableInfinite2d = true
|
|
|
+ this.list2d = []
|
|
|
+ setTimeout(() => {
|
|
|
+ this.fetchMore2d()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.disableInfinite2d = false
|
|
|
+ }, 0)
|
|
|
+ }, 0)
|
|
|
+ }, 333),
|
|
|
+ refetchSmartly() {
|
|
|
+ if (this.currentDim === 3) {
|
|
|
+ this.refetch3d()
|
|
|
+ } else {
|
|
|
+ this.refetch2d()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -438,6 +519,11 @@ export default {
|
|
|
top: 50%;
|
|
|
left: 50%;
|
|
|
transform: translate(-50%, -50%);
|
|
|
+ animation-name: delay-show;
|
|
|
+ animation-duration: 0.3s;
|
|
|
+ animation-fill-mode: forwards;
|
|
|
+ animation-timing-function: step-end;
|
|
|
+
|
|
|
> img {
|
|
|
width: 22.92rem;
|
|
|
height: 20.83rem;
|
|
@@ -451,4 +537,13 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+@keyframes delay-show {
|
|
|
+ 0% {
|
|
|
+ opacity: 0;
|
|
|
+ }
|
|
|
+ 100% {
|
|
|
+ opacity: 1;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|