<template>
	<view class="content">
		<view v-if="curTab == 2" class="pageCon"><course-list :flag="1" :list="list"></course-list></view>
		<!-- <view v-if="curTab == 2" class="pageCon"><goods :flag="1" :list="list"></goods></view> -->
		<view v-if="curTab == 3" class="pageThr"><hotgods :flag="1" :list="list"></hotgods></view>
	</view>
</template>

<script>
import courseList from '../../index/components/knowVidList.vue';
import hotgods from '../../../pagesA/mall/componets/hotgodlist.vue';
export default {
	components: {
		courseList,
		hotgods
	},
	data() {
		return {
			type:1,  // 1=收藏 2下载 3.点赞
			curTab:2 ,//  1=商品  2=文档  3=视频
			list: [
				// { image: '/static/img/pro/indnotice.png', name: '知识过关', path: '/pages/knowledge/knowledge' },
				// { image: '/static/img/pro/indnotice.png', name: '知识过关', path: '/pages/knowledge/knowledge' },
				// { image: '/static/img/pro/indnotice.png', name: '知识过关', path: '/pages/knowledge/knowledge' },
			],
			status:'loadmore',
			page:1,
			pagenum:10,
		};
	},
	onPullDownRefresh() {
		setTimeout(res => {
			uni.stopPullDownRefresh();
		}, 1000);
	},

	onReachBottom() {
		if (this.status == 'nomore') return;
		this.status = 'loadmore';
		this.page = ++this.page;
		this.getInfoList();
	},
	onLoad(opt) {
		this.type=opt.type||1; 
		if(this.type==1){
			uni.setNavigationBarTitle({
				title:'我的收藏'
			})
		}else if(this.type==2){
			uni.setNavigationBarTitle({
				title:'我的下载'
			})
		}else if(this.type==3){
			uni.setNavigationBarTitle({
				title:'我的点赞'
			})
		} 
		this.getInfoList();
	},
	methods: {
		getInfoList() {
			let url=this.type==1?'collection/getCollectionList':this.type==2?'user/myDownList':'user/getTeamList';
			this.$api
				.request(url, {
					type:this.curTab,
					page: this.page,
					limit: this.pagenum
				})
				.then(data => {
					if (data.code == '200') {
						this.list = this.list.concat(data.data);
						if (data.data.length < this.pagnum) {
							this.status = 'nomore';
						}
					} else {
						this.$api.toast(data.msg);
					}
				});
		},
		toNext(url) {
			uni.navigateTo({
				url: url
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.pageCon {
	padding: 20rpx 30rpx;
}
.pageThr {
	padding: 20rpx 0;
}
</style>
