index.uvue 8.11 KB
<template>
    <!-- <view class="home-frame-container scene-shell-root hf-embed-in-tab-slot"> -->

        <!-- 主导航 Tabbar 由 TabBarShell 横/竖壳承担;此处仅内容区 -->
        <!-- <view class="home-content hf-content-without-tabbar"> -->
            <!-- <view class="right-side"> -->
                <!-- 仅「场景首页」:接待中心 / 我的 为独立路由页(见 HomeFrameTabbar) -->
                <!-- 三卡片布局:轻改 / 权益等使用 swiperCustom -->
                <view class="app-content-box">
                    <!-- ✅ 性能优化:骨架屏 + 异步加载 -->
                    <StartReceptionSkeleton v-if="!startReceptionLoaded" />
                    <view v-else-if="props.showStartReception"
                          class="start"
                          hover-class="start-hover"
                          @click="onStartClick">
                        <view class="start-inner">
                            <view class="start-icon-wrap">
                                <un-icon name="play-right-fill" size="14" color="#1677ff"></un-icon>
                            </view>
                            <text class="start-text">开始接待</text>
                        </view>
                    </view>
                    <view class="right-content-box flex-row">
                        <view class="content-left">
                            <view class="module-box box-class">
                                <!-- ✅ 性能优化:骨架屏 + 异步加载 -->
                                <ProductIntroSkeleton v-if="!productIntroLoaded" />
                                <view v-else-if="props.swiperCustom" class="content-box">
                                    <ProductIntroSwiper
                                                        :load-complete="props.introLoadComplete ?? false"
                                                        :swiper-list="props.introSwiperList ?? []"
                                                        :modules="props.introModules ?? []"
                                                        :eyebrow="props.introEyebrow ?? '权益中心'"
                                                        :empty-title="props.introEmptyTitle ?? '权益配置中'"
                                                        :empty-text="props.introEmptyText ?? '敬请期待'"
                                                        :show-switch-product="props.introShowSwitchProduct ?? false"
                                                        @swiper-change="onIntroSwiperChange"
                                                        @slide-tap="onIntroSlideTap"
                                                        @switchProduct="onIntroSwitchProduct" />
                                </view>
                                <view v-else class="content-box swiper-placeholder">
                                    <text class="placeholder-text">敬请期待</text>
                                </view>
                            </view>
                            <view class="tool-box box-class">
                                <view class="common-title">
                                    <text class="title-text">{{ props.toolBoxTitle ?? '展业工具' }}</text>
                                </view>
                                <view class="content-box tool-content-box">
                                    <!-- 展业工具骨架屏 -->
                                    <ToolSkeleton v-if="!toolBoxLoaded" :count="4" />
                                    <view v-else class="swiper-placeholder">
                                        <un-empty
											mode="data"
											text="敬请期待"
										>
										</un-empty>
                                    </view>
                                </view>
                            </view>
                        </view>
                        <!-- <view class="content-right box-class">
                            <view class="common-title">
                                <text class="title-text">服务中心</text>
                            </view>
                            <view class="content-box">
                                <HomeFrameMessageIndex class="message-box" />
                            </view>
                        </view> -->
                    </view>
                </view>
            <!-- </view> -->
        <!-- </view> -->
    <!-- </view> -->
</template>

<script setup lang="uts">
import { defineExpose, onMounted, ref } from "vue";

// ✅ 从 uview-unix 模块导入 UnSwiperItem 类型
import type { UnSwiperItem } from "@/uni_modules/uview-unix";

import ProductIntroSkeleton from "@/components/Skeleton/ProductIntroSkeleton.uvue";
import StartReceptionSkeleton from "@/components/Skeleton/StartReceptionSkeleton.uvue";
import ToolSkeleton from "@/components/Skeleton/ToolSkeleton.uvue";
import { delay } from "@/utils/delay.uts"; // ✅ 导入延迟执行工具函数
// import { cssClassRef, useResolutionConfig } from "@/services/adapter";
// import { layoutService } from "@/services/LayoutService.uts";
import { requestRecordPermission } from "@/utils/permission.uts";

import ProductIntroSwiper from "./ProductIntroSwiper.uvue";


const props = withDefaults(defineProps<{
  showFooter?: boolean
  swiperCustom?: boolean
  /** 产品介绍区:与 swiperCustom 配套,由页面传入列表与文案 */
  introLoadComplete?: boolean
  introSwiperList?: UnSwiperItem[]
  introModules?: any[]
  introEyebrow?: string
  introEmptyTitle?: string
  introEmptyText?: string
  introSwiperHeight?: number | null
  /** 精品 Pad:产品介绍区展示「切换产品」按钮(对齐 simgle_app HomeSlot) */
  introShowSwitchProduct?: boolean
  /** 是否显示「开始接待」按钮;未传或为 true 时显示 */
  showStartReception?: boolean
  /** 展业工具区块标题,默认「展业工具」 */
  toolBoxTitle?: string
  /**
   * 嵌入 `pages/index/index` 的 TabBarShell 槽内:与外层壳叠加时作为 flex 子项占满剩余区域。
   * 独立整页使用 HomeFrame 时不要传(默认 false)。
   */
  embedInTabSlot?: boolean
}>(), {
	showStartReception: true,
	introShowSwitchProduct: false,
	embedInTabSlot: false,
});

const emit = defineEmits<{
  start: []
  introSwiperChange: [index: number]
  introSlideTap: [index: number]
  introSwitchProduct: []
}>();


function onIntroSwiperChange(index: number): void {
	emit("introSwiperChange", index);
}

function onIntroSlideTap(index: number): void {
	emit("introSlideTap", index);
}

function onIntroSwitchProduct(): void {
	emit("introSwitchProduct");
}

/** ✅ 性能优化:分模块异步加载状态管理 */
const startReceptionLoaded = ref<boolean>(false);    // 开始接待按钮加载状态
const productIntroLoaded = ref<boolean>(false);      // 产品介绍模块加载状态
const toolBoxLoaded = ref<boolean>(false);           // 展业工具加载状态

// ✅ 性能优化:updateApp 保留供外部调用,但当前无实际逻辑
function updateApp(): void {
	// TODO: 如需刷新用户信息,在此添加逻辑
}

function onStartClick(): void {
	emit("start");
}


onMounted((): void => {
	requestRecordPermission();

	// ✅ 性能优化:分模块异步加载,避免低端机白屏
	// 初始状态已为 false,无需重复设置
	// startReceptionLoaded.value = false;  // ← 冗余,移除
	// productIntroLoaded.value = false;    // ← 冗余,移除
	// toolBoxLoaded.value = false;         // ← 冗余,移除

	// ✅ 修复白屏:增加首次延迟时间,确保骨架屏完全渲染后再开始显示内容
	// 低端机上骨架屏渲染可能需要 50-100ms
	delay(() => {
		// 1. 第一个模块:开始接待按钮(最快)
		startReceptionLoaded.value = true;

		delay(() => {
			// 2. 第二个模块:产品介绍
			productIntroLoaded.value = true;

			delay(() => {
				// 3. 第三个模块:展业工具(最慢)
				toolBoxLoaded.value = true;
			}, 2); // 约 32ms
		}, 2); // 约 32ms
	}, 4); // ✅ 增加到 64ms,给骨架屏足够的渲染时间
});
defineExpose({
	updateApp
});
</script>

<style scoped lang="scss">
@import "./styles/common.scss";
</style>