<route lang="jsonc" type="page">
{
	"needLogin": true,
	"layout": "default",
	"style": {
		"navigationBarBackgroundColor": "#FFF",
		"navigationBarTitleText": "资质信息"
	}
}
</route>

<template>
	<view class="flex flex-col min-h-screen">
		<view class="bg-[#fff] pt-28rpx px-30rpx">
			<view class="font-800 text-36rpx text-[#303133] leading-50rpx flex items-center">
				<view class="mr-20rpx">经营资质</view>
				<view @click="router.navigateTo(`/bundle/store-license/add?id=${licenses.id}`)">
					<wd-icon name="edit-outline" size="32rpx"></wd-icon>
				</view>
			</view>
			<view class="flex items-center mt-28rpx text-28rpx leading-40rpx">
				<view class="mr-20rpx text-[#606266]">证件号码：</view>
				<view class="text-[#303133]">{{ licenses.card }}</view>
			</view>

			<view class="flex items-center mt-28rpx text-28rpx leading-40rpx">
				<view class="mr-20rpx text-[#606266]">企业名称：</view>
				<view class="text-[#303133]">{{ licenses.name }}</view>
			</view>

			<view class="flex items-center mt-28rpx text-28rpx leading-40rpx">
				<view class="mr-20rpx text-[#606266]">法定代表：</view>
				<view class="text-[#303133]">{{ licenses.legal_person }}</view>
			</view>

			<view class="flex items-center mt-28rpx text-28rpx leading-40rpx">
				<view class="mr-20rpx text-[#606266]">有效期至：{{ licenses.effective == 1 ? '永久有效' : licenses.end_time }}</view>
			</view>

			<view class="mt-24rpx mb-34rpx">
				<wd-img width="624rpx" height="420rpx" :src="licenses.license_img" mode="aspectFit" @click="previewImage(licenses.license_img, [licenses.license_img])"/>
			</view>
		</view>
		<view class="bg-[#F8F9FA] flex-1 px-42rpx">
			<wd-divider color="#9CA3AF">免责声明</wd-divider>
			<view class="text-22rpx text-[#9CA3AF] leading-40rpx">以上资质信息来源于商家自我声明和/或申报内容。商家需保证信息真实有效，平台也将定期核查。如与实际不符或有疑问，请联系平台客服。</view>
		</view>
	</view>
</template>


<script lang="ts" setup>
	import { getStoreQual } from '@/api/store'
	import { useStoreStore } from '@/store'
	import { previewImage, router } from '@/utils/tools'
	
	const useStore = useStoreStore()

	const licenses = ref({
		id: 0,
		card: '', // 证件号码
		name: '', // 企业名称
		legal_person: '', // 法定代表
		effective: 0, // 有效期 1-长期 2-非长期
		end_time: '', // 结束时间
		license_img: '' // 营业执照图片地址
	})

	onLoad(() => {
		getStoreQual(useStore.defaultStore.id).then(res => {
			licenses.value = res.details
		})
		// TODO: 拉取经营资质数据，赋值 licenses.value
	});
</script>

