<template>
	<view>
		 <u-navbar   :share="share"    :back-text="newsDetail.title" back-icon-size="28" back-icon-color="#ffffff"
			:background="{backgroundColor: '#2795FD',}" :back-text-style="{color: '#ffffff'}"></u-navbar>
		
		
		<view class="main">
			<view class="title">
				{{newsDetail.title}}
			</view>
			<view class="date-views">
				<view class="date">
					{{newsDetail.createTime}}
				</view>
				<view class="views">
					<view class="icon">
						<img src="@/assets/img/riLine-eye-line Copy@1x.png" alt="">
					</view>
					<view class="number">
						{{newsDetail.browseNumber}}
					</view>
				</view>
			</view>
			<u-line  color="#e6e6e6"/>
			<view class="content news-content"  v-html="newsDetail.content" >
			
			</view>
			
		</view>
		<view  v-if="newsDetail.codeImage" class="codeImage">
			<image  mode="aspectFit"
			
			v-if="newsDetail.codeImage" :src="newsDetail.codeImage" :show-menu-by-longpress="true" ></image>
			<view  class="codeImageView" ><u-icon name="arrow-upward"></u-icon><u-icon name="arrow-upward"></u-icon><u-icon name="arrow-upward"></u-icon> 长按图片<u-icon name="arrow-upward"></u-icon><u-icon name="arrow-upward"></u-icon><u-icon name="arrow-upward"></u-icon></view>
		</view>
	</view>
</template>

<script>
	import * as API from '@/apis/pagejs/packages.js'
	export default {
		data() {
			return {
				id: '',
				share: 0,
				newsDetail: {
				  "id": "",
				  "title": "",
				  "category": "",
				   "content":"",
				  "browseNumber": 0,
				  "thumbnailImage": "",
				  "createBy": "",
				  "createTime": "",
				  "updateBy": "",
				  "updateTime": "",
				  "status": "1",
				  "codeImage": "",
				  "categoryN": ""
				},
			}
		},
		onShareTimeline(){
			return {
				title: this.newsDetail.title,
				path: '/pages/packages/news/articleDetail?shareMP=1&id=' + this.id
			}
		},
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				//.log(res.target)
			}
			return {
				title: this.newsDetail.title,
				path: '/pages/packages/news/articleDetail?shareMP=1&id=' + this.id
			}
		},
		onLoad(op) {
			if (op.shareMP) {
				this.share = op.shareMP
			}
			
			this.id =op.id;
			this.getNewsDetail();
		},
		methods: {
			customBack(){
				uni.redirectTo({
					url:"/pages/main/index/index"
				})
			},
			timestart(){
					console.log("aaa1")
			},
			timeend(){
					console.log("aaa2")
			},
			saveImg(){
					console.log("aaa3")
			},
			getNewsDetail() {
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				
				API.newsDetail({
					id:this.id
				}).then((res) => {
					uni.hideLoading()					
					var newsDetail = res.data.newsInfo;
					if(newsDetail.content){
						var reg=new RegExp('alt','gi');
						newsDetail.content=newsDetail.content.replace(reg,'width="100%" height="100%"  /> <p')	
						
					}
					this.newsDetail=newsDetail
				}).catch(error => {
					uni.showToast({icon: 'none',
						title: error,
						icon: "none"
					})
				})
			}
		}
	}
</script>
<style>
	page {
		background: #F0F0F2;
		padding-bottom: 120px;
	}
</style>

<style lang="scss" scoped>
	.codeImage{
		background-color: #fff;
		 text-align: center;
		.codeImageView{
			padding: 20rpx 0px 40rpx;
			font-size: 32rpx;
			 
		}
		image{
			 border: 1px dashed;
			width: 700rpx;
			
		}
	}
	.main{
		padding: 40rpx 32rpx;
		background-color: #fff;
		.title{
			color: rgba(16, 16, 16, 1);
			font-size: 40rpx;
			text-align: justify;
			line-height: 48rpx;
		}
		.date-views{
			margin-top: 64rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 32rpx;
			.date{
				color: rgba(119, 119, 119, 1);
				font-size: 24rpx;
			}
			.views{
				display: flex;
				align-items: center;
				color: rgba(119, 119, 119, 1);
				font-size: 12px;
				img{
					width: 32rpx;
					height: 32rpx;
					vertical-align: middle;
					margin-right: 8rpx;
				}
			}
		}
	  .content{
		  color: rgba(51, 51, 51, 1);
		  font-size: 32rpx;
		  line-height: 56rpx;
		  margin-top: 40rpx;
	  }
	.news-picture{
		margin-top: 32rpx;
		height: 310rpx;
	    overflow: hidden;
		img{
			width: 100%;
			height: 100%;
		}
	}
	.picture-title{
		color: rgba(119, 119, 119, 1);
		font-size: 24rpx;
		margin-top: 16rpx;
		text-align: center;
	}
	}

</style>
