<template>
	<view>
		<view class="line"></view>
		<view class="list" v-if="contentList && contentList.length > 0">
			<!-- :url="'/topic/content/content?id=' + item.id" -->
			<navigator :url="'/integralshop/content/content?id=' + item.id" hover-class="none" class="li" v-for="(item, index) in contentList" :key="index">
				<image :src="item.pic" mode="aspectFill" class="li-img"></image>
				<view class="info">
					<view class="title">{{ item.title }}</view>
					<view class="time ddflex">
						<image src="../../static/pages/images/nearbytime.png"></image>
						{{ item.createDate }}
					</view>
					<view class="opt ddflex" v-if="!bindId">
						<view class="browse">{{item.browse}}次浏览</view>
						<!-- <view class="ddflex">
							<view class="opt-btn ddflex">
								<image src="../../static/images/like.png"></image>
								99+
							</view>
							<view class="opt-btn ddflex">
								<image src="../../static/images/comment.png"></image>
								99+
							</view>
							<view class="opt-btn ddflex">
								<image src="../../static/images/jifen.png"></image>
								+50
							</view>
						</view> -->
					</view>
				</view>
			</navigator>
		</view>

		<view class="nodata" v-else>
			<image :src="picUrlss + 'empty_dd.png'"></image>
			<text>暂无活动</text>
		</view>
	</view>
</template>

<script>
// pages/sort/sort.js
//获取应用实例
const app = getApp();
const req = require('../../utils/request.js');

export default {
	data() {
		return {
			picUrlss: req.public.picUrls,
			bindId: '',
			form: {
				page: 1,
				limit: 10
			},
			contentList: [],
			isLoad: true
		};
	},

	onLoad: async function(options) {
		this.bindId = options.bindId;
		// if (this.bindId) {
		this.getContentList(true);
		// }
	},

	onShow() {},

	onReachBottom() {
		this.form.page++;
		this.getContentList(false);
	},

	methods: {
		getContentList(isShow) {
			if (!this.isLoad) return false;
			this.isLoad = false;
			let form = this.form;
			if (this.bindId) {
				form.cid = this.bindId;
			} else {
				//获取个人数据
				form.isMyData = 1;
			}
			req.getRequest(
				'/api/content/list',
				form,
				res => {
					if (res && res.length == 10) {
						this.isLoad = true;
					}
					if (this.form.page > 1) {
						res = this.contentList.concat(res);
					}
					this.contentList = res;
				},
				isShow
			);
		}
	}
};
</script>
<style>
@import './index.css';
</style>
