|
@@ -13,7 +13,8 @@
|
|
:class="{active: isFav}"
|
|
:class="{active: isFav}"
|
|
@click="handleFavorite"
|
|
@click="handleFavorite"
|
|
>
|
|
>
|
|
- <u-icon name="heart-fill" size="58rpx" :color="isFav?$colors.primaryColor:$colors.defaultColor" />
|
|
|
|
|
|
+ <u-loading-icon v-if="favLoading" size="58rpx" :color="$colors.primaryColor" />
|
|
|
|
+ <u-icon v-else name="heart-fill" size="58rpx" :color="isFav?$colors.primaryColor:$colors.defaultColor" />
|
|
<text>{{ $util.tranNumber(favNumber) }}</text>
|
|
<text>{{ $util.tranNumber(favNumber) }}</text>
|
|
</view>
|
|
</view>
|
|
<!--收藏-->
|
|
<!--收藏-->
|
|
@@ -22,7 +23,8 @@
|
|
:class="{active: isCollect}"
|
|
:class="{active: isCollect}"
|
|
@click="handleCollect"
|
|
@click="handleCollect"
|
|
>
|
|
>
|
|
- <u-icon name="star-fill" size="58rpx" :color="isCollect?$colors.primaryColor:$colors.defaultColor" />
|
|
|
|
|
|
+ <u-loading-icon v-if="collectLoading" size="58rpx" :color="$colors.primaryColor" />
|
|
|
|
+ <u-icon v-else name="star-fill" size="58rpx" :color="isCollect?$colors.primaryColor:$colors.defaultColor" />
|
|
<text>{{ $util.tranNumber(episode.user_collect_count) }}</text>
|
|
<text>{{ $util.tranNumber(episode.user_collect_count) }}</text>
|
|
</view>
|
|
</view>
|
|
<!--分享-->
|
|
<!--分享-->
|
|
@@ -68,6 +70,8 @@ export default {
|
|
return {
|
|
return {
|
|
isCollect: false,
|
|
isCollect: false,
|
|
isFav: false,
|
|
isFav: false,
|
|
|
|
+ favLoading: false,
|
|
|
|
+ collectLoading: false,
|
|
toast: { // 收藏/喜欢 toast
|
|
toast: { // 收藏/喜欢 toast
|
|
status: 'success',
|
|
status: 'success',
|
|
text: '收藏成功',
|
|
text: '收藏成功',
|
|
@@ -112,10 +116,12 @@ export default {
|
|
handleCollect() {
|
|
handleCollect() {
|
|
if (this.btnLock) return
|
|
if (this.btnLock) return
|
|
this.btnLock = true
|
|
this.btnLock = true
|
|
|
|
+ this.collectLoading = true
|
|
const method = this.isCollect ? 'destroy' : 'add'
|
|
const method = this.isCollect ? 'destroy' : 'add'
|
|
const num = this.isCollect ? -1 : 1
|
|
const num = this.isCollect ? -1 : 1
|
|
- this.$api.user.collect[method](this.currentEpisode.id).then(res => {
|
|
|
|
|
|
+ this.$api.user.collect[method](this.episode.id).then(res => {
|
|
this.btnLock = false
|
|
this.btnLock = false
|
|
|
|
+ this.collectLoading = false
|
|
if (res.data) {
|
|
if (res.data) {
|
|
this.toast.show = true
|
|
this.toast.show = true
|
|
this.toast.status = this.isCollect ? 'cancel' : 'success'
|
|
this.toast.status = this.isCollect ? 'cancel' : 'success'
|
|
@@ -123,6 +129,9 @@ export default {
|
|
this.isCollect = !this.isCollect
|
|
this.isCollect = !this.isCollect
|
|
this.$emit('change', { type: 'collect', num: num })
|
|
this.$emit('change', { type: 'collect', num: num })
|
|
}
|
|
}
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ this.collectLoading = false
|
|
|
|
+ this.btnLock = false
|
|
})
|
|
})
|
|
},
|
|
},
|
|
// 检查是否喜欢当前短剧
|
|
// 检查是否喜欢当前短剧
|
|
@@ -135,12 +144,16 @@ export default {
|
|
},
|
|
},
|
|
// 处理 喜欢剧集
|
|
// 处理 喜欢剧集
|
|
handleFavorite() {
|
|
handleFavorite() {
|
|
|
|
+ console.log('-->handleFavorite', this.btnLock)
|
|
if (this.btnLock) return
|
|
if (this.btnLock) return
|
|
|
|
+ console.log('-->handleFavorite', this.btnLock)
|
|
this.btnLock = true
|
|
this.btnLock = true
|
|
|
|
+ this.favLoading = true
|
|
const method = this.isFav ? 'destroy' : 'add'
|
|
const method = this.isFav ? 'destroy' : 'add'
|
|
const num = this.isFav ? -1 : 1
|
|
const num = this.isFav ? -1 : 1
|
|
this.$api.user.favorite[method](this.currentEpisode.id).then(res => {
|
|
this.$api.user.favorite[method](this.currentEpisode.id).then(res => {
|
|
this.btnLock = false
|
|
this.btnLock = false
|
|
|
|
+ this.favLoading = false
|
|
if (res.data) {
|
|
if (res.data) {
|
|
this.toast.show = true
|
|
this.toast.show = true
|
|
this.toast.status = this.isFav ? 'cancel' : 'success'
|
|
this.toast.status = this.isFav ? 'cancel' : 'success'
|
|
@@ -149,6 +162,9 @@ export default {
|
|
this.isFav = !this.isFav
|
|
this.isFav = !this.isFav
|
|
this.favNumber += num
|
|
this.favNumber += num
|
|
}
|
|
}
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ this.favLoading = false
|
|
|
|
+ this.btnLock = false
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|