<template>

	<view>
		<uni-section type="text">
			<view class="uni-padding-wrap uni-common-mt">
				<uni-segmented-control :current="status" :values="sublist" :active-color="activeColor"
					@clickItem="sectionChange" />
			</view>
		</uni-section>
		<!-- <view style="background-color: #fff; height:45px; width:100%;position: fixed;top: 0px;z-index: 99;">
			<view class="uniform">
				<a class="uniform-a-active"
					href="{php echo $this->createMobileUrl('myfeedback',array('status'=>0))}">待解决</a>
			</view>
			<view class="uniform">
				<a class="uniform-a-active"
					href="{php echo $this->createMobileUrl('myfeedback',array('status'=>1))}">已解决</a>
			</view>
		</view> -->
		<!-- <view style="height:47px;"></view> -->

		<view class="weui-cells__title">
			<text v-if="status==0">待解决反馈</text>
			<text v-if="status==1">已解决反馈</text>
			共<b>{{total}}</b>个
		</view>
		<view v-if="total<=0" class="no-data-cont-change">
			<i class="icon iconfont iconwushuju no-data-icon"></i>
			<p>您暂时没有此条件下的反馈!</p>
		</view>

		<view class="partner-list" id="list" v-for="item in list" :id="item.id" :key="item.id">
			<view class="weui-panel">
				<view class="weui-panel__bd">
					<span href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
						<uni-card :is-shadow="false">
							<view class="weui-media-box__bd">
								<h4 class="weui-media-box__title">反馈编号：{{item.id}}</h4>
								<p class="weui-media-box__desc">反馈时间：{{formatDate(item.createtime)}}</p>
								<p class="weui-media-box__desc">问题简述：{{item.reason}}</p>
								<p class="weui-media-box__desc">问题详情：{{item.remark}}</p>
								<p v-if="item.status==1" class="weui-media-box__desc">解决方法：{{item.solution}}</p>
								<p class="weui-media-box__desc">回复内容：{{item.response}}</p>
							</view>
						</uni-card>

					</span>
				</view>
			</view>
		</view>
		<view v-if="total>psize" style="margin: 40px 0px; text-align: center;">
			<view class="show-more">
				<a href="javascript:void(0);" style="color: #000;" @click="loadPage()" id="pager">浏览更多</a>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				status: 0,
				total: 0,
				sublist: ['待解决', '已解决'],
				page: 1,
				psize: 5
			};
		},
		onLoad(option) {
			this.getMyFeedback(this.status)
		},
		methods: {
			sectionChange(e) {
				if (e.currentIndex == 0) {
					this.status = 0
					this.list= [],
					this.getMyFeedback(0)
				} else {
					this.status = 1
					this.list= [],
					this.getMyFeedback(1)
				}
			},
			getMyFeedback(status) {
				var _this = this
				uni.request({
					method: 'get',
					url: config.baseUrl +
						'app/index.php?i=1&j=1&c=entry&debugSkip=true&m=wdl_shopping&do=myfeedback&isajax=1&status=' +
						status + '&page=' + _this.page,
					success(res) {
						//console.log('myfeedback??????>' + JSON.stringify(res));
						_this.total = res.data.total
						    for (let item of res.data.list) {
						      if(!_this.list.includes(item)){
								_this.list.push(item)
							  }
						    }
						_this.psize = res.data.psize
					},
					fail(res) {
						console.log(JSON.stringify(res))
					}
				})
			},
			loadPage() {
				this.page += 1;
				this.getMyFeedback(this.status);
			},  
			formatDate(time) {
				let date = new Date(time*1000);
				let year = date.getUTCFullYear();
				let month = date.getUTCMonth() + 1;
				let day = date.getUTCDate();
				let hours = date.getUTCHours();
				let minutes = date.getUTCMinutes();
				let seconds = date.getUTCSeconds();
				// 为了使结果更加易读，可以对月、日、小时、分钟和秒进行补零操作
				month = month < 10 ? '0' + month : month;
				day = day < 10 ? '0' + day : day;
				hours = hours < 10 ? '0' + hours : hours;
				minutes = minutes < 10 ? '0' + minutes : minutes;
				seconds = seconds < 10 ? '0' + seconds : seconds;
				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
		  }
		},
		
	};
</script>

<link rel="stylesheet" href="@/static/css/weui.css">
<style>
	a {
		text-decoration: none;
		color: #000;
	}

	a:hover,
	a:focus {
		text-decoration: none;
		color: #1390ea;
	}

	.uniform {
		float: left;
		width: 50%;
		text-align: center;
		height: 42px;
	}

	.uniform a {
		display: block;
		height: 100%;
		width: 100%;
		line-height: 40px;
		border-bottom: 2px solid #d7d3d3;
	}

	.uniform .uniform-a-active {
		color: #247aff;
		font-weight: bold;
		border-bottom: 2px solid #247aff;
	}

	.pay-type {
		float: left;
		font-size: 14px;
	}

	.weui-media-box__desc {
		color: #666d7f;
		font-size: 14px;
		padding-top: 4px;
	}


	.uni-padding-wrap {
		width: 750rpx;
	}

	/* 	body {
		background: url('{$curPath}/yuejilu/newbg2.png') no-repeat center;
		background-size: 100% 100%;
		background-position: center 100%;
		height: 100vh;
		width: 100vw;
	} */

	/* 暂无数据去掉背景色*/
	.no-data-cont-change {
		text-align: center;
		color: #d7d7d7;
	}
</style>