<template>
	<view class="se-mt-10">
		<view class="se-m-20 se-br-20 se-bs-b se-bgc-white se-py-20 se-px-30">
			<view class="se-flex se-flex-ai-c se-pb-10">
				<view class="line-orange"></view>
				<view class="se-ml-10 se-fs-32 se-c-black se-fw-6">
					企业信息
				</view>
			</view>
			<view class="se-py-10 se-pb-30">
				<view class="se-mt-30">
					<text class="se-fs-28 se-c-black se-fw5">公司名称：{{companyData.employAuthenticationCompany && companyData.employAuthenticationCompany.name || companyData.workName || '暂未'}}</text>
					<br>
					<text class="se-fs-28 se-c-black se-fw5">公司地址：{{companyData.employAuthenticationCompany && companyData.employAuthenticationCompany.address || companyData.workAddress || '暂未'}}</text>
					<br>
					<text class="se-fs-28 se-c-black se-fw5">所属行业：{{companyData.employAuthenticationCompany && companyData.employAuthenticationCompany.industryName || '暂未'}}</text>
					<br>
					<text class="se-fs-28 se-c-black se-fw5">招聘联系人：{{companyData.employAuthenticationPerson && companyData.employAuthenticationPerson.name || '暂未'}}</text>
					<br>
					<text class="se-fs-24 se-c-text-third">联系方式：{{companyData.employAuthenticationPerson && companyData.employAuthenticationPerson.phone || '暂未'}}</text>
					<view class="se-bgc-orange se-c-white se-fs-20 se-display-ib se-px-10 se-py-5 se-br-10 se-ml-10"
						@click="copyText(companyData.employAuthenticationPerson && companyData.employAuthenticationPerson.phone)">
						复制
					</view>
				</view>
				<view class="se-mt-10">
					<text class="se-fs-24 se-c-33">工作地址：{{companyData.workAddress || '暂未'}}</text>
					<view class="se-bgc-orange se-c-white se-fs-20 se-display-ib se-px-10 se-py-5 se-br-10 se-ml-10"
						@click="copyText(companyData.workAddress)">
						复制
					</view>
				</view>
			</view>
			<!-- 联系企业按钮 -->
			<view class="se-px-220 se-pb-30 se-fs-20 se-flex se-flex-h-c" v-if="showContactButton">
				<view
					@click="callCompany()"
					class="se-mx-10 se-w-200 se-br-40 se-flex-h-c se-h-50 se-lh-50 se-ta-c se-fs-24 se-c-white se-bgc-orange">
					<text>联系企业</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'CompanyInfo',
	props: {
		// 企业数据
		companyData: {
			type: Object,
			default: () => ({})
		},
		// 是否显示联系企业按钮
		showContactButton: {
			type: Boolean,
			default: false
		}
	},
	methods: {
		// 复制文本
		copyText(text) {
			if (!text) {
				uni.showToast({
					title: '暂无内容可复制',
					icon: 'none'
				});
				return;
			}
			
			uni.setClipboardData({
				data: text,
				success: () => {
					uni.showToast({
						title: "复制成功",
						icon: "none",
					});
				},
				fail: (err) => {
					console.error("复制失败", err);
				},
			});
		},
		
		// 拨打企业联系人电话
		callCompany() {
			const phone = this.companyData.employAuthenticationPerson && this.companyData.employAuthenticationPerson.phone;
			if (phone) {
				uni.makePhoneCall({
					phoneNumber: phone,
					fail: (err) => {
						console.error('拨打电话失败', err);
						uni.showToast({
							title: '拨打电话失败',
							icon: 'none'
						});
					}
				});
			} else {
				uni.showToast({
					title: '企业联系人电话号码不存在',
					icon: 'none'
				});
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.line-orange {
	width: 8rpx;
	height: 32rpx;
	background: #ff7a31;
	border-radius: 4rpx;
}
</style>