<template>
	<view>
		<nav-bar title="我的消息"></nav-bar>
		<view v-if="!listData.length"><u-empty text="消息列表为空" mode="message"></u-empty></view>
		<view v-else v-for="(item, index) in listData" :key="index" style="padding-bottom: 20rpx;">
			<navigator hover-class="none" :url="`/pages2/msg/detail?id=${item.id}&orderGoodsId=${item.orderGoodsId}&goodsId=${item.goodsId}`" class="item" :style="item.receiptStatus === 1 ? 'opacity: 0.7' : ''">
				<view style="display: flex;justify-content: space-between;align-items: center;height: 60rpx;">
					<view style="color: #333333;font-size: 30rpx;font-weight: bold;display: flex;align-items: center;">
						<image :src="item.systemStatus === 1 ? img1 : img2" style="width: 40rpx;height: 40rpx;margin-right: 10rpx;"></image>
						{{item.systemStatus === 1 ? '系统通知' : '教务通知'}}
					</view>
					<view style="color: #999999;font-size: 24rpx;">{{ $method.timestampToTime(item.sendTime, false) }}</view>
				</view>
				<u-line color="#D6D6DB" />
				<view style="display: flex;justify-content: space-between;padding: 25rpx;color: #666666;">
					{{ item.systemStatus === 2 ? item.informVo.informName : item.systemStatus === 1 ? item.text : '接口异常' }}
				</view>
				<u-line color="#D6D6DB" />
				<view style="display: flex;justify-content: space-between;align-items: center;height: 50rpx;margin-top: 10rpx;padding: 0 25rpx;">
					<view class="color: #333333;font-size: 28rpx;">查看详情</view>
					<view><u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
				</view>
			</navigator>
		</view>
		<u-divider v-if="totals !== 0 && listData.length === totals" bg-color="#eaeef1">到底了</u-divider>
	</view>
</template>

<script>
import { mapGetters } from 'vuex';
export default {
	components: {},
	data() {
		return {
			list: [
				{
					name: '待支付'
				},
				{
					name: '已支付'
				},
				{
					name: '已取消'
				}
			],
			list1: [1, 2, 3, 4, 5, 6, 7],
			current: 0,
			img1: '/static/icon/msg_icon1.png',
			img2: '/static/icon/msg_icon2.png',
			listData: [],
			totals: 0,
			formData: {
				systemStatusList:'1,2',
				pageNum: 1,
				pageSize: 8
			}
		};
	},
	onPullDownRefresh() {
		this.formData.pageNum = 1
		this.$api
			.getappinformUserlist(this.formData)
			.then(res => {
				if (res.data.code === 200) {
					this.listData = res.data.rows;
					this.totals = res.data.total;
				}
			})
			.finally(() => {
				uni.stopPullDownRefresh();
			});
	},
	onLoad(option) {
		this.$store.getters.dictObj;
		this.getInfo();
	},
	onShow() {
		// this.getInfo();
	},
	onShareAppMessage(res) {
		var self = this;
		return {
			title: '中正',
			path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
		};
	},
	methods: {
		getChangeData(v){
			this.listData.map(item => {
				if(item.id === v && item.receiptStatus !== 1){
					item.receiptStatus = 1
				}
			})
		}, 
		getInfo() {
			this.$api.getappinformUserlist(this.formData).then(res => {
				if (res.data.code === 200) {
					this.listData = res.data.rows;
					this.totals = res.data.total;
				}
			});
		},
		againGetApi() {
			this.$api.getappinformUserlist(this.formData).then(res => {
				if (res.data.code === 200) {
					this.listData = this.listData.concat(res.data.rows);
				}
			});
		}
	},
	onReachBottom() {
		if (this.listData.length < this.totals) {
			this.formData.pageNum++;
			this.againGetApi();
		}
	},
	computed: { ...mapGetters(['userInfo']) }
};
</script>
<style>
page {
	background: #eaeef1;
}
</style>
<style scoped>
.btn2 {
	width: 144rpx;
	height: 48rpx;
	background: #ffffff;
	border: 2rpx solid #007aff;
	border-radius: 16rpx;
	text-align: center;
	line-height: 48rpx;
	color: #007aff;
	margin: 0 8rpx;
}
.btn1 {
	width: 144rpx;
	height: 48rpx;
	background: #ffffff;
	border: 2rpx solid #999999;
	border-radius: 16rpx;
	text-align: center;
	line-height: 48rpx;
	color: #999999;
	margin: 0 8rpx;
}
.item {
	background: #ffffff;
	border-radius: 16rpx;
	padding: 15rpx;
}
.priceTag {
	font-size: 30rpx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #ff2d55;
	display: flex;
	flex-direction: row-reverse;
}

.bottomBox {
	position: fixed;
	bottom: 0;
	width: 100%;
	left: 0;
	height: 98rpx;
	background-color: #ffffff;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0 30rpx;
}
</style>
