<template>
	<view class="complaint-detail">
		<!-- 顶部导航栏 -->
		<custom-navbar 
		  title="申诉详情" 
		  :show-back="true"
		  title-color="#000"
		  background-color="#FFFFFF"
		></custom-navbar>
		<view class="state">
			<text class="state-text">{{detail.state == 1 ? '处理中' : detail.state == 2 ? '处理完成' : detail.state == 3 ? '撤销' : ''}}</text>
		</view>
		<view class="container">
			<view class="box">
				<text class="way">{{detail.title}}</text>
			</view>
			<view class="box">
				<text class="date">{{detail.add_time}}</text>
			</view>
			<view class="box">
				<text class="reason">{{detail.text}}</text>
			</view>
			<view class="images">
				<image
					class="img"
					v-for="(img,index) in detail.photos"
					:key="index"
					:src="img"
					mode="aspectFill"
					@click="previewImage(detail.photos,index)"></image>
			</view>
			<view class="contact">
				<view class="contact-item">
					<text class="contact-lable">联系人</text>
					<text class="contact-text">{{detail.name}}</text>
				</view>
				<view class="contact-item">
					<text class="contact-lable">联系方式</text>
					<text class="contact-text">{{detail.phone}}</text>
				</view>
			</view>
			<view class="result" v-if="detail.state == 2">
				<view>
					<text class="result-date">{{detail.end_time}}</text>
				</view>
				<view>
					<text class="result-cont">处理结果：{{detail.result}}</text>
				</view>
			</view>
		</view>
		<!-- 操作区 -->
		<view class="handle-btns">
			<view
				class="handle-btn"
				@click="contact"
				v-if="detail.state == 1">
				<text class="handle-text">联系客服</text>
			</view>
			<view
				class="handle-btn"
				v-if="detail.state == 1"
				@click="removeComplaint(detail)">
				<text class="handle-text">撤销投诉</text>
			</view>
			<view
				class="handle-btn"
				@click="againComplaint(detail)"
				v-if="detail.state == 3">
				<text class="handle-text">再次发起</text>
			</view>
		</view>
	</view>
</template>

<script>
import request from '../../utils/request';
	export default {
		data() {
			return {
				order_number: '',
				detail: {}
			}
		},
		onLoad(options) {
			this.order_number = options.number;
			this.getappealdetail();
		},
		methods: {
			getappealdetail() {
				request.post('/user/getappealdetail',{order_number: this.order_number}).then(res=>{
				this.detail = res.data;
				})
			},
			previewImage(urls, current) {
			  uni.previewImage({
				urls: urls,
				current: current
			  })
			},
			removeComplaint(detail) {
				request.post('/user/revokeappeal',{order_number: detail.order_number}).then(res=>{
					if(res.state == 1) {
						uni.showToast({
							title: '撤销成功',
							icon: 'none'
						})
						this.getappealdetail();
					}else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			contact() {
				uni.navigateTo({
					url: '/pages/contact/contact'
				})
			},
			// 再次发起
			againComplaint(detail) {
			  uni.redirectTo({
				url: '/pages/complaint/add-complaint?number='+detail.order_number
			  })
			},
		}
	}
</script>

<style>
.state {
  height: 60rpx;
  line-height: 60rpx;
  background-color: #E8101E;
  padding: 0 24rpx;
}
.state-text {
  font-size: 28rpx;
  color: rgba(255, 255, 255, 0.9);
}
.container {
  margin: 24rpx;
  padding: 24rpx 24rpx 0;
  background-color: #fff;
  border-radius: 16rpx;
}
.way {
  font-size: 28rpx;
  color: #333;
}
.date,.reason {
  font-size: 24rpx;
  color: #999;
  
}
.box {
  margin-bottom: 8rpx;
}
.contact {
  border-top: 2rpx solid #eee;
}
.contact-item {
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  align-items: center;
  height: 60rpx;
}
.contact-lable {
  font-size: 24rpx;
  color: #999;
}
.contact-text {
  font-size: 24rpx;
  color: #333;
}
.result {
  background-color: #eee;
  border-radius: 10rpx;
  padding: 18rpx;
}
.result-date {
  font-size: 24rpx;
  color: #333;
}
.result-cont {
	font-size: 28rpx;
	color: #333;
}
.handle-btns {
  height: 102rpx;
  background-color: #fff;
  display: flex;
  flex-flow: row nowrap;
  justify-content: flex-end;
  align-items: center;
  padding: 0 24rpx;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
}
.handle-btn {
  width: 140rpx;
  height: 56rpx;
  line-height: 56rpx;
  text-align: center;
  border: 2rpx solid #eee;
  border-radius: 28rpx;
  margin-left: 20rpx;
}
.handle-text {
  font-size: 28rpx;
  color: #333;
}
.images {
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24rpx;
  border-bottom: 2rpx solid #eee;
}
.img {
  width: 198rpx;
  height: 198rpx;
  background-color: #eee;
  border-radius: 20rpx;
}
</style>
