<template>
	<view class="container">
		<uni-forms :label-width="80">
			<uni-forms-item label="问题反馈" name="issue" required>
				<uni-easyinput  v-model="formData.issue" 
					type="textarea"
					placeholder="请输入问题反馈"
					:maxlength='-1' autoHeight />
			</uni-forms-item>
		</uni-forms>
		<div class="action-container">
			<div class="app-item" v-for="(item,index) in actionList" :key="index" @click="handle(item)">
				<image class="logo" :src="item.miniLogo" ></image>
				<view class="name">{{item.miniTitle}}</view>
			</div>
		</div>
	</view>
</template>

<script>
	import {getByQr} from '@/api/openApi.js'
	export default {
		data() {
			return {
				formData:{
					issue:""
				},
				actionList:[]
			}
		},
		onLoad(options){
			this.init(options)
		},
		methods: {
			init(options){
				this.getData(options)
			},
			getData({ocId, code}){
				if(!ocId){
					let qrcode=uni.getStorageSync('qrcode')
					if(!qrcode){
					   return
					}
					ocId=qrcode.ocId
					code=qrcode.code
				}
				getByQr(ocId, code).then((res)=>{
					this.actionList=res.data.miniList
					uni.setStorageSync('qrcode',{
						...res.data.target,
						targetId:res.data.targetId,
						targetType:res.data.targetType,
						ocId,
						code
					})
				})	
			},
			handle(item){
				if(item.miniCode==='app-snapshot'){	//隐患登记				
					uni.navigateTo({url:'/pages/app_views/danger/submit/submit'})
				}				
				if(item.miniCode==='app-checklist'){// 清单
					uni.navigateTo({url:'/pages/app_views/checkList/index/index?type=app&id='+item.checklistId})
				}
				if(item.miniCode==='app-checklist-satisfaction'){// 满意度
					uni.navigateTo({url:'/pages/app_views/satisfaction_evaluation/satisfaction_evaluation?type=app&id='+item.checklistId})
				}				
			},
			isLogin(){
				let isLogin=uni.getStorageSync('isLogin')
				if(!isLogin){
					 // #ifdef H5
						uni.navigateTo({
							url:'/pages/login/index'
						})
					 // #endif
					 // #ifndef H5
					uni.navigateTo({
						url:'/pages/authorizedLogin/index'
					})
					// #endif
				}				
			},
			submit(form) {
			},
			isNull(val){
				if(val===undefined||val==="undefined"||val===""||val===null){
					return true
				}
				return false
			}
		},
		onShareAppMessage() {
			
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
		.button{
			background-color:#3384FF;
			color: #fff;
		}
		.action-container{
			display: flex;
			flex-wrap: wrap;
			.app-item{
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				width: 25%;
				padding: 20rpx 10rpx;
				box-sizing: border-box;
				// border: 1px solid #efe3e3;
				border-left: 0;
				&:nth-child(1){
					// border-left: 1rpx solid #efe3e3;
					border-radius: 20rpx;
				}
				.logo{
					display: block;
					width: 80rpx;
					height: 80rpx;
					border: 1px solid #efe3e3;
					border-radius: 10rpx;
				}
				.name{
					width: 100%;
					color: #666;
					font-size: 24rpx;
					line-height: 1;
					margin-top: 20rpx;
					text-overflow: ellipsis;
					word-break: break-all;
					overflow: hidden;
					white-space: nowrap;
					text-align: center;
				}
			}
		}
	}
</style>
