myCollection.vue 3.0 KB
<template>
	<view>
		<u-empty
		marginTop="251"
		        mode="list"
				text="暂无收藏"
				v-if="!list.length"
		>
		</u-empty>
		<view class="misslist" v-if="list.length">
			<custom-waterfalls-flow :value="list" :columnSpace="1.5" :seat="2" @edit="edit" @del="del"
				@wapperClick="wapperClick" @imageClick="wapperClick">
				<template v-slot:default="item">
					<view class="item">
						<view class="title">{{item.name}}</view>
						<view class="desc">{{item.sort.name}}</view>
						<view class="desc flexA">
							{{item.seller_name}}
							<view class="money">
								<text style="font-size: 20rpx;">¥</text>{{item.price}}
							</view>
						</view>
					</view>
				</template>
			</custom-waterfalls-flow>
		</view>
		
	</view>
</template>


<script>
	import { myFav } from '@/api/mine.js'
	export default {
		data() {
			return {
				list2: [{
					name: '全部',
				}, {
					name: '售卖中',
				}, {
					name: '已售出'
				}],
				list: [],
				page:1,
				num:10,
				lastPage:1
			}
		},
		onLoad() {
			let URL=window.location.href
			this.$wxH5Share.get_jssdk("收藏",URL)
		},
		onShow() {
			this.page = 1
			this.list= [ ]
			this.myFav()
		},
		methods: {
			async myFav(){
			  try {
			    const res = await myFav(this.page,this.num)
			    console.log('myFav', res)
				 res.list.data.forEach(it=>{
					 it.image = it.images_preview[0]
				 })
				this.list = this.list.concat( res.list.data)
				this.lastPage= res.list.last_page
			    // 保存数据
			  } catch (err) {
			 	uni.showToast({ title:err,icon:'none' })
			    console.log('myFav', err)
			  }
			},
			edit(e) {
				console.log('edit', e);
			},
			del(e) {
				console.log('del', e);
			},
			wapperClick(item) {
				uni.navigateTo({
					url:'/pages/index/detail?id='+item.id
				})
				console.log('单项点击事件', item)
			}
		},
		// 触底触发
		onReachBottom() {
			if(this.page >= this.lastPage) return
			this.page=this.page+1 
			this.myFav()
			// this.list = this.list.concat(this.list)
		},
	}
</script>

<style lang="less">
	page {
		background: #f6f6f6;
	}

	.misslist {
		padding: 32rpx 30rpx;
		// margin-top: 24rpx;
	}

	.u-sticky {
		top: 0 !important;
	}

	.item {
		padding: 24rpx;

		.title {
			color: rgba(0, 0, 0, 0.9);
			font-size: 26rpx;
			font-weight: 700;
		}

		.desc {
			justify-content: space-between;
			color: rgba(0, 0, 0, 0.6);
			font-size: 24rpx;

			.money {
				color: #F85317;
				font-size: 32rpx;
				font-weight: 700;
			}
		}

		.bot {
			display: flex;
			justify-content: flex-end;

			image {
				width: 40rpx;
				height: 40rpx;
			}
		}
	}

	.topState {
		z-index: 1;
		position: absolute;
		left: 0;
		top: 0;
		width: 132rpx;
		height: 56rpx;
		border-radius: 12rpx 0 24rpx 0;
		opacity: 1;
		background: rgba(254, 208, 0, 1);
	}

	.Sale {}

	.Sold {
		background: rgba(218, 218, 218, 1);
		color: rgba(0, 0, 0, 0.9);
		font-size: 26rpx;
	}
</style>