<template>
	<view class="complaint">
		<view class="complaint-item" v-for="(item, index) in list" :key="index" @click="toDetailsPage(item.complain_id)">
			<ComplaintItem :info="item"></ComplaintItem>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>
<script>
import ComplaintItem from '@/components/complaint-item/index'
export default {
	data() {
		return {
			list:[]
		}
	},
	components: {
		ComplaintItem
	},
	onLoad() {
		this.getlist()
	},
	methods: {
		// 获取投诉列表
		getlist(){
			this.$u.api.reportlist({}).then(res => {
				console.log(res)
				if (res.errCode != 0) {
					this.$refs.uToast.show({
						title: res.message,
						type: 'error'
					});
				} else {
					let arr = res.data.dataList
					for(let index in arr){
						this.list.push(arr[index])
					}
					
				}
			});
		},
		toDetailsPage(id) {
			uni.navigateTo({
				url: '/pages/user/complaintDetails?id='+id
			});
		}
	},
};
</script>
<style lang="scss" scoped>
.complaint {
	min-height: calc(100vh - var(--window-top));
	background-color: #ECECEC;
	padding: 20rpx 30rpx;
}
</style>