<template>
	<view class="content bgfff">

		<!-- 列表 -->
		<view class="box">
			<view class="product">
				<view class="newslist" v-for="(item,index) in newsList" :key="index" @click="handleActive(item.id)">
					<view class="right">
						<image :src="item.url_data" mode="aspectFit"></image>
					</view>
					<view class="left">
						<view class="title">
							{{item.title}}
						</view>
						<view class="">
							报名人数：{{item.people_num}}
						</view>
					</view>
					<view class="time isAddress c999 ">
						<icon class="iconfont icon-icon-test1"></icon>
						{{item.start_time}} 至 {{item.end_time}}
					</view>
				</view>
			</view>
			<view class="nolist" style="margin-top: 15px;" v-if="!newsList.length">
				<image src="@/static/none.png"></image>
				<text>暂无数据</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	export default {
		data() {
			return {
				page: 1,
				lastPage: 1,
				newsList: [],
			}
		},
		onLoad() {
			let that = this
			that.page = 1
			that.handleInfoList()
		},
		onReachBottom() {
			let that = this
			console.log("this.lastPage", this.lastPage)
			if (!this.lastPage || this.page >= this.lastPage) {
				uni.showToast({
					title: '没有更多数据！',
					icon: 'none'
				})
				return
			}
			this.page++
			this.handleInfoList()
		},
		// onShareAppMessage() {
		// 	let that = this
		// 	return {
		// 		title: "智照团线上展厅",
		// 		path: '/pageTwo/news/list?type=' + that.type,
		// 		imageUrl: '',
		// 		success: function(res) {
		// 			console.log("分享到朋友成功")
		// 		},
		// 		fail: function(res) {
		// 			console.log("分享到朋友失败")
		// 		},
		// 	}
		// },
		// onShareTimeline() {
		// 	let that = this
		// 	return {
		// 		title: "智照团线上展厅",
		// 		query: 'type=' + that.type,
		// 		imageUrl: '',
		// 		success: function(res) {
		// 			console.log("分享到朋友成功")
		// 		},
		// 		fail: function(res) {
		// 			console.log("分享到朋友失败")
		// 		},
		// 	}
		// },
		methods: {
			handleInfoList() {
				let that = this
				that.$model.getCampaignList({
					page: this.page
				}).then((res) => {
					if (res.code != 0) return
					console.log("1111", res)
					that.newsList = that.newsList.concat(res.data.content_list)
					that.lastPage = res.data.page_total
				})
			},
			handleActive(id) {
				let that = this
				uni.navigateTo({
					url: "/pageTwo/campaign/detail?id=" + id
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.box {
		width: 100%;
	}

	.marginTop {
		margin-top: 85px;
	}

	.tabbar {
		width: 100%;
		margin-top: 75px;
		display: flex;
		justify-content: space-around;
		align-items: center;
		position: relative;
		background-color: #fff;

		view {
			font-size: 16px;
			height: 40px;
			line-height: 40px;
			padding: 0 25px;
			text-align: center;

		}

		.active {
			color: $blue;
			font-weight: bold;
			border-bottom: 2px solid $blue;
		}
	}

	.title {
		line-height: 24px !important;
	}

	.time {
		icon {
			margin-top: -7px !important;
		}
	}

	.tabbar::before {
		content: "";
		position: absolute;
		left: 50%;
		height: 40px;
		width: 1px;
		background-color: #dfdfdf;
	}
</style>