<template>
	<view>
		<uni-nav-bar  left-icon="left" :statusBar="true"  title="Message" 
		color="#fff" backgroundColor="#000000"  @clickLeft="back"  :border="false"/>
		
		<view class="body">
			<view class="msg_item" v-for="(item,index) in list.blocks" :key="item.block_title" @click="gotopage(item)">
				<view class="msg_time">{{item.block_avaiable_from | Mes}}</view>
				<view class="msg_title">{{item.block_title}}</view>
				<!-- <view class="msg_content">{{item.}}</view> -->
				<view class="msg_img" v-if="item.block_pic"><image :src="item.block_pic" class="imagesize"></image></view>
			</view>
			<view class="msg_item" v-for="(item,index) in app_Mes" :key ="item.id">
				<view class="msg_time">{{ item.add_time | Mes}}</view>
				<view class="msg_title">{{ item.mtitle }}</view>
				<view class="msg_content">
				</view>
			</view>
			<!-- <view class="msg_item">
				<view class="msg_time">21/04/2022 14:42:31</view>
				<view class="msg_title">Message heading</view>
				<view class="msg_content">
					estimated to be deliverd on estimated to be deliverd on estim
					ated to be deliverd on estimated to be deliverd on
				</view>
				<view class="msg_img"></view>
			</view> -->
		</view>
	</view>
</template>


<script>
	import {defaultRequest} from '../../api/index.js'
	export default {
		data() {
			return {
				list:[],
				myMes:{
					_action:'getmessagelist',
					type:0,
					importance:'',
					label:'',
					title:'',
					page_index:1,
					page_size:10
				},
				app_Mes:[]
			}
		},
		filters:{
			Mes(e){
				let str = e
				str=str.substring(0,10);
				const year = str.substring(0,4)
				let date = str.substring(5,10)
				date = date.replace('-','/')
				let time = date + '/'+year
				return time
			}
		},
		methods:{
			// getList(){
			// 	let data={_action:'getfavourableactivities'}
			// 	defaultRequest(data).then(res=>{
			// 		console.info(res)
			// 		if(res.error==0){
			// 			// this.list=res.data
						
			// 		}
			// 	})
			// },
			getMes(){
				let data ={ _action:'getpagedata',pagecode:'006-PERSONALCENTERPAGE'
					
				}
				let a=0, b =0
				defaultRequest(data).then(res =>{
					
					let list = res.data.zones
					
					list.map(item =>{
						if(item.zone_code =='XIAOXI'){
							this.list = item
							
						}
					})
					console.log(this.list.blocks.length)
					a = this.list.blocks.length
					let str = this.list.blocks[0].block_avaiable_from
					
				})
				defaultRequest(this.myMes).then(res =>{
					console.log(res)
					if(res.error ==0){
						this.app_Mes = res.data.message_list
						b = this.app_Mes.length
						console.log(this.app_Mes.length)
					}
				 let sum = parseInt(a) + parseInt(b)
				 console.log(sum)
				
				})
			},
			gotopage(item){
				console.log(item.block_link)
				const i = item.block_link.indexOf('?')
				const src = item.block_link.substring(i)
				if(item.block_link.includes('goodslist')){
					uni.navigateTo({
						url:'../category/productList'+src
					})
				}else{
					uni.navigateTo({
						url:'../productDetails/index'+src
					})
				}
			},
			back(){
				uni.navigateBack()
			}
		},
		onLoad() {
			// this.getList()
			this.getMes()
		}
	}
</script>

<style lang="scss" scoped>
	.uni-navbar{
		font-size: 32rpx;
		font-weight: bold;
	}
	.body{
		// border-top: 13.33rpx #F7F7F7 solid;
		padding:0 26.67rpx;
	}
	.msg_item{
		padding-top: 42.67rpx;
		padding-bottom: 28rpx;
		// border-bottom: 1px solid #E2E2E2;
		
		.msg_time{
			font-size: 25.33rpx;
			font-weight: 400;
			text-align: center;
			margin-bottom: 41.33rpx;
		}
		.msg_title{
			font-size: 28rpx;
			margin-bottom: 20rpx;
		}
		.msg_content{
			color: #555555;
			font-size: 25.33rpx;
			font-weight: 400;
			
		}
		.msg_img{
			margin-top: 37.33rpx;
		
			width: 100%;
			height: 281.33rpx;
			background-color: #ffdcd3      ;
			
			
		}
	}
	.msg_item:last-child{
		border-bottom: none;
	}
	.imagesize{
		width: 100%;
		height: 100%;
	}
</style>