<template>
	<view class="subpackage-host">
		<component v-if="Impl" :is="Impl" v-bind="$attrs" v-on="$listeners" />
		<view v-else class="loading">
			<text v-if="error">{{ error }}</text>
			<text v-else>正在加载...</text>
		</view>
	</view>
</template>

<script>
export default {
	inheritAttrs: false,
	data() {
		return {
			Impl: null,
			error: ''
		};
	},
	created() {
		this.loadImpl();
	},
	methods: {
		loadSubPackagePagesSubpackage() {
			return new Promise((resolve, reject) => {
				if (!uni || !uni.loadSubPackage) {
					resolve();
					return;
				}
				uni.loadSubPackage({
					name: 'pages-subpackage',
					success: resolve,
					fail: () => {
						uni.loadSubPackage({
							root: 'pages-subpackage',
							success: resolve,
							fail: reject
						});
					}
				});
			});
		},
		async loadImpl() {
			try {
				await this.loadSubPackagePagesSubpackage();
				const mod = await import('@/pages-subpackage/furniture_reception/common_begin_reception.vue');
				this.Impl = mod && (mod.default || mod);
			} catch (e) {
				console.error('[CommonBeginReceptionHost] loadImpl failed:', e);
				this.error = '模块加载失败';
			}
		}
	}
};
</script>

<style>
.subpackage-host {
	min-height: 1px;
}
.loading {
	padding: 24rpx 16rpx;
	color: #666;
	font-size: 28rpx;
}
</style>