<template>
	<view class="site">
		<view class="site-bd">
			<view class="item" v-for="(a,i) in list" :key="i" @click="openPage(a)">
				<view class="a">{{a.type_item}}<text>{{a.createtime}}</text></view>
				<view class="b">
					<image src="https://zhengxin.njrenzhou.cn/static/icon-arrow.png"></image>
				</view>
			</view>
		</view>
		<view class="empty" v-if="total == 0">
			<image src="https://zhengxin.njrenzhou.cn/static/empty.png"></image>
			<view class="txt">暂无数据 ~</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				offset: 1,
				list: [],
				total: 1
			};
		},
		mounted() {
			this.systemfankuiGetList();
		},
		onReachBottom() {
			const that = this;
			uni.showLoading({
				title: "加载中"
			})
			if(this.list.length <= this.total){
				that.offset ++;
				setTimeout(function() {
					that.systemfankuiGetList(1);
				}, 1000);
			}
		},
		methods: {
			//数组对象去重
			arrayUnique (arr, name) {
				var hash = {};
				return arr.reduce(function (item, next) {
					hash[next[name]]
						? ""
						: (hash[next[name]] = true && item.push(next));
					return item;
				}, []);
			},
			//获取反馈类型
			async systemfankuiGetList(type) {
				const { code, data } = await this.$api.systemfankuiGetList({
					offset: this.offset,
					limit: 20,
					token: uni.getStorageSync("token")
				})
				if(type==1){
					uni.hideLoading();
				}
				if(code == 1){
					this.list = this.arrayUnique([...this.list,...data.rows],'id');
					this.total = data.total;
				}
			},
			openPage(obj){
				uni.setStorageSync("feedInfo", obj);
				uni.navigateTo({
					url: "/pages/user/feedDetails"
				})
			},
		},
		destroyed() {
			uni.removeStorageSync("feedInfo")
		},
	}
</script>

<style lang="scss" scoped>
.site{
	padding: 0 25rpx 25rpx;
	overflow: hidden;
	.empty{
		padding: 150rpx 0;
		text-align: center;
		font-size: 26rpx;
		color: #666;
		image{
			width: 460rpx;
			height: 400rpx;
			margin-bottom: 30rpx;
		}
	}
	&-bd{
		width: 100%;
		margin: 0 auto;
		position: relative;
		.item{
			background: #FFFFFF;
			box-shadow: 0px 3rpx 10rpx 0px rgba(9,44,39,0.05);
			border-radius: 20rpx;
			padding: 30rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			overflow: hidden;
			margin-top: 20rpx;
			.a{
				flex: 1;
				font-weight: 500;
				font-size: 30rpx;
				color: #333333;
				max-width: 500rpx;
				text{
					display: block;
					font-size: 24rpx;
					color: #999999;
					margin-top: 20rpx;
				}
			}
			.b{
				margin-left: 20rpx;
				image{
					width: 50rpx;
					height: 50rpx;
				}
			}
		}
	}
}
</style>

