<template>
	<view>
		<u-navbar :is-back="false" :border-bottom="false"><view class="navbar-tit">点赞</view></u-navbar>
		<view class="praise">
			<view class="praiseLink">
				<view class="praiseLink-item" style="" @click="toIPraise">
					<view class="praiseLink-tit">
						<h4>我点赞的</h4><span></span>
					</view>
				</view>
				<view class="praiseLink-item praiseLink-bg2" @click="toPraiseMe">
					<view class="praiseLink-tit">
						<h4>谁点赞了我</h4><span v-if="newLike">+{{newLike}}</span>
					</view>
					<p>{{likeINum}}人点赞了我</p>
				</view>
			</view>
			<view class="title">互相点赞联系双方</view>
			<view class="praiseMain" v-if="homePageList.length > 0">
				<view class="praiseMain-item" v-for="(item ,index) in homePageList" :key="item.id">
					<view class="praiseMain-tit">恭喜配对成功!</view>
					<view class="praiseMain-pic">
						<view class="praiseMain-pic-item">
							<u-image class="newsList-img" :src="item.beLikeMemberFaceImage+'?x-oss-process=image/resize,m_fill,w_256,h_256'" height="260" width="260" border-radius="10"></u-image>
						</view>
						<view class="praiseMain-heart">
							<u-icon custom-prefix="custom-icon" name="heart-2-fill" size="36px" color="#fff"></u-icon>
						</view>
						<view class="praiseMain-pic-item">
							<view class="praiseMain-add" v-if="item.chatNotReadNum != '0'">
								{{item.chatNotReadNum}}条未读消息
							</view>
							<u-image class="newsList-img" :src="item.likeMemberFaceImage+'?x-oss-process=image/resize,m_fill,w_256,h_256'" height="260" width="260" border-radius="10"></u-image>
						</view>
					</view>
					<view class="praiseMain-pic-text">恭喜！您与「{{item.likeMemberName}}」相互点赞！</view>
					<view class="praiseMain-btn">
						<u-button type="error" shape="circle"  @click="gotoUrl('pages/user/message?id='+item.likeMemberId)" :custom-style="customStyle">联系Ta</u-button>
					</view>
				</view>
			</view>
			<view class="jpDefault" v-else>
				<u-image width="179px" height="126px" src="/static/img/default1.png"></u-image>
				<p>暂无配对成功记录</p>
			</view>
		</view>
 	</view>
</template>

<script>
	import * as likesApi from '@/apis/likes.js'
	
	export default {
		data() {
			return {
				newLike: '',
				likeINum: '',
				homePageList: [],
				customStyle: {
					background: '#FF5E5E'
				},
			}
		},
		onShow() {
			if(this.carhelp.getPersonInfo().id != null) {
				this.getHomePage(true);
			}
		},		
		methods: {
			toIPraise() {
				if(this.carhelp.getPersonInfo().id != null) {
					uni.navigateTo({
						url: '/pages/praise/iPraise'
					});
				} else {
					uni.showToast({
						title: "请用户先登录再浏览本页面",
						icon: "none"
					})
				}
			},
			toPraiseMe() {
				if(this.carhelp.getPersonInfo().id != null) {
					uni.navigateTo({
						url: '/pages/praise/praiseMe'
					});
				} else {
					uni.showToast({
						title: "请用户先登录再浏览本页面",
						icon: "none"
					})
				}
			},
			getHomePage(bl) {
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				if (bl) {
					this.likeList = [];
				}
				likesApi.homePage().then((res) => {
					this.newLike = res.data.likeINotReadNum;
					this.likeINum = res.data.likeINum;
					this.homePageList = res.data.eachOtherPage.data;
					uni.hideLoading();
				}).catch(error => {
					uni.showToast({
						title: error,icon: "none"
					})
				})
			},
		}
	}
</script>
<style>
	page{
		background-color: #f4f0f0;
	}
</style>
<style lang="scss" scoped>
	.jpDefault{
		padding-top:90px;
		display: flex;
		flex-direction: column;
		align-items: center;
		p{
			color: #A69F9F;
			font-size: 16px;
			margin-top: 12px;
		}
	}
	.newsList-img{
		z-index: -1;
	}
	.title{
		font-size: 16px;
		margin-bottom: 10px;
		margin-left: 15px;
	}
	.praiseMain{
		.praiseMain-item{
			margin: 15px;
			background-color: #fff;
			border-radius: 12px;
			padding: 20px;
			position: relative;
		}
		.praiseMain-heart{
			height: 60px;
			width: 60px;
			background-color: #FF5E5E;
			position: absolute;
			border-radius: 50%;
			top: 95px;
			left: 50%;
			margin-left: -30px;
			z-index: 99;
			line-height: 60px;
			text-align: center;
		}
		.praiseMain-tit{
			font-size: 24px;
			color:#FF5E5E;
			margin-bottom: 10px;
			text-align: center;
		}
		.praiseMain-pic{
			display: flex;
			justify-content: space-between;
			padding: 0 15px;
		}
		.praiseMain-pic-text{
			font-size: 16px;
			text-align: center;
			margin: 15px 0;
		}
		.praiseMain-btn{
			padding: 0 15px;
		}
		.praiseMain-pic-item{
			position: relative;
		}
		.praiseMain-add{
			position: absolute;
			background:rgba(0,0,0,0.5);
			height: 20px;
			z-index: 9;
			border-radius: 0 0 5px 5px;
			left: 0;
			right: 0;
			bottom: 0;
			color:#fff;
			text-align: center;
			font-size: 12px;
			line-height: 20px;
			backdrop-filter: blur(8px);
			/* Note: backdrop-filter has minimal browser support */
		}
	}
	.navbar-tit{
		padding-left:15px;
		font-size: 24px;
	}
	.praiseLink{
		margin: 16px;
		display: flex;
		justify-content: space-between;
		.praiseLink-item{
			height: 80px;
			background:url(../../static/img/listbg.png) no-repeat #fff right bottom;
			background-size:65px 45px;
			flex: 0.47;
			padding: 20px;
			border-radius: 12px;
			.praiseLink-tit{
				display: flex;
				align-items: center;
				span{
					font-size: 12px;
					color:#fff;
					background-color: #FF5E5E ;
					padding: 0 4px;
					border-radius: 4px;
					margin-left: 5px;
				}
				h4{
					font-size: 16px;
					font-weight: normal;
				}
			}
			p{
				color:#999;
				font-size: 12px;
				margin-top: 3px;
			}
		}
		.praiseLink-bg2{
			background:url(../../static/img/listbg2.png) no-repeat #fff right bottom;
			background-size:65px 45px;
		}
	}
</style>
