<template>
	<view class="page">
		<view class="block">
			<view class="form-list">
				<view class="line">
					<view class="name">LOGO</view>
					<view class="val">
						<image class="avatar" :src="info.logoUrl"></image>
					</view>
				</view>
				<view class="line">
					<view class="name">{{ platformName }}名称</view>
					<view class="val">{{ info.classificationName }}</view>
				</view>
				<view v-if="platformSource === '6'" class="line">
					<view class="name">供应商分类</view>
					<view class="val">{{ typeName }}</view>
				</view>
				<view class="line">
					<view class="name">{{ platformName }}slogan</view>
					<view class="val">{{ info.slogan }}</view>
				</view>
				<view class="line">
					<view class="name">省份</view>
					<view class="val">{{ info.province }}</view>
				</view>
				<view class="line">
					<view class="name">城市</view>
					<view class="val">{{ info.city }}</view>
				</view>
				<view class="line">
					<view class="name">地址</view>
					<view class="val">{{ info.address }}</view>
				</view>
				<view class="line">
					<view class="name">联系电话</view>
					<view class="val">{{ info.phone }}</view>
				</view>
				<view class="line no-bd">
					<view class="name">{{ platformName }}简介</view>
					<view class="val">{{ info.briefIntroduction }}</view>
				</view>
				<view class="py">
					<image v-for="(item, i) in pictureUrl" :key="i" class="pic" :src="item"></image>
				</view>
				<view v-if="info.qrCodeOneName" class="line">
					<view class="name">二维码描述1</view>
					<view class="val">{{ info.qrCodeOneName }}</view>
				</view>
				<view v-if="info.qrCodeOneUrl" class="line">
					<view class="name">二维码1</view>
					<image class="qrcode" :src="info.qrCodeOneUrl" mode="widthFix"></image>
				</view>
				<view v-if="info.qrCodeTwoName" class="line">
					<view class="name">二维码描述2</view>
					<view class="val">{{ info.qrCodeTwoName }}</view>
				</view>
				<view v-if="info.qrCodeTwoUrl" class="line">
					<view class="name">二维码2</view>
					<image class="qrcode" :src="info.qrCodeTwoUrl" mode="widthFix"></image>
				</view>
				<view v-if="info.qrCodeThreeName" class="line">
					<view class="name">二维码描述3</view>
					<view class="val">{{ info.qrCodeThreeName }}</view>
				</view>
				<view v-if="info.qrCodeThreeUrl" class="line">
					<view class="name">二维码3</view>
					<image class="qrcode" :src="info.qrCodeThreeUrl" mode="widthFix"></image>
				</view>
			</view>
		</view>
		
		<view v-if="isTeam" class="btn-wrap">
			<view class="btn" @click="toEdit">编辑</view>
		</view>
	</view>
</template>

<script>
	import { queryTeamInfo, enterpriseCertificationStatus } from '@/apis/modules/user.js'
	import Common from '@/config/common'
	export default {
		data() {
			return {
				openId: uni.getStorageSync('openId'),
				isTeam: uni.getStorageSync('team').isTeam == 1, // 队长
				teamId: uni.getStorageSync('teamId'),
				info: {},
				pictureUrl: [],
				typeName: '',
				platformSource: '',
			}
		},
		computed: {
			// 平台名字
			platformName() {
				return this.platformSource === '6' ? '供应商' : this.platformSource === '5' ? '幼儿园' : ''
			},
		},
		onShow() {
			this.pictureUrl = []
			this.getEnterInfo()
			this.getInfo()
		},
		methods: {
			// 获取个人信息
			getInfo() {
				queryTeamInfo({
					teamId: this.teamId
				}).then(res => {
					const data = res.teamInfo
					if (!data.logoUrl) data.logoUrl = Common.avatar
					
					// 分类回显
					const type = res.supplierClassification
					if (type && type.length) {
						this.typeName = type[0].supplierClassificationName
					} else {
						this.typeName = ''
					}
					
					if (data.pictureUrl) this.pictureUrl = data.pictureUrl.split(',')
					this.info = data
				}).catch(e => {})
			},
			// 企业认证信息
			async getEnterInfo() {
				const { data } = await enterpriseCertificationStatus(this.openId)
				if (data) {
					this.platformSource = data.platformSource
				}
			},
			// 编辑
			toEdit() {
				this.$util.to('/team/infoEdit/infoEdit')
			}
		}
	}
</script>

<style scoped lang="scss">
.page {
	padding-bottom: 170rpx;
	-webkit-overflow-scrolling: touch;
}
.avatar {
	width: 80rpx;
	height: 80rpx;
	border: 0;
	border-radius: 50%;
}
.form-list {
	.pic {
		width: 200rpx;
		height: 200rpx;
		margin-right: 10rpx;
	}
	.qrcode {
		width: 300rpx;
	}
}
</style>
