<template>
	<view class="charts-box" style="padding-bottom: 50px;">

		<view class="top" style="margin-top: 15px;">
			<text>企业名称：</text>
			<text>{{queryParams.businessName}}</text>
		</view>
		<view class="top">
			<text>核查日期：</text>
			<text>{{queryParams.executionTime}}</text>
		</view>
		<view class="top">
			<text>核查结果：</text>
			<text>{{result}}</text>
		</view>

		<view v-show="isShow">

			<view class="top">
				<text>异常信息详情：</text>
			</view>

			<block v-for="item in list" :key="item.index">
				<!-- 包裹图片+两行文字 id="{{index}}"是给按下了那个item记录-->
				<view class="view_tupian_wenzi" @click="clickData(item.index)">
					<!-- 包裹两行文字 -->
					<view class="view_wenzi2">
						<view class="top2">
							<text>列入日期：</text>
							<text>{{item.addDate}}</text>
						</view>
						<view class="top2">
							<text>列入经营异常名录原因：</text>
							<text>{{item.addReason}}</text>
						</view>
						<view class="top2">
							<text>作出决定机关：</text>
							<text>{{item.decisionOffice}}</text>
						</view>
						<view class="top2">
							<text>移出日期：</text>
							<text>{{item.removeDate}}</text>
						</view>
						<view class="top2">
							<text>移出经营异常名录原因：</text>
							<text>{{item.romoveReason}}</text>
						</view>
						<view class="top2">
							<text>移出决定机关：</text>
							<text>{{item.removeDecisionOffice}}</text>
						</view>

					</view>

				</view>

			</block>


		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: "",
				result: "",
				isShow: false,
				queryParams: {
					businessName: "",
					executionTime: ""
				},
				list: [],
				fileUrl:"",
			};
		},
		onLoad(option) {

			// var data = JSON.stringify(option)

			this.queryParams = {
				businessName: option.businessName,
				executionTime: option.executionTime
			}

			console.log('1111', this.queryParams)

			// this.setData({
			// 	queryParams: JSON.stringify(option)
			// })

			// console.log('setData', this.queryParams)
			this.getData()

			// console.log('App onLoad', JSON.stringify(option))
			// this.title = JSON.stringify(option)
			// wx.showToast({
			// 	title: 'onLoad成功>>>>>' + JSON.stringify(option),
			// 	icon: 'none',
			// 	duration: 5000 //持续的时间
			// })

		},
		onShow() {
			wx.hideHomeButton()
		},
		methods: {
			download() {
				 uni.downloadFile({
				     url: this.fileUrl,// 网络文档地址
				     success: (data) => {
				     if (data.statusCode === 200) {
				         uni.saveFile({
				           tempFilePath: data.tempFilePath, //临时路径
				           success: function(res) {
				             // 保存路径
				             uni.showToast({ title: "文件已保存："+res.savedFilePath,duration:5000 })
				             setTimeout(()=>{
				               //打开文档查看
				               uni.openDocument({
				                 filePath:res.savedFilePath,
								  showMenu: true,//右上角是否有可以转发分享的功能
				                 success:function(res){
				                   console.log('打开文档成功')
				                 }
				               })
				             }, 3000);
				           }
				         });
				       }
				     },
				     fail: (err) => {
				       uni.showToast({
				         title: '失败请重新下载'
				       });
				     },
				   });
				 
				
			},
			getData() {
				console.log('getData', this.queryParams)
				this.$api.selectBusinessRiskInfo(this.queryParams).then((resp) => {
					console.log('1111>>>>>>', resp)
					this.list = resp
					console.log('2222>>>>>>', this.list.length)
					this.result = this.list.length == 0 ? "无异常信息" : "共有" + this.list.length + "条异常信息"
					this.isShow = this.list.length == 0 ? false : true

				}).catch(e => {
					console.log('eeeee', e)
				})
			},
			clickData(e) {
				console.log("按了：", e.currentTarget.id)
			}


		},

	};
</script>

<style lang="scss">
	.top {
		margin-left: 25px;
		margin-top: 5px;
	}

	/* 包裹图片和两行文字 */

	.view_tupian_wenzi {
		display: flex;
		flex-direction: row;
		align-items: center;

		/* 圆角 */
		border-radius: 20rpx;

		/* 边 */
		border: 3rpx solid #E0E3DA;
		box-shadow: 5rpx 5rpx 5rpx 5rpx #E0E3DA;

		background-color: #ffffff;
		margin: 30rpx;

		/* padding使得文字和图片不至于贴着边框 */
		padding: 30rpx;

	}

	/* 图片 */

	.image_1 {
		width: 100rpx;
		height: 100rpx;
	}

	/* 包裹两行文字 */

	.view_wenzi2 {

		width: 100%;
		margin-left: 25rpx;
		display: flex;
		flex-direction: column;

		.top2 {
			margin-top: 5px;
		}

		.text1 {
			font-size: 15px;
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 1;
			-webkit-box-orient: vertical;
		}

		.text2 {
			flex: 1;
			margin-top: 5px;
			font-size: 12px;
		}


	}

	/* 小字 */

	.text_small {
		font-size: 30rpx;
		word-break: break-all;
		color: #7a7878;
		margin-top: 10rpx
	}

	.text_small2 {
		font-size: 25rpx;
		color: #f00;
		margin-top: 10rpx
	}
</style>