<template>
	<view class="share-content">
		<view class="share-inner">
			<view class="share-item" @click="doReport()">
				<image src="/static/svg/report_icon.svg" mode=""></image>
				<text class="text">举报</text>
			</view>
			<view class="share-item" @click="doBlock()">
				<image src="/static/svg/block_icon.svg" mode=""></image>
				<text class="text">{{expertItem.isBlackTalent?"解除拉黑":"拉黑"}}</text>
			</view>
		
		</view>
		<view class="cancel-btn" @click="closeShare">取消</view>
	</view>

</template>

<script>
	import {  addBlackVideo,addBlackTalent,cancelBlack } from '@/api/expert'
	export default {
		name: "expert-box",
		props: {
			expertItem: {
				type: Object,
				default: function() {
					return {
						imageUrl: "",
						title: "",
						url: "",
						summary: url,
						courseId: 0,
						videoId: 0,
						talentId:0,
						isBlackTalent:false
					}; 
				}
			},
		},
		data() {
			return {
				
			};
		},
		methods: {
			doReport() {
				uni.navigateTo({
					url: "/pages/user/feedback?talentId="+this.expertItem.talentId+"&type=2"
				});
			},
			doBlock() {
				let that=this;
				if(this.expertItem.isBlackTalent){
					this.cancelBlackAct();
				}else{
					uni.showActionSheet({
						title:"拉黑后，将屏蔽对方作品",
						itemList: ["确定拉黑"],
						success: function(res) {
							that.doBlockAct();
						}
					});
				}
			},
			doBlockAct() {
				let params={"talentId":this.expertItem.talentId, "type": "1" };
				addBlackTalent(params).then(res => {
						if (res.code == 200) {
							uni.showToast({
								title: "操作成功",
								icon: 'none'
							});
							this.$emit('refreshExpert');
							
						}else{
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
						}
					},
					rej => {}
				);
			},
			cancelBlackAct() {
				let params={"talentId":this.expertItem.talentId };
				cancelBlack(params).then(res => {
						if (res.code == 200) {
							uni.showToast({
								title: "操作成功",
								icon: 'none'
							});
							this.$emit('refreshExpert');
							
						}else{
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
						}
					},
					rej => {}
				);
			},
			closeShare() {
				return this.$emit('closeExpert');
			},
		}
	}
</script>

<style lang="scss" scoped>
	.share-content {
		background-color: #FFF;
		border-radius: 40upx 40upx 0px 0px;
		.share-inner {
			padding: 50upx 0 0 0;
			display: flex;
			flex-wrap: wrap;
			.share-item {
				width: 25%;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				margin-bottom: 66upx;
				image {
					width: 80upx;
					height: 80upx;
					margin-bottom: 20upx;
				}
				.text {
					font-size: 28upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #111111;
					line-height: 1;
				}
			}
		}
		
		.cancel-btn {
			height: 96upx;
			line-height: 96upx;
			text-align: center;
			font-size: 32upx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #111111;
			border-top: 2upx solid #E8E8E8;
			background-color: #FFF;
		}
	}
</style>