<template>
	<view class="content main-bg">
		<view class="list" v-if="list.length > 0">
			<view class="item" v-for="item in list">
				<view class="time font-color3 font-twenty-four">{{ item.reviewerTime }}</view>
				<view class="text font-color3 font-thirty-two">{{ item.msgInfo ? item.msgInfo : '' }}</view>
				<view class="reason font-color3 font-twenty">{{ item.remark ? item.remark : '' }}</view>
			</view>
		</view>
		<view class="empty" v-else>
			<u-empty text="暂无消息" mode="list"></u-empty>
		</view>
		<u-tabbar :list="tabBarList" :active-color="activeColor" :inactive-color="inactiveColor"
					:border-top="borderTop"></u-tabbar>
	</view>
</template>

<script>
import { mapGetters } from 'vuex'
import server from "@/api/index";
export default {
	data() {
		return {
			borderTop: false,
			inactiveColor: '#ccc',
			activeColor: '#2E4F1C',
			list: [],
			userInfo:{}
		}
	},
	computed: {
		...mapGetters([
			'tabBarList',
			'role'
		])
	},
	onLoad() {
		setTimeout(function () {
			console.log('start pulldown');
		}, 1000);
		uni.startPullDownRefresh();
	},
	onPullDownRefresh() {
		this.userInfo = uni.getStorageSync('userInfo');
		this.getListFn();
		setTimeout(function () {
			uni.stopPullDownRefresh();
		}, 1000);
	},
	methods:{
		show(){
			this.userInfo = uni.getStorageSync('userInfo');
			this.getListFn();
		},
		getListFn(){
			if(this.userInfo.type === '2'){
				server.getNews({veteransId: this.userInfo.userId, msgType: this.userInfo.type}).then(res =>{
					this.list = [];
					if(res){
						this.list = res
					}
				})
			}else if(this.userInfo.type === '1'){
				server.getNews({veteransId: this.userInfo.nickName, msgType: this.userInfo.type}).then(res =>{
					this.list = [];
					if(res){
						this.list = res
					}
				})
			}
		}
	}
}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		height: auto;
		min-height: 100vh;
		padding: 30rpx;
		.empty{
			padding-top: 200rpx;
		}
		.list{
			width: 100%;
			.item{
				width: 100%;
				min-height: 165rpx;
				height: auto;
				background: #FFFFFF;
				border-radius: 24rpx;
				padding: 30rpx;
				margin-bottom: 30rpx;
				.text{
					padding-top: 30rpx;
					font-weight: 600;
					letter-spacing: 2rpx;
				}
				.reason{
					padding-top: 22rpx;
					line-height: 40rpx;
				}
			}
		}
	}
</style>
