<template>
	<view class="p-30">
		<!-- <view class="c-menu">
			<u-cell title="2024-01-01" isLink>
				<template slot="value">
					<text class="t-orange">待处理</text>
				</template>
			</u-cell>
			<u-cell class="no-line" title="2024-01-01" isLink>
				<template slot="value">
					<text class="t-green">已处理</text>
				</template>
			</u-cell>
		</view> -->
		
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view class="c-menu">
				<u-cell :title="item.createTime" isLink v-for="item in list" :key="item.id" @click="goInfo(item)">
					<!-- <template slot="value">
						<text class="t-orange">待处理</text>
					</template> -->
				</u-cell>
			</view>
		</mescroll-body>
		
		<view style="padding: 50rpx;" class="fixed-btn">
			<u-button shape="circle" type="primary" @click="navigateTo('/pages/my/feedback/add/add')">新增意见反馈</u-button>
		</view>
	</view>
</template>

<script>
	import {
		feedbackList
	} from '@/api/index.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {
		mapState
	} from 'vuex'
	export default {
		computed: {
			...mapState(['userInfo'])
		},
		mixins: [MescrollMixin],
		data() {
			return {
				list: []
			}
		},
		onShow() {
			if(this.mescroll) {
				this.mescroll.resetUpScroll();
			}
		},
		methods: {
			goInfo(item) {
				this.navigateTo('/pages/my/feedback/add/add?data='+JSON.stringify(item))
			},
			async getList(pageNum) {
				const res = await feedbackList(pageNum, 20, {
					userId: this.userInfo.id
				})
				if(res.success) {
					this.mescroll.endBySize(res.data.list.length, parseInt(res.data.total));
					if (pageNum == 1) this.list = []; //如果是第一页需手动制空列表
					this.list = this.list.concat(res.data.list);
				} else {
					this.mescroll.endErr();
				}
			},
			upCallback(page) {
				this.getList(page.num)
			},
		}
	}
</script>

<style lang="scss">
	.t-orange {
		font-size: 28upx;
		color: $u-warning-dark;
	}
	.t-green {
		font-size: 28upx;
		color: $u-success-dark;
	}
	.fixed-btn {
		width: 100%;
		box-sizing: border-box;
		position: fixed;
		left: 0;
		bottom: 0
	}
</style>
