Commit 5a1f711d authored by Damon's avatar Damon

perf: 收藏

parent 56a02ffb
......@@ -64,10 +64,15 @@
<view
class="c-list"
v-if="type === 1 || type === 3"
@click="collection(collectionFlag)"
@click="$u.throttle(collection, 500)"
>
<u-icon v-show="!collectionFlag" name="star" color="#5A6073" size="40"></u-icon>
<u-icon v-show="collectionFlag" name="star-fill" color="#FF930D" size="40"></u-icon>
<u-image
:src="collectImg"
width="36"
height="36"
:fade="false"
:lazy-load="false"
/>
<text>{{ collectionFlag ? '已收藏' : '收藏' }}</text>
</view>
<view class="c-list" v-if="type === 2" @click="handPapers">
......@@ -205,6 +210,11 @@ export default {
removeImg() {
return process.uniEnv.qn_base_url + 'remove-error.png'
},
collectImg() {
const info = this.list.find(v => v.index === this.currentIndex)
const name = info?.collectionFlag ? 'collected.png' : 'collect.png'
return process.uniEnv.qn_base_url + name
},
currentNumber() {
let index = this.currentIndex
return index === -2 ? this.total : index + 1
......@@ -520,8 +530,9 @@ export default {
})
},
// 收藏
collection(status) {
collection() {
const info = this.list.find(v => v.index === this.currentIndex)
const status = info ? info.collectionFlag : false
const action = status ? 'removeCollection' : 'joinCollection'
this.$u.api[action]({questionId: info.id}).then(res => {
if(res) {
......
......@@ -67,8 +67,13 @@
</view>
<view class="u-flex opera">
<view class="opera-list" @click="collection(item)">
<u-icon v-show="!collectionFlag" name="star" color="#5A6073" size="40"></u-icon>
<u-icon v-show="collectionFlag" name="star-fill" color="#FF930D" size="40"></u-icon>
<u-image
:src="collectImg"
width="36"
height="36"
:fade="false"
:lazy-load="false"
/>
<text>{{ collectionFlag ? '已收藏' : '收藏' }}</text>
</view>
<view class="opera-list" @click="arrowUp(index)">
......@@ -128,6 +133,11 @@ export default {
count() {
return this.lists.length
},
collectImg() {
const info = this.lists.find(v => v.index === this.arrIndex)
const name = info?.collectionFlag ? 'collected.png' : 'collect.png'
return process.uniEnv.qn_base_url + name
},
collectionFlag() {
const info = this.lists.find(v => v.index === this.arrIndex)
return info ? info.collectionFlag : false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment