<template>
	<view class="body">
		<view class="inputstyle">
			<image src="../../static/se.png" mode=""></image>
			<input type="text" v-model="name" placeholder="検索"  @blur="search"/>
		</view>
		<view class="content">
			<view class="item" v-for="item in list" :key="item.id">
				<view class="itempic" :style="{backgroundImage:`url(${item.thumbnail})`}">
					<view class="left-cover">
						<image v-if="!item.whetherLike"  src="../../static/heat.png" mode=""></image>
						<image v-if="item.whetherLike" @click.stop="unlike(item.id)" src="../../static/278.png" mode=""></image>
						<view class="number">
							{{item.likeNumInt}}
						</view>
					</view>
				</view>
				<view class="text">
					{{item.collectionName}}
				</view>
				<view class="textname">
					{{item.artistName}} #{{item.issueNumber}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{}, {}, {}, {}, {}, {}],
				name:""
			}
		},
		onShow() {
			this.mylike();
		},
		methods: {
			//查询点赞作品 
			async mylike() {
				const res = await this.$myRequest({
					url: '/api/foreignAuth/inquireLike?name='+this.name,
					header: {
						token: uni.getStorageSync("token"),
						Authorization: uni.getStorageSync("Authorization"),
					},
				})
				if (res.data.code == 200) {
					this.list = res.data.rows
				}
			},
				
			search(){
				this.mylike();
			},
			//取消点赞
			async unlike(id){
				const res = await this.$myRequest({
					url: '/api/foreignAuth/donPraise?id='+id,
					header: {
						token: uni.getStorageSync("token"),
						Authorization: uni.getStorageSync("Authorization"),
					},
				})
				if(res.data.code==200){
					uni.showToast({
						title: "取消点赞成功"
					})
					this.mylike();
				}else{
					uni.showToast({
						title: res.data.msg
					})
				}
			},
		}
	}
</script>

<style lang="scss">
	.body {
		padding-top: 0rpx;
		display: flex;
		flex-direction: column;
		background-color: #000000;
		min-height: 1340rpx;
		font-family: Arial-Regular;

		.inputstyle {
			margin-left: 54rpx;
			width: 660rpx;
			height: 80rpx;
			background: #1C1C1C;
			border-radius: 14rpx;
			display: flex;
			align-items: center;
			color: #FFFFFF;

			image {
				margin-left: 18rpx;
				width: 30rpx;
				height: 30rpx;
				margin-right: 16rpx;
			}
		}

		.content {
			display: flex;
			flex-wrap: wrap;

			.item {
				color: #FFFFFF;
				width: 324rpx;
				height: 446rpx;
				background-color: #1C1C1C;
				border-radius: 24rpx;
				margin-left: 36rpx;
				margin-top: 40rpx;

				.itempic {
					width: 324rpx;
					height: 324rpx;
					background-repeat: no-repeat;
					background-size: cover;
					overflow: hidden;
					border-radius:12rpx;

					.left-cover {
						margin-top: 18rpx;
						width: 94rpx;
						height: 40rpx;
						background:rgba(0,0,0,0.5);
						border-radius: 8rpx;
						font-size: 24rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						margin-left: 24rpx;

						image {
							width: 24rpx;
							height: 24rpx;
							margin-left: 12rpx;
							margin-top: 0rpx;
						}

						.number {
							margin-left: 8rpx;
						}
					}
				}

				.text {
					font-size: 28rpx;
					margin-left: 24rpx;
					margin-top: 16rpx;
				}

				.textname {
					margin-top: 16rpx;
					font-size: 28rpx;
					margin-left: 24rpx;
				}
			}
		}

	}
</style>
