<template>
	<view class="content">
		<view class="detail-cont">
			<view class="title">{{item.title}}</view>
			<view class="info">
				<view class="reads">阅读数：{{item.views}}</view>
				<view class="time">{{item.publishTime}}</view>
			</view>
			<!-- 正文 -->
			<view class="full-text">
				<view v-html="item.contents"></view>
			</view>
		</view>
		<!-- 最近阅读 -->
		<view class="recent-reads">
			<view class="left">
				<text class="label">最近阅读</text>
				<view class="peop-box"  >
					<view class="head-box">
						<view class="head" v-for="(subitem,j) in views" :key="j">
							<image :src="subitem.avatar==null?'/static/images/detault_head.jpg':subitem.avatar" mode=""></image>
						</view>
					</view>
					<image class="arrow" src="/static/images/arrow_gray.png" mode=""></image>
				</view>
				
			</view>
			<view class="share-btn"  @click="openShare()">
				<image src="/static/images/share.png" mode=""></image>
				<text>分享</text>
			</view>
		</view>
		<u-popup :show="show" @close="closeShare" >
			<view class="share-content">
				<view class="share-inner">
					<view class="share-item">
						<image src="/static/images/icon_wx.png" mode=""></image>
						<text class="text">微信</text>
					</view>
					<view class="share-item">
						<image src="/static/images/icon_pyq.png" mode=""></image>
						<text class="text">朋友圈</text>
					</view>
					<view class="share-item">
						<image src="/static/images/icon_xcxhb.png" mode=""></image>
						<text class="text">小程序海报</text>
					</view>
					<view class="share-item">
						<image src="/static/images/icon_xccard.png" mode=""></image>
						<text class="text">小程序卡片</text>
					</view>
					<view class="share-item">
						<image src="/static/images/icon_code.png" mode=""></image>
						<text class="text">二维码</text>
					</view>
					<view class="share-item">
						<image src="/static/images/icon_copy_link.png" mode=""></image>
						<text class="text">复制链接</text>
					</view>
				</view>
				<view class="cancel-btn" @click="closeShare">取消</view>
			</view>
		</u-popup>
	</view> 
</template>

<script>
	import {getArticleByArticleId,updateView} from '@/api/article'
	export default {
		data() {
			return {
				show:false,
				articleId:null,
				item:{},
				views:[],
			};
		},
		onLoad(option) {
			this.articleId=option.articleId;
			if(this.$isLogin()){
				this.updateView();
			}
		},
		onShow() {
			this.getArticleByArticleId();
		},
		methods:{
			openShare() {
				this.show = true
			},
			closeShare() {
			  this.show = false
			},
			updateView(){
				updateView(this.articleId).then(
					res => {
					},
					rej => { }
				);
			},
			getArticleByArticleId(){
				let data = {articleId:this.articleId};
				getArticleByArticleId(data).then(
					res => {
						if(res.code==200){
							this.item=res.data;
							this.views=res.views;
						}else{
							uni.showToast({
								icon:'none',
								title: "请求失败",
							});
						}
					},
					rej => {}
				);
			},
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
	.content{
		 height: 100%;
		 width: 100%;
	}
	.detail-cont{
		padding: 40upx 40upx 161rpx;
		overflow-y: auto;
		.title{
			font-size: 40upx;
			font-family: PingFang SC;
			// font-weight: bold;
			color: #222222;
			line-height: 70upx;
		}
		.info{
			display: flex;
			align-items: center;
			font-size: 24upx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #999999;
			line-height: 48upx;
			margin: 23upx 0;
			.reads{
				margin-right: 30upx;
			}
		}
		.full-text{
			font-size: 36upx;
			font-family: PingFang SC;
			// font-weight: 500;
			color: #222222;
			line-height: 60upx;
		}
	}
	.recent-reads{
		width: 100%;
		position:  fixed;
		bottom:0upx;
		left:0rpx;
		box-sizing: border-box;
		height: 121upx;
		background: #FFFFFF;
		border-top: 1px solid #F0F0F0;
		padding: 0 40upx 0 37upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		.left{
			display: flex;
			align-items: center;
			.label{
				font-size: 28upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;
				line-height: 1;
				margin-right: 20upx;
			}
			.peop-box{
				display: flex;
				align-items: center;
				.head-box{
					margin-right: 28upx;
					display: flex;
					align-items: center;
					.head{
						width: 48upx;
						height: 48upx;
						border-radius: 50%;
						overflow: hidden;
						box-shadow: 0 0 0 1px #fff;
						margin-right: -10upx;
						image{
							width: 100%;
							height: 100%;
						}
					}
				}
				.arrow{
					width: 13upx;
					height: 23upx;
				}
			}
		}
		.share-btn{
			 
			width: 240upx;
			height: 80upx;
			line-height: 80upx;
			font-size: 30upx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			background: #2BC7B9;
			border-radius: 40upx;
			display: flex;
			align-items: center;
			justify-content: center;
			image{
				width: 32upx;
				height: 32upx;
				margin-right: 15upx;
			}
			.share{
				position: absolute;
				width: 100%;
				height: 100%;
				opacity: 0;
			}
		}
	}
	 
	.share-content{
		background-color: #FFF;
		border-radius: 40upx 40upx 0px 0px;
		.share-inner{
			padding: 70upx 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>
