<template>
	<view>
		<view class="barBox">
			<headers class="fixedheader" :themeType="'white'" :showBack="true">
				<view class="headerName">
					基本信息
				</view>
			</headers>
		</view>
		<view class="tabBox">
			<view :class="{'enterprise-tab':true,'active-tab': checked == 1}" @click="handleTab(1)">企业信息</view>
			<view :class="{'project-tab':true,'active-tab': checked == 2}" @click="handleTab(2)">项目信息</view>
		</view>
		<scroll-view :scroll-y="true" class="scrollBox" :style="{height: screenHeight + 'px'}" v-if="checked == 1">
			<view class="property-item">
				<view class="item-top">企业名称</view>
				<view class="item-bottom">{{enterpriseInfo.enterpriseName || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">企业类型</view>
				<view class="item-bottom">{{enterpriseInfo.companyTypeName || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">统一社会信用代码</view>
				<view class="item-bottom">{{enterpriseInfo.socialCode || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">法定代表人</view>
				<view class="item-bottom">{{enterpriseInfo.enterpriseLegalPerson || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">法人电话</view>
				<view class="item-bottom">{{enterpriseInfo.legalPersonTel || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">注册人申请电话</view>
				<view class="item-bottom">{{enterpriseInfo.registerPersonPhoneTel || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">开户行</view>
				<view class="item-bottom">{{enterpriseInfo.bankname || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">银行账号</view>
				<view class="item-bottom">{{enterpriseInfo.bankcardnumber || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">营业执照截止日期</view>
				<text class="item-bottom">{{enterpriseInfo.businessLicenseEndDate || '--'}}</text>
			</view>
			<view class="property-item">
				<view class="item-top">资质照片</view>
				<view class="item-bottom" v-if="enterpriseInfo.enterpriseQualificationUrl">
					<image :src="url_config+'image/'+enterpriseInfo.enterpriseQualificationUrl" 
					@click="previewImage(url_config+'image/'+enterpriseInfo.enterpriseQualificationUrl)"
					class="icon-image"></image>
					<!-- <image :src="enterpriseInfo.enterpriseQualificationUrl[0].url" 
					@click="previewImage(enterpriseInfo.enterpriseQualificationUrl[0].url)"
					class="icon-image"></image> -->
				</view>
				<view class="item-bottom" v-else>
					<text>--</text>
				</view>
			</view>
		</scroll-view>
		<scroll-view :scroll-y="true" class="scrollBox" :style="{height: screenHeight + 'px'}" v-if="checked == 2">
			<view class="property-item">
				<view class="item-top">承包商名称</view>
				<view class="item-bottom">{{conProjectInfo.cbsName || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">项目施工区域</view>
				<view class="item-bottom">{{conProjectInfo.projectBuildArea || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">项目经理</view>
				<view class="item-bottom">{{conProjectInfo.projectManage || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">项目类型</view>
				<view class="item-bottom">{{conProjectInfo.cbsProjectTypeName || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">施工阶段</view>
				<view class="item-bottom">{{conProjectInfo.constructionStageName || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">经度位置</view>
				<view class="item-bottom">{{conProjectInfo.longitude || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">纬度位置</view>
				<view class="item-bottom">{{conProjectInfo.latitude || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">项目编号</view>
				<view class="item-bottom">{{conProjectInfo.projectNumber || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">结构类型</view>
				<view class="item-bottom">{{conProjectInfo.structureTypeName || '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">项目面积(㎡)</view>
				<view class="item-bottom">{{conProjectInfo.projectAcreage ? conProjectInfo.projectAcreage + '㎡' : '--'}}</view>
			</view>
			<view class="property-item">
				<view class="item-top">工程状态</view>
				<view class="item-bottom">{{
					conProjectInfo.bulidStatus == 0 ? '未开工' : 
					conProjectInfo.bulidStatus == 1 ? '在建' : 
					conProjectInfo.bulidStatus == 2 ? '停工' : 
					conProjectInfo.bulidStatus == 3 ? '竣备' : '--'
				}}</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				projectId: '',
				checked: 1,
				screenHeight: '',
				enterpriseInfo: '',
				conProjectInfo: '',
			};
		},
		onLoad(option) {
			this.id = option.id
			this.projectId = option.projectId
			this.getHeight()
			this.getDetailInfo()
		},
		methods: {
			getHeight() {
				this.screenHeight = uni.getSystemInfoSync().screenHeight - 44 - 44
				console.log(this.screenHeight);
			},
			handleTab(val){
				this.checked = val
			},
			getDetailInfo(){
				let data = {
					enterpriseId: this.id,
					projectSn: JSON.parse(uni.getStorageSync('projectDetail')).projectSn,
				}
				let that = this
				this.sendRequest({
					url: 'xmgl/enterpriseInfo/getEnterpriseInfoById',
					method: 'post',
					data: data,
					success: res => {
						console.log("enterpriseInfo", res);
						this.enterpriseInfo = res.result
						
						// if(this.enterpriseInfo.enterpriseQualificationUrl){
						// pc处理方式
						// 	this.enterpriseInfo.enterpriseQualificationUrl = 
						// 	res.result.enterpriseQualificationUrl &&  res.result.enterpriseQualificationUrl.split(',').length > 0 ? 
						// 	res.result.enterpriseQualificationUrl.split(',').map(item => {
						// 		return {
						// 			name: item.split('*')[0],
						// 			url: that.url_config+'image/'+ item.split('*')[1],
						// 		}
						// 	}) : res.result.enterpriseQualificationUrl.indexOf('http://') >= 0 ? res.result.enterpriseQualificationUrl : 
						// 		res.result.enterpriseQualificationUrl,
						// }
						
						//如果app有图片但没加载出来，就切换成上面pc处理方式
						if(this.enterpriseInfo.enterpriseQualificationUrl){
							this.enterpriseInfo.enterpriseQualificationUrl = this.enterpriseInfo.enterpriseQualificationUrl.split('*')[1]
						}
						
						this.conProjectInfo = res.result.projectEnterprise
					}
				})
			},
			//预览图片
			previewImage(url) {
				console.log('url',url);
				uni.previewImage({
					urls: [url]
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.barBox {
		// background-color: #5181F6;
		background-color: #f6f6f6;
		min-height: 100%;
		height: 44px;
		.fixedheader {
			position: fixed;
			top: 0;
			left: 0;
			width: 100%;
			z-index: 999;
			.headerName {
				z-index: 1;
			}
		}
	}
	.tabBox{
		width: 100%;
		height: 44px;
		display: flex;
		.enterprise-tab{
			width: 50%;
			height: 100%;
			border: 1rpx solid #e5e5e5;
			// border-top: none;
			// border-left: none;
			line-height: 44px;
			text-align: center;
		}
		.project-tab{
			width: 50%;
			height: 100%;
			border: 1rpx solid #e5e5e5;
			// border-top: none;
			// border-right: none;
			line-height: 44px;
			text-align: center;
		}
		.active-tab{
			background-color: #2b8df3;
		}
	}
	.scrollBox{
		height: 100%;
		width: calc(100% - 20px);
		// background-color: darkred;
		margin: 0 10px;
		word-break: break-all;
		.property-item{
			// line-height: 25px;
			margin-bottom: 15px;
			.item-top{
				color: #878787;
			}
			.item-bottom{
				margin-top: 5px;
				width: auto;
				height: auto;
				.icon-image{
					width: 50px;
					height: 50px;
				}
			}
		}
	}
</style>
