<template>
	<view style="padding: 24rpx;">
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
		<view class="list x-f" v-for="(item,index) in dataList" :key="index">
			<view class="image">
				<image :src="item.images?item.images.split(',')[0]:''" mode="aspectFill" style="width: 100%;height: 100%;"></image>
				<view class="tag" :style="{backgroundColor: item.isProcessCompleted==1? '#eee': item.isHandlePlatform==0&&item.isHandleStore==0 ? 'red':'#2583EB', color: item.isProcessCompleted==1? '#666':'#fff'}">
					{{item.isProcessCompleted==1? '已结束':item.isHandlePlatform==0&&item.isHandleStore==0 ? '待处理':'已处理'}}
				</view>
			</view>
			<view style="flex: 1;overflow: hidden;" @click="showDetail(item)">
				<view class="ellipsis2">{{item.title}}</view>
				<view class="x-bc">
					<view class="time">{{item.createTime}}</view>
					<view class="btn">查看</view>
				</view>
			</view>
		</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {storeComplaintList} from "@/api/user.js"
	export default {
		mixins: [MescrollMixin], 
		data() {
			return {
				mescroll:null,
				// 上拉加载的配置
				downOption: {   //下拉刷新
				 	use:true,
					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption: {
					onScroll:true,
					use: true, // 是否启用上拉加载; 默认true
					page: {
						num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					textNoMore: '没有更多了', 
					empty: {
						icon:'/static/images/no_data.png',
						tip: '暂无数据'
					}
				},
				// 列表数据
				dataList: []
			}
		},
		onShow() {
			this.mescroll&&this.mescroll.resetUpScroll()
		},
		methods: {
			showDetail(item) {
				uni.navigateTo({
					url:'/pages_user/complaintListDetail?id='+item.id
				})
			},
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			/*下拉刷新的回调 */
			downCallback(mescroll) {
				mescroll.resetUpScroll()
			},
			upCallback(page) {
				//联网加载数据
				var that = this;
				var data = {
					status:this.status,
					page: page.num,
					pageSize: page.size
				};
				storeComplaintList(data).then(res => {
					if(res.code==200){
						//设置列表数据
						if (page.num == 1) {
							that.dataList = res.rows; 
							
						} else {
							that.dataList = that.dataList.concat(res.rows);
							 
						}
						that.mescroll.endBySize(res.rows.length, res.total);
						
					}else{
						uni.showToast({
							icon:'none',
							title: "请求失败",
						});
						that.dataList = null;
						that.mescroll.endErr();
					}
				});
			},
		}
	}
</script>

<style scoped lang="scss">
	.time {
		font-size: 28rpx;
		color: #888;
	}
	.btn{
		margin-top: 16rpx;
		padding: 8rpx 20rpx;
		font-size: 26upx;
		font-family: PingFang SC;
		font-weight: 500;
		text-align: center;
		border-radius: 32upx;
		border: 1rpx solid #2583EB;
		color: #2583EB;
	}
	.list {
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 24rpx;
		overflow: hidden;
		font-size: 30rpx;
		margin-bottom: 24rpx;
		.image {
			flex-shrink: 0;
			width: 150rpx;
			height: 150rpx;
			background-color: #eee;
			position: relative;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			overflow: hidden;
			margin-right: 24rpx;
		}
		.tag {
			position: absolute;
			top: 0;
			left: 0;
			padding: 5rpx 6rpx;
			font-size: 20rpx;
			color: #FFFFFF;
			background-color: red;
			border-radius: 16rpx 0 16rpx 0;
		}
	}
</style>