<template>
	<view class="index tn-safe-area-inset-bottom" style="background-color: #f7f7f7;min-height: 100vh;">

		<tn-nav-bar customBack>
			<view slot="back" class='tn-custom-nav-bar__back' @click="goBack()">
				<text class='icon tn-icon-left'></text>
			</view>

			<view slot="default" style="display: flex;">
				<view style="flex:1;margin-left:25px">
					<text :style="{fontSize:(wxFontSize)+'px'}">我的反馈</text>
				</view>

			</view>
		</tn-nav-bar>

		<view :style="{paddingTop: vuex_custom_bar_height + 'px'}">



			<!-- 图文信息 -->
			<block v-for="(item,index) in content" :key="index">
				<view class="blogger__item" style="border-radius: 12px;margin: 12px 16px 12px 16px; background-color: #fff;">
					<view class="blogger__author tn-flex tn-flex-row-between tn-flex-col-center">
						<view class="justify__author__info">
							<view class="tn-flex tn-flex-row-center">
								<view class="tn-flex tn-flex-row-center tn-flex-col-center">
									<view class="tn-padding-right tn-text-ellipsis">
										<view class="tn-padding-right tn-text-bold tn-text-lg" :style="{fontSize:(wxFontSize)+'px'}">
											{{ item.type==1?'【汇报系统故障】':item.type==2?'【平台机制咨询】':item.type==3?'【投诉】':item.type==5?'【平台用户举报】':'【其他】' }}
										</view>
									</view>
								</view>
							</view>
						</view>
						<view 
							class="blogger__author__btn justify-content-item tn-flex-col-center tn-flex-row-center" >
							<text class="" v-if="item.status==1" style="background: #fce9e9;font-size: 12px;
			padding: 8px;
			color: #EF2121;
			border-radius: 24px;
			 " :style="{fontSize:(wxFontSize-6)+'px'}">已处理</text><text class="" v-if="item.status==0" style="background: #e6e6e6;font-size: 12px;
			padding: 8px;
			color: #999;
			border-radius: 24px;
			 " :style="{fontSize:(wxFontSize-6)+'px'}">未处理</text>
						</view>
					</view>

					<view
						class="blogger__desc tn-margin-top-sm tn-margin-bottom-sm tn-text-justify tn-flex-col-center tn-flex-row-left">
						<text
							class="blogger__desc__content tn-flex-1 tn-text-justify tn-text-df" :style="{fontSize:(wxFontSize-1)+'px'}">{{ item.content }}</text>
							
					</view>
					<view v-if="item.ansowe"
						class="blogger__desc tn-margin-top-sm tn-margin-bottom-sm tn-text-justify tn-flex-col-center tn-flex-row-left">
						<text
							class="blogger__desc__content tn-flex-1 tn-text-justify tn-text-df" style="color:red" :style="{fontSize:(wxFontSize-2)+'px'}">回复:{{ item.ansowe }}</text>
							
					</view>
 

					<block v-if="item.imgList">
						<view v-if="[1,2,4].indexOf(item.imgList.length) != -1" class="tn-padding-top-xs"
							@click="tn('')">
							<image v-for="(image_item,image_index) in item.imgList" :key="image_index"
								class="blogger__main-image" :class="{
			            'blogger__main-image--1 tn-margin-bottom-sm': item.imgList.length === 1,
			            'blogger__main-image--2 tn-margin-right-sm tn-margin-bottom-sm': item.imgList.length === 2 || item.imgList.length === 4
			          }" :src="image_item.ftpUrl" mode="aspectFill" @click="showImg(item.imgList,image_index)"></image>
						</view>
						<view v-else class="tn-padding-top-xs">
							<tn-grid hoverClass="none" :col="3">
								<block v-for="(image_item,image_index) in item.imgList" :key="image_index">
									<!-- #ifndef MP-WEIXIN -->
									<tn-grid-item style="width: 30%;margin: 10rpx;">
										<image class="blogger__main-image blogger__main-image--3"
											@click="showImg(item.imgList,image_index)" :src="image_item.ftpUrl"
											mode="aspectFill"></image>
									</tn-grid-item>
									<!-- #endif-->
									<!-- #ifdef MP-WEIXIN -->
									<tn-grid-item style="width: 30%;margin: 10rpx;">
										<image class="blogger__main-image blogger__main-image--3"
											@click="showImg(item.imgList,image_index)" :src="image_item.ftpUrl"
											mode="aspectFill"></image>
									</tn-grid-item>
									<!-- #endif-->
								</block>
							</tn-grid>
						</view>
					</block>



					<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-top-xs">
						<view class="justify-content-item tn-color-gray tn-text-center">
							<view class="tn-padding-right   tn-padding-top-xs tn-color-gray" :style="{fontSize:(wxFontSize-3)+'px'}">
								{{ item.createTime|formatDate }}
							</view>

						</view>

					</view>
				</view>


			</block>

			<view v-if="showEmpty" style="margin-top: 32vh;">
				<tn-empty mode="data"></tn-empty>
			</view>
		</view>

		<view class="edit tnxuanfu" @tap="showLandscape">
			<view class="bg0 pa">
				<view class="bg1">
					<text class='icon tn-icon-edit-write-fill'></text>

				</view>
			</view>
			<view class="hx-box pa">
				<view class="pr">
					<view class="hx-k1 pa0">
						<view class="span"></view>
					</view>
					<view class="hx-k2 pa0">
						<view class="span"></view>
					</view>
					<view class="hx-k3 pa0">
						<view class="span"></view>
					</view>
					<view class="hx-k4 pa0">
						<view class="span"></view>
					</view>
					<view class="hx-k5 pa0">
						<view class="span"></view>
					</view>
					<view class="hx-k6 pa0">
						<view class="span"></view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../utils/request'

	export default {
		data() {
			return {
				showHistory: false,
				content: [],
				showEmpty: false,
				wxFontSize:17
			}
		},
		filters: {
			formatDate(value) {
				if (!value) return '';
				const date = new Date(value);
				const today = new Date();
				const yesterday = new Date(today); // 昨天的日期
				yesterday.setDate(yesterday.getDate() - 1); // 将昨天的日期设置为前一天

				if (date.getFullYear() == today.getFullYear() && date.getMonth() == today.getMonth() && date.getDate() ==
					today.getDate()) {
					return '今天 ' + (date.getHours() > 9 ? '' : '0') + date.getHours() + ':' + (date
						.getMinutes() > 9 ? '' : '0') + date.getMinutes(); // 根据需要格式化日期
				}
				if (date.getFullYear() == yesterday.getFullYear() && date.getMonth() == yesterday.getMonth() && date
					.getDate() == yesterday.getDate()) {
					return '昨天 ' + (date.getHours() > 9 ? '' : '0') + date.getHours() + ':' + (date
						.getMinutes() > 9 ? '' : '0') + date.getMinutes(); // 根据需要格式化日期
				}
				return date.toLocaleDateString() + ' ' + (date.getHours() > 9 ? '' : '0') + date.getHours() + ':' + (date
					.getMinutes() > 9 ? '' : '0') + date.getMinutes(); // 根据需要格式化日期
			},


		},
		created() {
			
		},
		methods: {
			onPullDownRefresh() {
				this.loadData();
			},
			showLandscape() {
				uni.navigateTo({
					url: '/pages/mine/addFeed'
				})
			},
			goBack() {
					uni.navigateBack();
			},
			isImage(fileName) {
				const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'ico']
				const extension = fileName.split('.').pop().toLowerCase();
				return imageExtensions.includes(extension);
			},
			loadData(pageIndex=1) {
				if(!uni.getStorageSync('userNo')){
					return false;
				}
				let that = this;
				that.showEmpty = false;
				request.post('/slbFeedback/query', {
					limit:10,
					index:pageIndex,
					userNo: uni.getStorageSync('userNo'),
				}).then(res => {
					console.warn(res);
					if (res && res.success) {
						let newList = res.list || [];
						for (let i = 0; i < newList.length; i++) {
							newList[i].imgList = [];
							for (let j = 0; j < newList[i].fileDetailList.length; j++) {
								if (that.isImage(newList[i].fileDetailList[j].fileName)) {
									newList[i].imgList.push(newList[i].fileDetailList[j]);
								}
							}
						}
						if(pageIndex==1){
							that.content = newList;
						}else{
							that.content = that.content.concat(newList || []);
						}
						
						if (newList.length == 0) {
							that.showEmpty = true;
						} else {
							that.showEmpty = false;
						}
						if(res.total>that.content.length&&res.total>pageIndex*10){
							that.loadData(pageIndex+1);
						}
					}
					uni.stopPullDownRefresh();
				})
			},
			showImg(items, index) {
				let urls = [];
				for (let i = 0; i < items.length; i++) {
					urls.push(items[i].ftpUrl);
				}

				// 预览图片
				uni.previewImage({
					urls: urls,
					current: index,

				});
			},
		},
		onLoad() {
			const appBaseInfo = wx.getAppBaseInfo();
			this.wxFontSize = uni.getStorageSync('fontSize')||appBaseInfo.fontSizeSetting||17;
			this.loadData();
		}
	}
</script>

<style lang="scss" scoped>
	/* 胶囊*/
	.tn-custom-nav-bar__back {
		width: 60%;
		height: 100%;
		position: relative;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		box-sizing: border-box;
		// background-color: rgba(0, 0, 0, 0.15);
		border-radius: 1000rpx;
		// border: 1rpx solid rgba(255, 255, 255, 0.5);
		// color: #FFFFFF;
		font-size: 18px;

		.icon {
			display: block;
			flex: 1;
			margin: auto;
			text-align: center;
		}

		&:before {
			content: " ";
			width: 1rpx;
			height: 110%;
			position: absolute;
			top: 22.5%;
			left: 0;
			right: 0;
			margin: auto;
			transform: scale(0.5);
			transform-origin: 0 0;
			pointer-events: none;
			box-sizing: border-box;
			opacity: 0.7;
			background-color: #FFFFFF;
		}
	}


	/* 文章内容 start*/
	.blogger {
		&__item {
			padding: 30rpx;
		}

		&__author {
			&__btn {
				margin-right: -12rpx;
				opacity: 0.5;
			}
		}

		&__desc {
			line-height: 30rpx;

			&__label {

				color: #1D2541;
				background-color: #F3F2F7;
				border-radius: 10rpx;
				font-size: 22rpx;

				padding: 5rpx 15rpx;
				margin: 5rpx 18rpx 0 0;

				&--prefix {
					font-size: 24rpx;
					color: #1D2541;
					padding-right: 10rpx;
				}
			}

			&__content {
				line-height: 50rpx;
			}
		}

		&__content {
			margin-top: 18rpx;
			padding-right: 18rpx;

			&__data {
				line-height: 46rpx;
				text-align: justify;
				overflow: hidden;
				transition: all 0.25s ease-in-out;

			}

			&__status {
				margin-top: 10rpx;
				font-size: 26rpx;
				color: #82B2FF;
			}
		}

		&__main-image {
			border: 1rpx solid #F8F7F8;
			border-radius: 16rpx;

			&--1 {
				max-width: 80%;
				max-height: 300rpx;
			}

			&--2 {
				max-width: 260rpx;
				max-height: 260rpx;
			}

			&--3 {
				height: 212rpx;
				width: 100%;
			}
		}

		&__count-icon {
			font-size: 40rpx;
			padding-right: 5rpx;
		}

		&__ad {
			width: 100%;
			height: 500rpx;
			transform: translate3d(0px, 0px, 0px) !important;

			::v-deep .uni-swiper-slide-frame {
				transform: translate3d(0px, 0px, 0px) !important;
			}

			.uni-swiper-slide-frame {
				transform: translate3d(0px, 0px, 0px) !important;
			}

			&__item {
				position: absolute;
				width: 100%;
				height: 100%;
				transform-origin: left center;
				transform: translate3d(100%, 0px, 0px) scale(1) !important;
				transition: transform 0.25s ease-in-out;
				z-index: 1;

				&--0 {
					transform: translate3d(0%, 0px, 0px) scale(1) !important;
					z-index: 4;
				}

				&--1 {
					transform: translate3d(13%, 0px, 0px) scale(0.9) !important;
					z-index: 3;
				}

				&--2 {
					transform: translate3d(26%, 0px, 0px) scale(0.8) !important;
					z-index: 2;
				}
			}

			&__content {
				border-radius: 40rpx;
				width: 640rpx;
				height: 500rpx;
				overflow: hidden;
			}

			&__image {
				width: 100%;
				height: 100%;
			}
		}
	}

	/* 文章内容 end*/

	/* 悬浮 */
	.tnxuanfu {
		animation: suspension 3s ease-in-out infinite;
	}

	@keyframes suspension {

		0%,
		100% {
			transform: translateY(0);
		}

		50% {
			transform: translateY(-0.8rem);
		}
	}

	/* 悬浮按钮 */
	.button-shop {
		width: 90rpx;
		height: 90rpx;
		display: flex;
		flex-direction: row;
		position: fixed;
		/* bottom:200rpx;
	    right: 20rpx; */
		left: 5rpx;
		top: 5rpx;
		z-index: 1001;
		border-radius: 100px;
		opacity: 0.9;
	}


	/* 按钮 */
	.edit {
		bottom: 300rpx;
		right: 75rpx;
		position: fixed;
		z-index: 9999;
	}


	.pa,
	.pa0 {
		position: absolute
	}

	.pa0 {
		left: 0;
		top: 0
	}


	.bg0 {
		width: 100rpx;
		height: 100rpx;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		background: #2196F3;
		border-radius: 50%;
		font-size: 32px;
		color: #fff;
		text-align: center;
		line-height: 50px;
	}

	.bg1 {
		width: 100%;
		height: 100%;
	}




	.hx-box {
		top: 50%;
		left: 50%;
		width: 100rpx;
		height: 100rpx;
		transform-style: preserve-3d;
		transform: translate(-50%, -50%) rotateY(75deg) rotateZ(10deg);
	}

	.hx-box .pr {
		width: 100rpx;
		height: 100rpx;
		transform-style: preserve-3d;
		animation: hxz 20s linear infinite;
	}

	@keyframes hxz {
		0% {
			transform: rotateX(0deg);
		}

		100% {
			transform: rotateX(-360deg);
		}
	}



	.hx-box .pr .pa0 {
		width: 100rpx;
		height: 100rpx;
		/* border: 4px solid #5ec0ff; */
		border-radius: 1000px;
	}



	@keyframes hx {
		to {
			transform: rotate(360deg);
		}
	}

	.hx-k1 {
		transform: rotateX(-60deg) rotateZ(-60deg)
	}

	.hx-k2 {
		transform: rotateX(-30deg) rotateZ(-30deg)
	}

	.hx-k3 {
		transform: rotateX(0deg) rotateZ(0deg)
	}

	.hx-k4 {
		transform: rotateX(30deg) rotateZ(30deg)
	}

	.hx-k5 {
		transform: rotateX(60deg) rotateZ(60deg)
	}

	.hx-k6 {
		transform: rotateX(90deg) rotateZ(90deg)
	}
</style>