<template>
	<view class="kudos">
		<!-- 点赞列表 -->
		<view class="List">
			<view class="ListItem" v-for="(item,index) in List" @click="goVoteDetail(item.id)">
				<image src="http://t9.9026.com/imgs/Kudosbg.png" style="width: 640rpx;height:420rpx;"></image>
				<view class="kudosicon">
					<image src="/static/icon/Kudos.png" v-if="item.is_like!=1" @click.stop="clickKudos(item.id,index)"></image>
					<image src="/static/icon/Kudos(1).png" v-if="item.is_like==1" @click.stop="clickKudos(item.id,index)"></image>
				</view>
				<view class="nav">
					<view class="events">
						<text>{{item.title}}</text>
					</view>
					<view class="voteStatus">
						<text v-if="false">未开始</text>
						<text style="color:#FF6503 ;">投票中</text>
					</view>
				</view>
				<view class="foot">
					<image src="/static/icon/data.png"></image>
					<text>{{item.end_time}} 结束</text>
				</view>
			</view>
		</view>
		<!-- 已经到底啦 -->
		<uni-load-more :status="status" color="#CCCCCC" :content-text="contentText"/>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				//组件uni-load-more
				status: 'noMore',
				contentText: {
					contentdown: '查看更多',
					contentrefresh: '加载中',
					contentnomore: '——  已经到底啦  ——'
				},
				// 点赞列表
				List:[],
			}
		},
		onLoad() {
			this.getList()
		},
		methods:{
			// 获取点赞列表
			getList(){
				this.$api.active.getActiveList({
					page:1,
					is_my_like:1
				}).then(res=>{
					console.log(res,"点赞列表")
					if(res.code==0){
						this.List=res.data.data
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				})
			},
			// 跳转投票详情
			goVoteDetail(id){
				uni.navigateTo({
					url:'/pages/index/active-detail/index?id='+id
				})
			},
			// 点赞
			clickKudos(id,index){
				let beforeLike=this.List[index].is_like
				this.$api.active.kudos({
					activity_id:id
				}).then(res=>{
					console.log(res,'点赞')
					if(res.code==0){
						if(beforeLike==1){
							this.List[index].is_like=0
						}else{
							this.List[index].is_like=1
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	$pageColor:#F9F9F9;
	$bgColor:#FFFFFF;

	@mixin flexlayout {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.kudos {
		height: 100%;
		background: $pageColor;
	}

	.List {
		padding: 0 30rpx;
		box-sizing: border-box;
		padding-top: 24rpx;

		.ListItem {
			position: relative;
			margin-bottom: 24rpx;
			width: 690rpx;
			height: 562rpx;
			background: $bgColor;
			box-shadow: 0rpx 12rpx 40rpx 0rpx rgba(220, 222, 229, 0.4);
			border-radius: 24rpx;
			padding: 20rpx 26rpx 26rpx 24rpx;

			.kudosicon {
				width: 48rpx;
				position: absolute;
				top: 52rpx;
				right: 58rpx;
				border-radius: 50%;
				height: 48rpx;
				background: #FFFFFF;
				opacity: 0.84;
				@include flexlayout()
				image{
					width: 29rpx;
					height: 26rpx;
				}
			}

			.nav {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.events {
					text {
						font-size: 30rpx;
						font-family: PingFang-SC-Bold, PingFang-SC;
						font-weight: bold;
						color: #333333;
					}
				}

				.voteStatus {
					font-size: 30rpx;
					font-family: PingFang-SC-Medium, PingFang-SC;
					font-weight: 500;
					color: #999999;
				}
			}

			.foot {
				margin-top: 10rpx;
				display: flex;
				align-items: center;

				image {
					width: 28rpx;
					height: 28rpx;
					margin-right: 8rpx;
				}

				text {
					font-size: 24rpx;
					font-weight: 500;
					color: #999999;
					display: block;
				}
			}

		}
	}
</style>
