<template>
	<view style="padding-top: 30px;">
		<view class="company-box">
			<view class="banner-box">
				<image :src="model.BannerList[0]" mode="aspectFill" class="banner"></image>
				<view class="status-layer">
					<img :src="statusImages[company.CompanyStatus]" />
				</view>
			</view>
			
			<div class="info">
				<view class="name">
					{{model.BrandName?model.BrandName:''}}
					{{model.Name?model.Name:''}}
					{{model.CarrierName?model.CarrierName:''}}
				</view>
				<view>
					<view class="tag-box" style="display: flex; overflow: hidden;margin-top: 10rpx;">
					  <text class="tag1">{{allTypeCnName[company.FirstShopType-1]}}</text
					  ><text class="tag2">{{ model.CategoryName }}</text>
					</view>
				</view>
				<view class="company-name">
					企业名称：{{company.CompanyName}}
				</view>
				<div class="reject" v-if="company.CompanyStatus==2&&company.RejectRemark">
					<view class="">驳回原因</view>
					<view style="font-size: 24rpx;margin-top: 10rpx;">
						{{company.RejectRemark}}
					</view>
				</div>
				<view class="option-box" v-if="company.CompanyStatus>0">
					<view class="item" @click="setEditorHandler">修改</view>
					<view class="split"></view>
					<view class="item" v-if="company.CompanyStatus==2" style="color: #F60;" @click="seeDelHandler">删除</view>
					<view class="item" @click="seeDetailsHandler" v-else :style="{color:mainColor}">详情</view>
				</view>
			</div>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			company:{
				type:Object
			}
		},
		data() {
			return {
				model:[],
				allTypeList:['BrandModel','CarrierModel','EnterpriseServicesModel','buildingApplyForModel'],
				allTypeCnName:['品牌','载体','企业','楼宇'],
				statusImages:[
					'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638699743437937519.png',
					'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638699743172273668.png',
					'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638699743172742181.png'
				],
				mainColor:'',
				links:['/pages/kotra/brand/detail_brand?id=','/pages/kotra/carrier/detail_carrier?id=','/pages/kotra/brand/detail_company?id=','/pages/kotra/carrier/detail_building?id=']
			}
		},
		mounted() {
			this.mainColor = this.$uiConfig.mainColor
			this.model = this.company[this.allTypeList[this.company.FirstShopType-1]]
			console.log(this.model)
		},
		methods: {
			setEditorHandler(){
				this.$emit('change',1)
			},
			seeDetailsHandler(){
				uni.navigateTo({
					url:this.links[this.company.FirstShopType-1]+this.model.ID
				})
				
			},
			seeDelHandler() {
				let that = this
				uni.showModal({
					content: `是否删除企业 "${that.company.CompanyName}" 相关信息？`,
					confirmText: "确认",
					cancelText: '取消',
					success: (res) => {
						if (res.confirm) {
							let parms = {
								url: "/api/AppletTrade/RemoveCompanyEnterprise",
								data: {
									CompanyId: that.model.CompanyId
								}
							};
							that.request2(parms, (res) => {
								if (res.resultCode == 1) {
									wx.showToast({
										icon: 'none',
										title: "删除成功！",
										duration: 1000,
									});
									uni.navigateBack({
										delta: 1
									});
								}
							})
						}
					}
				})
			}
		}
	}
</script>

<style>
.company-box {
	margin:0 30px;
	border-radius: 16rpx;
	background-color: #FFF;
	overflow: hidden;
}
.company-box .banner{
	width: 100%;
	max-height: 160px;
	background-color: #f1f1f1;
}
.company-box .banner-box{
	position: relative;
}
.company-box .banner-box .status-layer{
	background-color: rgba(0,0,0,.65);
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	top: 0;
	z-index: 2;
	display: flex;
	justify-content: center;
	align-items: center;
}
.company-box .banner-box .status-layer image{
	width: 192rpx;
	height: 160rpx;
}
.company-box .reject{
	background: #FCEAEA;
	border-radius: 10rpx;
	padding: 14rpx;
	color: #DD8D8D;
	font-size: 28rpx;
	margin-top: 14px;
}
.company-box .info{
	padding:12px;
}
.company-box .info .name{
	font-size: 16px;
	font-weight: bold;
}
.company-box .info .company-name{
	font-size: 12px;
	color: #999;
	margin-top: 5px;
}
.company-box .tag-box {
      border-radius: 6rpx;
	  overflow: hidden;
}
.company-box .tag-box .tag1 {
	padding: 7rpx 10rpx;
	background-color: #1f1f1f;
	font-size: 20rpx;
	color: #ffffff;
}
.company-box .tag-box .tag2 {
	padding: 7rpx 10rpx;
	background-image: linear-gradient(90deg, #e8cea5, #caa974);
	font-size: 20rpx;
	color: #1f1f1f;
	border-top-right-radius: 6rpx;
	border-bottom-right-radius: 6rpx;
}
.company-box .option-box{
	margin-top: 28rpx;
	padding: 28rpx 0 8rpx 0;
	border-top: 1px solid #f1f1f1;
	display: flex;
	align-items: center;
}
.company-box .option-box .item{
	flex: 1;
	font-size: 28rpx;
	text-align: center;
}
.company-box .option-box .split{
	height:40rpx;
	background: #EFEFEF;
	width: 1px;
}
</style>
