Files

102 lines
3.4 KiB
Vue
Raw Normal View History

2020-03-15 13:59:43 +08:00
<template>
<view ref="container">
<view class="collectionGoods" v-if="collectProductList.length > 0">
2021-04-18 15:28:14 +08:00
<view class="item acea-row row-between-wrapper" v-for="(item, collectProductListIndex) in collectProductList" :key="collectProductListIndex" @click="goGoodsCon(item)">
<view class="pictrue">
<image :src="item.image" />
</view>
<view class="text acea-row row-column-between">
<view class="infor line1">{{ item.storeName }}</view>
<view class="acea-row row-between-wrapper">
2021-04-18 15:28:14 +08:00
<view class="money font-color-red" v-if="isIntegral == 1">{{ item.costPrice }}积分</view>
<view class="money font-color-red" v-else>{{ item.price }}</view>
2020-07-14 00:07:15 +08:00
<view class="delete" @tap.stop="delCollection(collectProductListIndex)">删除</view>
</view>
</view>
</view>
</view>
2020-03-15 13:59:43 +08:00
<Loading :loaded="loadend" :loading="loading"></Loading>
2021-04-18 15:28:14 +08:00
<view class="noCommodity" style="background-color:#fff;" v-if="collectProductList.length < 1 && page > 1">
<view class="noPictrue">
2021-04-10 15:42:46 +08:00
<image :src="`${$VUE_APP_RESOURCES_URL}/images/noCollection.png`" class="image" />
</view>
2020-03-15 13:59:43 +08:00
<Recommend></Recommend>
</view>
</view>
2020-03-15 13:59:43 +08:00
</template>
<script>
2021-04-18 15:28:14 +08:00
import Recommend from '@/components/Recommend'
import { getCollectUser, getCollectDel } from '@/api/user'
import Loading from '@/components/Loading'
2020-03-15 13:59:43 +08:00
export default {
2021-04-18 15:28:14 +08:00
name: 'GoodsCollection',
2020-03-15 13:59:43 +08:00
components: {
Recommend,
2021-04-18 15:28:14 +08:00
Loading,
2020-03-15 13:59:43 +08:00
},
props: {},
data: function() {
return {
page: 1,
limit: 20,
2021-04-18 15:28:14 +08:00
type: 'collect',
2020-03-15 13:59:43 +08:00
collectProductList: [],
2021-04-18 15:28:14 +08:00
loadTitle: '',
2020-03-15 13:59:43 +08:00
loading: false,
2021-04-18 15:28:14 +08:00
loadend: false,
}
2020-03-15 13:59:43 +08:00
},
mounted: function() {
2021-04-18 15:28:14 +08:00
this.get_user_collect_product()
2020-03-15 13:59:43 +08:00
},
onReachBottom() {
2021-04-18 15:28:14 +08:00
!this.loading && this.get_user_collect_product()
2020-03-15 13:59:43 +08:00
},
methods: {
2020-03-16 01:40:52 +08:00
goGoodsCon(item) {
2021-04-18 15:28:14 +08:00
if (item.isIntegral == 1) {
this.$yrouter.push({
path: '/pages/shop/GoodsCon/index',
query: { id: item.pid },
})
} else {
this.$yrouter.push({
path: '/pages/shop/GoodsCon/index',
query: { id: item.pid },
})
}
2020-03-16 01:40:52 +08:00
},
2020-03-15 13:59:43 +08:00
get_user_collect_product: function() {
2021-04-18 15:28:14 +08:00
let that = this
if (that.loading) return //阻止下次请求false可以进行请求
if (that.loadend) return //阻止结束当前请求false可以进行请求
that.loading = true
getCollectUser(that.page, that.limit, that.type).then(res => {
that.loading = false
2020-03-15 13:59:43 +08:00
//apply();js将一个数组插入另一个数组;
2021-04-18 15:28:14 +08:00
that.collectProductList.push.apply(that.collectProductList, res.data)
that.loadend = res.data.length < that.limit //判断所有数据是否加载完成;
that.page = that.page + 1
})
2020-03-15 13:59:43 +08:00
},
//删除收藏;
delCollection: function(index) {
let that = this,
id = that.collectProductList[index].pid,
2021-04-18 15:28:14 +08:00
category = that.collectProductList[index].category
2020-03-15 13:59:43 +08:00
getCollectDel(id, category).then(function() {
uni.showToast({
2021-04-18 15:28:14 +08:00
title: '删除成功',
icon: 'success',
duration: 2000,
complete: () => {
2021-04-18 15:28:14 +08:00
that.collectProductList.splice(index, 1)
that.$set(that, 'collectProductList', that.collectProductList)
},
})
})
},
},
}
2020-03-15 13:59:43 +08:00
</script>