<template>
	<view class="wrap">
		<div class="preview-conatiner">
			<view class="title">{{viewData.taskTitle}}</view>		
		</div>
		<view class="content">				
			<view class="result">
				<view class="title">
					<text>内容</text>
				</view>
				<view class="result-conatiner">
					<span class="tag" v-for="(item,key) in viewData.taskContent" :key="key" >{{item.text}}</span>
				</view>
			</view>		
		</view>
	</view>
</template>

<script>
	import {updateMemory} from '@/api/user.js'
	export default{
		data(){
			return{
				readSrc:"",
				viewData:{
					taskTitle:"",
					taskContent:[]	
				},
				formData:{}
			}
		},
		onShow() {
			let info=uni.getStorageSync('detail-info')
			this.viewData=info
			let taskContentNew=[]
			let items=info.taskContent.split(/[\s\n]/).filter(item=>item!=="");
			items=items.map((item,index)=>{
				return {
					text: item,
					value: index,
					checked:0
				}
			})
			if(!this.isEmpty(info.taskContentNew)){
				taskContentNew=info.taskContentNew.split(/[\s\n]/).filter(item=>item!=="");
				taskContentNew=taskContentNew.map((item,index)=>{
					return {
						text: item,
						value: index,
						checked:1
					}
				})				
			}
			this.viewData.taskContent=items.concat(taskContentNew)
		},
		onUnload() {
			uni.removeStorageSync('detail-info')
		},
		methods:{
			isEmpty(val){
				if(val!=="undefined"&&val!==undefined&&val!==""&&val!==null){
					return false
				}
				return true
			}			
		}
	}
</script>

<style lang="scss" scoped>
*{
	padding: 0;
	margin: 0;
}
.wrap{	
	padding:20rpx;
	.title{
		height: 40rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		line-height: 40rpx;
		color: #333333;
		opacity: 1;	
		padding:0 0 36rpx 20rpx;
		position: relative;
		&::after{
			width: 12rpx;
			height: 28rpx;
			background:#2A83EF;
			opacity: 1;
			border-radius: 6px;					
			content: "";
			display: block;
			position: absolute;
			left: 0;
			top: 8rpx;
		}
	}	
	.content{
		padding: 10rpx;
		margin-top: 24rpx;
		::v-deep .uni-forms-item__content{
			display: flex;
			align-items: center;
			flex-wrap: wrap;
		}
		.title{
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		.tag{
			padding: 8rpx 20rpx;
			margin:10rpx ;
			background-color: #2A83EF;
			color: #fff;
			border-radius: 5rpx;
		}
	}	
}
</style>