<template>
	<view>
		<view class="head">
			<u--image class="logo" :showLoading="true" :src="src" :width="logoWidth" :height="logoHeight" @click="logo"></u--image>
			<u-divider :text="$t('index.title')" class="devide" :textColor="textColor" textSize="40"></u-divider>
		</view>
		<hl-form @actionSheet="actionSheet" :currentItem="currentItem" :form="form" @search="searchShow = true" @select="select" v-if="hlFormShow" :issueType='issueType' :name='name'></hl-form>
		<hlswiper></hlswiper>
		<notice v-show="noticeShow" @close="noticeShow = false" :title="$t('notice.title')" :content="content"></notice>
		<search @close="searchShow = false" v-if="searchShow"></search>
	</view>
</template>
<script>
	import hlForm from "@/components/hlForm.vue"
	import notice from "@/components/notice.vue"
	import search from "@/components/search.vue"
	import hlswiper from "@/components/swiper.vue"
	import { getSetting } from "@/api/setting.js"
	import { formAction } from "@/assets/config.js"
	import {
		getIssue,
		getIssueType
	} from "@/api/issue.js"
	export default {
		components: {
			hlForm,
			notice,
			search,
			hlswiper
		},
		data() {
			return {
				content:"",
				src: null,
				logoWidth:332,
				logoHeight:104,
				noticeShow: true,
				searchShow: false,
				issueList: [],
				issueType:0,
				name:'',
				hlFormShow:true,
				currentItem:{},
				textColor:'white',
				form: [{
						label: this.$t('index.form.a1'),
						require: true,
						actions: [],
						prop: 'select',
						rule: {
							type: 'string',
							required: true,
							// message: this.$t('index.form.ruleMes'),
							trigger: ['blur', 'change']
						},
					},
				],
			}
		},
		created() {
			if(process.uniEnv.name == 'bjst')
			{
				this.src = require("@/static/logo.png")
				this.textColor = 'white'
			}
			else{
				this.src = require("@/static/indiaLogo.png")
				this.textColor = 'black'
				this.logoHeight = 117
				this.logoWidth = 140
			}
			getSetting("sytc").then(r=>{
				this.content = r
			})
			this.noticeShow = !this.$store.state.refresh
			getIssueType().then((r) => {
				this.issueList = r
				for (let i in this.issueList) {
					this.form[0].actions.push({
						name: this.issueList[i].title,
						issueType: this.issueList[i].id
					})
				}
			})
		},
		methods: {
			logo() {},
			actionSheet(e){
				this.currentItem = e
			},
			select(e){
				this.form.splice(1,this.form.length - 2)
				this.issueType = e.issueType
				this.name = e.name
				this.hlFormShow = false
				this.$nextTick(()=>{
					formAction(e,this)
					this.hlFormShow = true
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	.head {
		padding-top: 30rpx;
		position: relative;

		.logo {
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.devide {
			font-family: Arial;
			font-weight: 400;
			// margin-top: 60rpx;
		}
	}
</style>