<template>
	<view>
		<u-image :src="imgUrl+detailList.cover" width="750rpx" height="290rpx">
		</u-image>
		<view class="feature">
			<text class="one_title">经营范围及特色</text>
			<view class="green_block">
				<text class="green_features">{{detailList.desc}}</text>
			</view>
		</view>
		<view class="introduce">
			<view class="introduce_title">企业介绍</view>
			<text class="business_introduce">{{detailList.content}}</text>
		</view>
		<view class="show">
			<view class="introduce_title">企业展示</view>
			<u-grid :border="false" col="4">
				<u-grid-item v-for="(listItem,listIndex) in detailList.images" :key="listIndex">
					<u--image :src="imgUrl+listItem" width="170rpx" height="170rpx" :lazy-load="true">
					</u--image>
				</u-grid-item>
			</u-grid>
		</view>
		<view class="footer">
			<u-icon name="kefu-ermai" color="#fff" size="30rpx"></u-icon>
			<text>联系客服</text>
		</view>
		<view style="margin:0 20rpx;">
			<u-overlay :show="!isLoad">
				<login @success="reOnLoad()" @fail="failToLoad()"></login>
			</u-overlay>
		</view>
	</view>
</template>

<script>
	import login from 'pages/my/login/login'
	export default {
		components: {
			login
		},
		data() {
			return {
				id: '',
				detailList: [],
				imgUrl: '',
				isLoad: true
			}
		},
		onLoad(option) {
			this.id = option.id
			this.getCertifiedCjDetail()
			this.imgUrl = uni.getStorageSync('img_url')
			if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
				this.isLoad = false
				// uni.navigateTo({
				// 	url: '../../pages/my/login/login'
				// })
				return
			}
			this.isLoad = true
		},
		methods: {
			//获取认证厂家详情
			getCertifiedCjDetail() {
				this.$apiServe.getCertifiedCjDetail(this.id).then(res => {
					// console.log('认证厂家详情页', res.data)
					if (res.data.data) {
						let data = res.data.data
						data.images = data.images.split(';')
						this.detailList = data
					} else {
						this.$toast.warn('没有更多详情了')
					}
				}).finally(_ => {})
			},
			reOnLoad() {
				if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
					this.$toast.warn('登录失败请重试')
					this.isLoad = false
					// uni.navigateTo({
					// 	url: '../../pages/my/login/login'
					// })
					return
				}
				this.isLoad = true
				this.getCertifiedCjDetail()
			},
			failToLoad() {
				this.$toast.warn('登录失败请重试')
			}
		}
	}
</script>

<style lang="scss">
	.feature {
		padding: 20rpx 16rpx;
		background-color: #fff;
		margin-bottom: 30rpx;

		.one_title {
			font-size: 28rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: bold;
			color: #3E3E3E;
			line-height: 40rpx;
		}

		.green_block {
			background-color: #16CA65;
			margin-top: 20rpx;

			height: 139rpx;
			border-radius: 6rpx;

			.green_features {
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
				line-height: 33rpx;
				margin-left: 20rpx;
				margin-top: 14rpx;
			}
		}
	}

	.introduce {
		padding: 20rpx 16rpx;
		background-color: #fff;
		margin-bottom: 30rpx;

		.introduce_title {
			font-size: 28rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: bold;
			color: #3E3E3E;
			line-height: 40rpx;
			margin-bottom: 10rpx;
		}

		.business_introduce {
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #666666;
			line-height: 33rpx;
		}
	}

	.show {
		padding: 20rpx 16rpx;
		background-color: #fff;
		margin-bottom: 78rpx;

		.u-grid {
			padding-top: 22rpx !important;
		}
	}

	.footer {
		height: 100rpx;
		background: #0EBB5B;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-content: center;
		text-align: center;

		.u-icon {
			justify-content: center;
		}

		text {
			font-size: 20rpx;
			font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
			font-weight: bold;
			color: #FFFFFF;
			line-height: 26rpx;
		}
	}
</style>
