Commit 91ce5326 by liimin

refactor(receptionCenter, adapter): 清理适配代码,重构工具与样式体系

删除废弃的全局common.scss文件及其导入语句,将样式迁移至组件scoped样式与CSS变量中
整合拆分的接待详情工具函数,将原receptionDetail.helper.uts、receptionDetail.qualityTransform.uts、lists/reception-detail-helpers.uts合并为统一的receptionDetail.helpers.uts
移除废弃的usePageVars、旧适配器类型定义、layout-adapt.scss等冗余适配文件与代码
修正SenceSelect组件的拼写错误为SceneSelect,统一项目组件命名规范
为CSS变量添加fallback默认值,修复变量缺失时的样式异常问题
删除全局分辨率适配的冗余配置与导入代码,简化现有适配逻辑
统一所有hooks的导入路径,修正多处文件导入错误
简化硬编码的适配样式,移除不必要的动态变量赋值
1 parent 19a214a2
Showing 38 changed files with 453 additions and 931 deletions
<script lang="uts"> <script lang="uts">
// import { updateResolutionConfig } from "@/services/adapter/index.uts";
// #ifdef APP // #ifdef APP
import { applyScreenOrientationLock } from "@/utils/apply-orientation-lock.uts"; import { applyScreenOrientationLock } from "@/utils/apply-orientation-lock.uts";
import ws from "@/ws"; import ws from "@/ws";
// #endif // #endif
import { updateOrientation } from "@/services/adapter/hooks/index.uts";
let firstBackTime = 0; let firstBackTime = 0;
export default { export default {
onLaunch () { onLaunch () {
// 初始化方向状态,后续由 appMixin.onResize 统一更新
updateOrientation(true);
// #ifdef APP // #ifdef APP
const sys = uni.getSystemInfoSync(); const sys = uni.getSystemInfoSync();
console.log(`[App] 当前分辨率:${ sys.screenWidth } x ${ sys.screenHeight}`); console.log(`[App] 当前分辨率:${ sys.screenWidth } x ${ sys.screenHeight}`);
...@@ -60,8 +62,7 @@ export default { ...@@ -60,8 +62,7 @@ export default {
<style lang="scss"> <style lang="scss">
/* 引入自定义 CSS 工具类 */ /* 引入自定义 CSS 工具类 */
@import url("./common.css"); @import url("./common.css");
/* I18n 布局适配:横竖屏 + 分辨率 */
// @import "./services/adapter/styles/layout-adapt.scss";
/* 全局默认样式:App 端 view 不支持 font-size,基准字号用 var(--l-font-*) 落在 <text> 上 */ /* 全局默认样式:App 端 view 不支持 font-size,基准字号用 var(--l-font-*) 落在 <text> 上 */
.layout-root { .layout-root {
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
import { ComponentPublicInstance, computed, onUnmounted, ref, watch } from "vue"; import { ComponentPublicInstance, computed, onUnmounted, ref, watch } from "vue";
import { getEmployeeListApi } from "@/api/common-api.uts"; import { getEmployeeListApi } from "@/api/common-api.uts";
// import { resolutionState } from "@/services/adapter/index.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
import { useWindowHeight } from "@/services/adapter/hooks/index.uts"; import { useWindowHeight } from "@/services/adapter/hooks/index.uts";
...@@ -78,10 +77,6 @@ const salesUuid = computed<string>(() => { ...@@ -78,10 +77,6 @@ const salesUuid = computed<string>(() => {
const dynamicZIndex = computed<number>(() => { const dynamicZIndex = computed<number>(() => {
return 10090; return 10090;
}); });
// const windowHeight = computed<number>(() => {
// const height = resolutionState.windowHeight;
// return height > 0 ? height : uni.getWindowInfo().windowHeight;
// });
const employeeList = ref<Array<any>>([]); const employeeList = ref<Array<any>>([]);
......
...@@ -81,8 +81,13 @@ function onEntryClick(key: string): void { ...@@ -81,8 +81,13 @@ function onEntryClick(key: string): void {
<style scoped lang="scss"> <style scoped lang="scss">
.module-entry-grid { .module-entry-grid {
width: 100%; width: 100%;
/* 用 flex:1 填充父级(wrap 为 flex 列容器),比 height:100% 在原生(wex)渲染下更可靠,
避免竖屏时网格高度塌缩、条目被裁掉 */
flex: 1 1 auto;
/* 自身也是 flex 列容器,让内部 list 用 flex:1 填满,整条高度链不再依赖 height:100% */
display: flex;
flex-direction: column;
min-height: var(--module-entry-grid-min-height, 48px); min-height: var(--module-entry-grid-min-height, 48px);
height: 100%;
background-color: var(--module-entry-grid-bg, #ffffff); background-color: var(--module-entry-grid-bg, #ffffff);
border-radius: var(--module-entry-grid-radius, 8px); border-radius: var(--module-entry-grid-radius, 8px);
box-sizing: border-box; box-sizing: border-box;
...@@ -92,7 +97,7 @@ function onEntryClick(key: string): void { ...@@ -92,7 +97,7 @@ function onEntryClick(key: string): void {
.module-entry-grid__list { .module-entry-grid__list {
width: 100%; width: 100%;
min-height: var(--module-entry-grid-list-min-height, var(--module-entry-grid-min-height, 48px)); min-height: var(--module-entry-grid-list-min-height, var(--module-entry-grid-min-height, 48px));
height: 100%; flex: 1 1 auto;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: nowrap; flex-wrap: nowrap;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<script setup lang="uts"> <script setup lang="uts">
import { computed, onMounted, onUnmounted, type Ref, ref, provide } from 'vue' import { computed, onMounted, onUnmounted, type Ref, ref, provide } from 'vue'
import { updateOrientation, useScreenVars } from '@/services/adapter/hooks/index.uts' import { useScreenVars } from '@/services/adapter/hooks/index.uts'
// import { layoutService } from '@/services/LayoutService.uts' // import { layoutService } from '@/services/LayoutService.uts'
const props = defineProps<{ const props = defineProps<{
pageVars?: UTSJSONObject | null pageVars?: UTSJSONObject | null
......
import { createSSRApp } from "vue"; import { createSSRApp } from "vue";
// 引入分辨率适配模块
// import { resolutionState, useResponsiveImage } from "@/services/adapter/index.uts";
import { logger } from "@/services/logger"; import { logger } from "@/services/logger";
import DBRecord from "@/services/recorder/DBRecord.uts"; import DBRecord from "@/services/recorder/DBRecord.uts";
import { RecordService } from "@/services/recorder/RecordService.uts"; import { RecordService } from "@/services/recorder/RecordService.uts";
...@@ -20,13 +18,6 @@ export function createApp() { ...@@ -20,13 +18,6 @@ export function createApp() {
// RecordService.mount(); // RecordService.mount();
initDB(); initDB();
appMixin(app); appMixin(app);
// 注入全局分辨率适配属性
// app.config.globalProperties.$resState = resolutionState;
// console.log("resolutionState =>", resolutionState);
// 注意:在 main.ts 中,useResponsiveImage 返回的函数可以直接挂载
// 但因为 useResponsiveImage 本身返回的是一个闭包函数,我们直接挂载它返回的函数可能更方便
// 或者我们直接挂载一个 getter 函数
// app.config.globalProperties.$getResImg = useResponsiveImage();
return { return {
app app
......
...@@ -61,18 +61,18 @@ ...@@ -61,18 +61,18 @@
<scroll-view class="list" <scroll-view class="list"
direction="vertical" direction="vertical"
:show-scrollbar="false" :show-scrollbar="false"
:style="styleObject"> :style="screenVars">
<AccountList v-if="stepIndex == 0" <AccountList v-if="stepIndex == 0"
ref="accountRef" ref="accountRef"
:style="styleObject" :style="screenVars"
@choose-account="chooseAccount" /> @choose-account="chooseAccount" />
<MerchantList v-else-if="stepIndex == 1" <MerchantList v-else-if="stepIndex == 1"
ref="merchantRef" ref="merchantRef"
:style="styleObject" :style="screenVars"
@choose-merchant="chooseMerchant" /> @choose-merchant="chooseMerchant" />
<Scene v-else <Scene v-else
ref="sceneRef" ref="sceneRef"
:style="styleObject" /> :style="screenVars" />
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ComponentPublicInstance, nextTick, ref, computed, type Ref } from "vue"; import { ComponentPublicInstance, nextTick, ref } from "vue";
import AccountList from "@/components/common/AccountList.uvue"; import AccountList from "@/components/common/AccountList.uvue";
import MerchantList from "@/components/common/MerchantList.uvue"; import MerchantList from "@/components/common/MerchantList.uvue";
...@@ -90,11 +90,7 @@ import { useScreenVars } from '@/services/adapter/hooks/index.uts' ...@@ -90,11 +90,7 @@ import { useScreenVars } from '@/services/adapter/hooks/index.uts'
import pageVars from './styles/index.vars' import pageVars from './styles/index.vars'
// 响应式样式变量 // 响应式样式变量
const screenVarsHook = useScreenVars(pageVars) const screenVars = useScreenVars(pageVars)
const styleObject = computed((): Any => {
const sv = screenVarsHook.screenVars as Ref<UTSJSONObject>
return sv.value as Any
})
// 不显式导入 onLoad,避免与编译器生成的 BasePage 构造函数中的 onLoad 冲突(error18) // 不显式导入 onLoad,避免与编译器生成的 BasePage 构造函数中的 onLoad 冲突(error18)
// import { onLoad } from "@dcloudio/uni-app"; // import { onLoad } from "@dcloudio/uni-app";
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<script setup lang="uts"> <script setup lang="uts">
import { ref } from "vue"; import { ref } from "vue";
import { useColumnLayout } from "@/services/adapter/hooks"; import { useColumnLayout } from "@/services/adapter/hooks/index.uts";
import StoreCard from "./StoreCard.uvue"; import StoreCard from "./StoreCard.uvue";
import { getStoreCodeField, getStoreNameField, getStoreCode, getStoreAddr, getStorePhone } from "./useStoreSelection"; import { getStoreCodeField, getStoreNameField, getStoreCode, getStoreAddr, getStorePhone } from "./useStoreSelection";
......
...@@ -88,7 +88,7 @@ import { isEmptyStr, type ObjOrNull } from "@/utils/common.uts"; ...@@ -88,7 +88,7 @@ import { isEmptyStr, type ObjOrNull } from "@/utils/common.uts";
import pageVars from "./styles/index.vars.uts"; import pageVars from "./styles/index.vars.uts";
import SkeletonCard from "./SkeletonCard.uvue"; import SkeletonCard from "./SkeletonCard.uvue";
import StoreGrid from "./StoreGrid.uvue"; import StoreGrid from "./StoreGrid.uvue";
import { useColumnLayout } from "@/services/adapter/hooks"; import { useColumnLayout } from "@/services/adapter/hooks/index.uts";
import { useStoreSelection, getStoreCode } from "./useStoreSelection"; import { useStoreSelection, getStoreCode } from "./useStoreSelection";
const { const {
......
// 约定式命名:必须叫 index.vars.uts
export default {
common: {
'--home-box-bg': '#FF4444',
},
portrait: {
'--adapter-color': 'red',
'--adapter-fontsize': '50px',
'--test-view-height': '360px',
'--test-view-border': '10px solid blue',
'--test-view-width': '100%'
'--test-view-bg': 'black',
'--test-view-border-width': '2px',
'--test-view-border-style': 'dashed',
'--test-view-border-color': 'blue',
'--test-view-border-radius': '10px',
'--test-view-align-items': 'center',
'--test-view-justify-content': 'center',
'--test-view-flex-direction': 'column',
'padding': '10px'
},
landscape: {
'--adapter-color': 'green',
'--adapter-fontsize': '50px',
'--test-view-height': '360px',
'--test-view-border': '10px solid blue',
'--test-view-width': '100%'
'--test-view-bg': 'orange',
'--test-view-border-width': '2px',
'--test-view-border-style': 'dashed',
'--test-view-border-color': 'blue',
'--test-view-border-radius': '10px',
'--test-view-align-items': 'center',
'--test-view-justify-content': 'center',
'--test-view-flex-direction': 'column',
'padding': '10px'
},
resolutions: {
'portrait-393x816': {
'--adapter-color': 'blue',
'--adapter-fontsize': '50px',
'--test-view-height': '360px',
'--test-view-border': '10px solid blue',
'--test-view-width': '100%'
'--test-view-bg': 'red',
'--test-view-border-width': '2px',
'--test-view-border-style': 'dashed',
'--test-view-border-color': 'blue',
'--test-view-border-radius': '10px',
'--test-view-align-items': 'center',
'--test-view-justify-content': 'center',
'--test-view-flex-direction': 'column',
'padding': '10px'
},
'landscape-816x393': {
'--adapter-color': '#FF4444',
'--adapter-fontsize': '20px',
'--test-view-width': '100%',
'--test-view-height': '380px',
'--test-view-border': '11px solid red',
'--test-view-bg': 'yellow',
'--test-view-border-width': '1px',
'--test-view-border-style': 'solid',
'--test-view-border-color': 'red',
'--test-view-border-radius': '50px',
'--test-view-align-items': 'center',
'--test-view-justify-content': 'flex-end',
'--test-view-flex-direction': 'row',
'padding': '10px'
},
},
}
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { computed } from "vue"; import { computed } from "vue";
import { useOrientation } from "@/services/adapter/hooks/useOrientation.uts"; import { useOrientation } from "@/services/adapter/hooks/index.uts";
const props = defineProps({ const props = defineProps({
views: { views: {
......
<template> <template>
<layout-root :page-vars="pageVars"> <layout-root :page-vars="pageVars">
<!-- TabBar 壳组件:横/竖两套布局 + 默认槽;方向由 useOrientation 驱动 --> <!-- TabBar 壳组件:单棵 DOM 树,方向通过 CSS 类控制,slot 始终挂载不被销毁重建 -->
<view v-if="shellIsPortrait" class="scene-shell-root-portrait"> <view class="scene-shell-root" :class="shellIsPortrait ? 'mode-portrait' : 'mode-landscape'">
<view class="scene-shell-main-portrait"> <view v-show="!shellIsPortrait" class="scene-shell-sidebar">
<Landscape :user-name="userName"
:current-tab-index="props.activeTabIndex"
@tab-change="(name: string | number) => onTabChange(name)"
@setting="onSetting"
@jump-person-center="jumpPersonCenter"
@switch-store="onSwitchStore" />
</view>
<view class="scene-shell-main">
<slot></slot> <slot></slot>
</view> </view>
<view class="scene-shell-tabbar-portrait"> <view v-show="shellIsPortrait" class="scene-shell-tabbar">
<Portrait :current-tab-index="props.activeTabIndex" <Portrait :current-tab-index="props.activeTabIndex"
@tab-change="(name: string | number) => onTabChange(name)" /> @tab-change="(name: string | number) => onTabChange(name)" />
</view>
</view>
<view v-else class="scene-shell-root-landscape">
<view class="scene-shell-body-landscape">
<Landscape :user-name="userName"
:current-tab-index="props.activeTabIndex"
@tab-change="(name: string | number) => onTabChange(name)"
@setting="onSetting"
@jump-person-center="jumpPersonCenter"
@switch-store="onSwitchStore" />
<view class="scene-shell-main-landscape">
<slot></slot>
</view>
</view> </view>
</view> </view>
<SettingBox :visible="showSetting" <SettingBox :visible="showSetting"
...@@ -37,7 +32,7 @@ import { computed, onMounted, onShow, type Ref } from "vue"; ...@@ -37,7 +32,7 @@ import { computed, onMounted, onShow, type Ref } from "vue";
import SettingBox from "@/pages/person/SettingBox.uvue"; import SettingBox from "@/pages/person/SettingBox.uvue";
import SwitchStoreSheet from "@/components/SwitchStoreSheet.uvue"; import SwitchStoreSheet from "@/components/SwitchStoreSheet.uvue";
import { updateOrientation, useOrientation } from "@/services/adapter/hooks/index.uts"; import { useOrientation } from "@/services/adapter/hooks/index.uts";
import { requestRecordPermission } from "@/utils/permission.uts"; import { requestRecordPermission } from "@/utils/permission.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts"; import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
...@@ -90,63 +85,44 @@ function onTabChange(name: string | number): void { ...@@ -90,63 +85,44 @@ function onTabChange(name: string | number): void {
} }
onMounted((): void => { onMounted((): void => {
updateOrientation(true);
requestRecordPermission(); requestRecordPermission();
hideNativeTabBar(); hideNativeTabBar();
}); });
onShow(() => { onShow(() => {
updateOrientation(true);
hideNativeTabBar(); hideNativeTabBar();
}); });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.scene-shell-root-portrait { /* 根容器:横竖屏共用基础样式 */
.scene-shell-root {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column;
min-height: 0; min-height: 0;
min-width: 0; min-width: 0;
} }
.scene-shell-main-portrait { /* 竖屏:纵向排列 [内容区 | 底部TabBar] */
flex: 1; .mode-portrait {
min-height: 0;
min-width: 0;
display: flex;
flex-direction: column; flex-direction: column;
overflow: hidden;
padding: 0 var(--content-box-padding-side, 8px);
} }
.scene-shell-tabbar-portrait { /* 横屏:横向排列 [侧边栏 | 内容区] */
flex-shrink: 0; .mode-landscape {
height: var(--tabbar-height, 60px); flex-direction: row;
} }
.scene-shell-root-landscape { /* 侧边栏容器(横屏显示,竖屏由 v-show 隐藏) */
width: 100%; .scene-shell-sidebar {
height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 0; flex-shrink: 0;
min-width: 0;
}
.scene-shell-body-landscape {
flex: 1;
display: flex;
flex-direction: row;
width: 100%;
height: 100%;
min-height: 0;
min-width: 0;
overflow: hidden;
} }
.scene-shell-main-landscape { /* 内容区:始终填满剩余空间 */
.scene-shell-main {
flex: 1 1 0%; flex: 1 1 0%;
min-width: 0; min-width: 0;
min-height: 0; min-height: 0;
...@@ -155,4 +131,12 @@ onShow(() => { ...@@ -155,4 +131,12 @@ onShow(() => {
overflow: hidden; overflow: hidden;
padding: 0 var(--content-box-padding-side, 8px); padding: 0 var(--content-box-padding-side, 8px);
} }
/* 底部 TabBar 容器(竖屏显示,横屏由 v-show 隐藏) */
.scene-shell-tabbar {
display: flex;
flex-direction: column;
flex-shrink: 0;
height: var(--tabbar-height, 60px);
}
</style> </style>
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<script setup lang="uts"> <script setup lang="uts">
import { computed, onMounted, onUnmounted, ref, nextTick, watch } from "vue"; import { computed, onMounted, onUnmounted, ref, nextTick, watch } from "vue";
import { useOrientation, useScreenVars } from "@/services/adapter/hooks"; import { useOrientation, useScreenVars } from "@/services/adapter/hooks/index.uts";
import SettingBox from "./SettingBox.uvue"; import SettingBox from "./SettingBox.uvue";
import SwitchStoreSheet from "@/components/SwitchStoreSheet.uvue"; import SwitchStoreSheet from "@/components/SwitchStoreSheet.uvue";
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
@select="onCarBrandsSelect" @select="onCarBrandsSelect"
@close="onCarBrandClose" @close="onCarBrandClose"
/> />
<SenceSelect <SceneSelect
ref="sceneSelectRef" ref="sceneSelectRef"
:echo-data="{ receptionScenario: formData.receptionSceneName } as UTSJSONObject" :echo-data="{ receptionScenario: formData.receptionSceneName } as UTSJSONObject"
echo-key="receptionScenario" echo-key="receptionScenario"
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
import { ref, watch, nextTick, computed, onMounted, type Ref } from 'vue' import { ref, watch, nextTick, computed, onMounted, type Ref } from 'vue'
import { ComponentPublicInstance } from 'vue' import { ComponentPublicInstance } from 'vue'
import CarBrands from '@/components/CarBrands.uvue' import CarBrands from '@/components/CarBrands.uvue'
import SenceSelect from './filters/SenceSelect.uvue' import SceneSelect from './filters/SceneSelect.uvue'
import CustomerTags from './filters/CustomerTags.uvue' import CustomerTags from './filters/CustomerTags.uvue'
import { saveVisitsInfo, updateVisitsInfo, findVisitsInfo } from '@/api/receiption.uts' import { saveVisitsInfo, updateVisitsInfo, findVisitsInfo } from '@/api/receiption.uts'
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
...@@ -169,7 +169,7 @@ import pageVars from './styles/index.vars.uts' ...@@ -169,7 +169,7 @@ import pageVars from './styles/index.vars.uts'
const phoneRex = /^1[3-9]\d{9}$/ const phoneRex = /^1[3-9]\d{9}$/
// 使用 index.vars.uts + common.scss 约定的 CSS 变量体系做自适应(方向/分辨率由 useScreenVars 内部决定) // 使用 index.vars.uts 约定的 CSS 变量体系做自适应(方向/分辨率由 useScreenVars 内部决定)
const pageStyleVars = useScreenVars(pageVars as UTSJSONObject) const pageStyleVars = useScreenVars(pageVars as UTSJSONObject)
{/* const pageStyleVars = computed((): Any => { {/* const pageStyleVars = computed((): Any => {
const sv = screenVarsHook.screenVars as Ref<UTSJSONObject> const sv = screenVarsHook.screenVars as Ref<UTSJSONObject>
...@@ -178,8 +178,8 @@ const pageStyleVars = useScreenVars(pageVars as UTSJSONObject) ...@@ -178,8 +178,8 @@ const pageStyleVars = useScreenVars(pageVars as UTSJSONObject)
const formAddFormItemCustomStyle = { const formAddFormItemCustomStyle = {
height: 'var(--reception-form-add-item-height)', height: 'var(--reception-form-add-item-height)',
paddingTop: 'var(--reception-form-add-item-padding-top)', paddingTop: 'var(--reception-form-add-item-padding-top, 0px)',
paddingBottom: 'var(--reception-form-add-item-padding-bottom)', paddingBottom: 'var(--reception-form-add-item-padding-bottom, 0px)',
} as UTSJSONObject } as UTSJSONObject
const formAddNavbarTitleStyle = computed((): UTSJSONObject => { const formAddNavbarTitleStyle = computed((): UTSJSONObject => {
......
...@@ -613,7 +613,7 @@ defineExpose({ ...@@ -613,7 +613,7 @@ defineExpose({
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "./styles/common.scss";
.reception-quality-analysis-root, .reception-quality-analysis-root,
.quality-block { .quality-block {
......
...@@ -73,7 +73,7 @@ import CustomEmpty from '@/components/CustomEmpty/index.uvue' ...@@ -73,7 +73,7 @@ import CustomEmpty from '@/components/CustomEmpty/index.uvue'
import { useScreenVars } from '@/services/adapter/hooks/index.uts' import { useScreenVars } from '@/services/adapter/hooks/index.uts'
import pageVars from '../styles/index.vars.uts' import pageVars from '../styles/index.vars.uts'
// 使用 index.vars.uts + common.scss 约定的 CSS 变量体系做自适应(方向/分辨率由 useScreenVars 内部决定) // 使用 index.vars.uts 约定的 CSS 变量体系做自适应(方向/分辨率由 useScreenVars 内部决定)
const pageStyleVars = useScreenVars(pageVars as UTSJSONObject) const pageStyleVars = useScreenVars(pageVars as UTSJSONObject)
// const pageStyleVars = computed((): Any => { // const pageStyleVars = computed((): Any => {
// const sv = screenVarsHook.screenVars as Ref<UTSJSONObject> // const sv = screenVarsHook.screenVars as Ref<UTSJSONObject>
...@@ -805,7 +805,7 @@ onLoad((options: UTSJSONObject | null) => { ...@@ -805,7 +805,7 @@ onLoad((options: UTSJSONObject | null) => {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../styles/common.scss';
.form-detail-root { .form-detail-root {
display: flex; display: flex;
......
...@@ -142,8 +142,8 @@ const inputFontSize = computed((): number => { ...@@ -142,8 +142,8 @@ const inputFontSize = computed((): number => {
const formItemCustomStyle = { const formItemCustomStyle = {
height: 'var(--reception-form-add-item-height)', height: 'var(--reception-form-add-item-height)',
paddingTop: 'var(--reception-form-add-item-padding-top)', paddingTop: 'var(--reception-form-add-item-padding-top, 0px)',
paddingBottom: 'var(--reception-form-add-item-padding-bottom)', paddingBottom: 'var(--reception-form-add-item-padding-bottom, 0px)',
} as UTSJSONObject } as UTSJSONObject
/** 顶部安全区占位(px):与 FormAdd/FormDetail 一致 */ /** 顶部安全区占位(px):与 FormAdd/FormDetail 一致 */
......
...@@ -204,12 +204,12 @@ function onEntryCardMaskDelete(item: UTSJSONObject): void { ...@@ -204,12 +204,12 @@ function onEntryCardMaskDelete(item: UTSJSONObject): void {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "../styles/common.scss";
.customer-entry-list { .customer-entry-list {
flex: 1; flex: 1;
flex-direction: var(--reception-list-container-direction, column); flex-direction: var(--reception-list-container-direction, column);
flex-wrap: var(--reception-list-container-wrap, nowrap); flex-wrap: var(--reception-list-container-wrap, nowrap);
justify-content: var(--reception-list-container-justify, flex-start); justify-content: flex-start;
width: 100%; width: 100%;
min-height: 0; min-height: 0;
/* ✅ 骨架屏网格布局:使用负 margin + padding 实现间距 */ /* ✅ 骨架屏网格布局:使用负 margin + padding 实现间距 */
......
...@@ -259,12 +259,12 @@ function onCardClick(item: UTSJSONObject): void { ...@@ -259,12 +259,12 @@ function onCardClick(item: UTSJSONObject): void {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "../styles/common.scss";
.reception-record-list { .reception-record-list {
flex: 1; flex: 1;
flex-direction: var(--reception-list-container-direction, column); flex-direction: var(--reception-list-container-direction, column);
flex-wrap: var(--reception-list-container-wrap, nowrap); flex-wrap: var(--reception-list-container-wrap, nowrap);
justify-content: var(--reception-list-container-justify, flex-start); justify-content: flex-start;
width: 100%; width: 100%;
min-height: 0; min-height: 0;
} }
......
/**
* 接待详情(录音对话)模块工具函数(模块级)
* 包含录音播放、对话行处理、质检数据处理等专用业务逻辑
*/
/**
* 安全转换列表为空数组
* UTS 对三元表达式的联合类型推导较保守,改用显式分支保证返回类型稳定
*/
export function toSafeList(list: UTSJSONObject[] | null | undefined): UTSJSONObject[] {
if (list != null) {
return list as UTSJSONObject[]
}
return [] as UTSJSONObject[]
}
/**
* 追加字符串数组元素到输出数组
*/
function appendStringArray(rawArr: any[], out: string[]): void {
let i = 0
while (i < rawArr.length) {
const item = rawArr[i]
if (item != null) {
const s = `${item}`.trim()
if (s != "") {
out.push(s)
}
}
i++
}
}
/**
* 解析 JSON 数组字符串或 string[]
* 与 DetailData / receptionDetail 一致
*/
export function parseStringArray(rawValue: any | null): string[] {
const out: string[] = []
if (rawValue == null) {
return out
}
if (rawValue instanceof Array) {
appendStringArray(rawValue as any[], out)
return out
}
const text = `${rawValue}`.trim()
if (text == "" || text == "[]") {
return out
}
if (text.substring(0, 1) == "[" && text.substring(text.length - 1, text.length) == "]") {
try {
const parsed = JSON.parse(text) as any
if (parsed != null && parsed instanceof Array) {
const arr = parsed as any[]
let i = 0
while (i < arr.length) {
const item = arr[i]
if (item != null) {
if (typeof item == "string") {
const s = item.trim()
if (s != "") {
out.push(s)
}
} else {
const obj = item as UTSJSONObject
const line =
(obj["text"] as string | null) ??
(obj["content"] as string | null) ??
(obj["script"] as string | null) ??
(obj["title"] as string | null)
if (line != null && line.trim() != "") {
out.push(line.trim())
}
}
}
i++
}
return out
}
} catch (e) {
if (`${e}` == "") {
// 显式消费异常,规避未使用告警
}
}
}
out.push(text)
return out
}
/**
* 解析话术推荐行
*/
export function parseScriptLines(row: UTSJSONObject): string[] {
const fromRecord = parseStringArray(row["scriptRecord"])
if (fromRecord.length > 0) {
return fromRecord
}
return parseStringArray(row["scriptRec"])
}
/**
* 质检行唯一标识
*/
export function qualityRowKey(row: UTSJSONObject, index: number): string {
const idRaw = row["id"]
if (idRaw != null) {
return `q-${idRaw}`
}
const tagId = row["tagId"]
if (tagId != null) {
return `q-t-${tagId}-${index}`
}
return `q-idx-${index}`
}
/**
* 获取质检维度组名
*/
export function qualityGroupName(row: UTSJSONObject): string {
const v = row["tagGroupName"] as string | null
return v != null ? v : ""
}
/**
* 获取质检分数标签
*/
export function qualityScoreLabel(row: UTSJSONObject): string {
const s = row["score"]
const t = row["sumScore"]
const left = s != null ? `${s}` : ""
const right = t != null ? `${t}` : ""
return `${left}/${right}`
}
/**
* 从对象中安全获取数字
*/
export function getNum(row: UTSJSONObject, key: string): number | null {
const v = row[key]
if (v == null) {
return null
}
if (typeof v == "number") {
if (isNaN(v)) {
return null
}
return v
}
const n = parseFloat(`${v}`)
if (isNaN(n)) {
return null
}
return n
}
/**
* 句子开始时间(秒),优先 offset 毫秒
*/
export function rowStartSec(row: UTSJSONObject): number {
const ms = getNum(row, "offset")
if (ms != null && ms >= 0) {
return ms / 1000.0
}
const mo = getNum(row, "mergedOffset")
if (mo != null && mo >= 0) {
return mo
}
return 0
}
/**
* 句子持续时间(秒)
*/
export function rowDurSec(row: UTSJSONObject): number {
const ms = getNum(row, "duration")
if (ms != null && ms >= 0) {
return ms / 1000.0
}
return 0
}
/**
* 对话行唯一标识
*/
export function lineKey(row: UTSJSONObject, idx: number): string {
const id = getNum(row, "id")
if (id != null) {
return `${id}`
}
return `i${idx}`
}
/**
* 获取对话内容
*/
export function lineContent(row: UTSJSONObject): string {
const c = row["content"] as string | null
return c != null ? c : ""
}
/**
* 格式化对话行时钟:0:01 形式,mergedOffset 按整秒展示
*/
export function formatLineClock(row: UTSJSONObject): string {
const mo = getNum(row, "mergedOffset")
const sec = mo != null && mo >= 0 ? Math.floor(mo) : Math.floor(rowStartSec(row))
const m = Math.floor(sec / 60)
const r = sec % 60
const rr = r < 10 ? `0${r}` : `${r}`
if (m > 0) {
return `${m}:${rr}`
}
return `0:${rr}`
}
/**
* 格式化分秒:MM:SS
*/
export function formatMmSs(sec: number): string {
const s = sec >= 0 ? Math.floor(sec) : 0
const m = Math.floor(s / 60)
const r = s % 60
const mm = m < 10 ? `0${m}` : `${m}`
const rr = r < 10 ? `0${r}` : `${r}`
return `${mm}:${rr}`
}
/**
* 判断是否为销售方
*/
export function isSaleSide(row: UTSJSONObject): boolean {
const r = row["role"] as string | null
if (r != null) {
const lower = r.toLowerCase()
if (lower == "sale" || lower == "0" || r == "销售") {
return true
}
if (lower == "client" || lower == "customer" || lower == "1" || r == "客户") {
return false
}
}
return true
}
/**
* 获取头像图片路径
*/
export function avatarSrc(row: UTSJSONObject): string {
return isSaleSide(row) ? "/static/images/reception/icon-user-sale.png" : "/static/images/reception/icon-user-client.png"
}
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import { get } from '@/utils/common.uts' import { get } from '@/utils/common.uts'
import { isBlankDisplayText, formatDateTimeLike } from '@/utils/format-utils.uts' import { isBlankDisplayText, formatDateTimeLike } from '@/utils/format-utils.uts'
import { getStr, getTs } from '../types/reception-center-helpers.uts' import { getStr, getTs } from '../types/reception-center-helpers.uts'
import { parseIntValue, parseNumberValue } from '../receptionDetail.helper.uts' import { parseIntValue, parseNumberValue } from '../receptionDetail.helpers.uts'
/** /**
* 解析日期字段为时间戳 * 解析日期字段为时间戳
......
/**
* 接待详情页辅助函数合集
* 合并自:receptionDetail.helper.uts / receptionDetail.qualityTransform.uts / lists/reception-detail-helpers.uts
*/
import { get } from "@/utils/common.uts"; import { get } from "@/utils/common.uts";
// ============================================================
// Part 1: 基础工具函数(原 receptionDetail.helper.uts)
// ============================================================
export function toTrimmedString(raw: any | null): string { export function toTrimmedString(raw: any | null): string {
if (raw == null) { if (raw == null) {
return ""; return "";
...@@ -115,7 +123,6 @@ export function getOrderFinishFlagOutcomeForItem(item: UTSJSONObject | null | un ...@@ -115,7 +123,6 @@ export function getOrderFinishFlagOutcomeForItem(item: UTSJSONObject | null | un
return -1; return -1;
} }
export function formatShareDate(ts: number | null): string { export function formatShareDate(ts: number | null): string {
if (ts == null || ts <= 0) { if (ts == null || ts <= 0) {
return "--"; return "--";
...@@ -222,3 +229,310 @@ export function pickQualityRowsFromResponse(res: any): UTSJSONObject[] { ...@@ -222,3 +229,310 @@ export function pickQualityRowsFromResponse(res: any): UTSJSONObject[] {
} }
return []; return [];
} }
// ============================================================
// Part 2: 对话与质检工具函数(原 lists/reception-detail-helpers.uts)
// ============================================================
export function toSafeList(list: UTSJSONObject[] | null | undefined): UTSJSONObject[] {
if (list != null) {
return list as UTSJSONObject[]
}
return [] as UTSJSONObject[]
}
function appendStringArray(rawArr: any[], out: string[]): void {
let i = 0
while (i < rawArr.length) {
const item = rawArr[i]
if (item != null) {
const s = `${item}`.trim()
if (s != "") {
out.push(s)
}
}
i++
}
}
export function parseStringArray(rawValue: any | null): string[] {
const out: string[] = []
if (rawValue == null) {
return out
}
if (rawValue instanceof Array) {
appendStringArray(rawValue as any[], out)
return out
}
const text = `${rawValue}`.trim()
if (text == "" || text == "[]") {
return out
}
if (text.substring(0, 1) == "[" && text.substring(text.length - 1, text.length) == "]") {
try {
const parsed = JSON.parse(text) as any
if (parsed != null && parsed instanceof Array) {
const arr = parsed as any[]
let i = 0
while (i < arr.length) {
const item = arr[i]
if (item != null) {
if (typeof item == "string") {
const s = item.trim()
if (s != "") {
out.push(s)
}
} else {
const obj = item as UTSJSONObject
const line =
(obj["text"] as string | null) ??
(obj["content"] as string | null) ??
(obj["script"] as string | null) ??
(obj["title"] as string | null)
if (line != null && line.trim() != "") {
out.push(line.trim())
}
}
}
i++
}
return out
}
} catch (e) {
if (`${e}` == "") {
// 显式消费异常,规避未使用告警
}
}
}
out.push(text)
return out
}
export function parseScriptLines(row: UTSJSONObject): string[] {
const fromRecord = parseStringArray(row["scriptRecord"])
if (fromRecord.length > 0) {
return fromRecord
}
return parseStringArray(row["scriptRec"])
}
export function qualityRowKey(row: UTSJSONObject, index: number): string {
const idRaw = row["id"]
if (idRaw != null) {
return `q-${idRaw}`
}
const tagId = row["tagId"]
if (tagId != null) {
return `q-t-${tagId}-${index}`
}
return `q-idx-${index}`
}
export function qualityGroupName(row: UTSJSONObject): string {
const v = row["tagGroupName"] as string | null
return v != null ? v : ""
}
export function qualityScoreLabel(row: UTSJSONObject): string {
const s = row["score"]
const t = row["sumScore"]
const left = s != null ? `${s}` : ""
const right = t != null ? `${t}` : ""
return `${left}/${right}`
}
export function getNum(row: UTSJSONObject, key: string): number | null {
const v = row[key]
if (v == null) {
return null
}
if (typeof v == "number") {
if (isNaN(v)) {
return null
}
return v
}
const n = parseFloat(`${v}`)
if (isNaN(n)) {
return null
}
return n
}
export function rowStartSec(row: UTSJSONObject): number {
const ms = getNum(row, "offset")
if (ms != null && ms >= 0) {
return ms / 1000.0
}
const mo = getNum(row, "mergedOffset")
if (mo != null && mo >= 0) {
return mo
}
return 0
}
export function rowDurSec(row: UTSJSONObject): number {
const ms = getNum(row, "duration")
if (ms != null && ms >= 0) {
return ms / 1000.0
}
return 0
}
export function lineKey(row: UTSJSONObject, idx: number): string {
const id = getNum(row, "id")
if (id != null) {
return `${id}`
}
return `i${idx}`
}
export function lineContent(row: UTSJSONObject): string {
const c = row["content"] as string | null
return c != null ? c : ""
}
export function formatLineClock(row: UTSJSONObject): string {
const mo = getNum(row, "mergedOffset")
const sec = mo != null && mo >= 0 ? Math.floor(mo) : Math.floor(rowStartSec(row))
const m = Math.floor(sec / 60)
const r = sec % 60
const rr = r < 10 ? `0${r}` : `${r}`
if (m > 0) {
return `${m}:${rr}`
}
return `0:${rr}`
}
export function formatMmSs(sec: number): string {
const s = sec >= 0 ? Math.floor(sec) : 0
const m = Math.floor(s / 60)
const r = s % 60
const mm = m < 10 ? `0${m}` : `${m}`
const rr = r < 10 ? `0${r}` : `${r}`
return `${mm}:${rr}`
}
export function isSaleSide(row: UTSJSONObject): boolean {
const r = row["role"] as string | null
if (r != null) {
const lower = r.toLowerCase()
if (lower == "sale" || lower == "0" || r == "销售") {
return true
}
if (lower == "client" || lower == "customer" || lower == "1" || r == "客户") {
return false
}
}
return true
}
export function avatarSrc(row: UTSJSONObject): string {
return isSaleSide(row) ? "/static/images/reception/icon-user-sale.png" : "/static/images/reception/icon-user-client.png"
}
// ============================================================
// Part 3: 质检数据转换(原 receptionDetail.qualityTransform.uts)
// ============================================================
function formatPlainText(s: string): string {
return s.replace(/\r\n/g, "\n").replace(/\n/g, " ").trim();
}
function firstScriptRecLine(raw: any | null): string {
const lines = parseStringArray(raw);
if (lines.length > 0) {
return formatPlainText(lines[0]);
}
return "";
}
export function transformSingleQualityRow(row: UTSJSONObject): UTSJSONObject {
const out = {} as UTSJSONObject;
for (const k in row) {
out[k] = row[k];
}
const scoreRaw = out["score"];
const sumRaw = out["sumScore"];
if (scoreRaw != null && sumRaw != null) {
out["formatScore"] = `${scoreRaw}/${sumRaw}`;
} else {
const fs = out["formatScore"] as string | null;
if (fs == null || fs.trim() == "") {
out["formatScore"] = "-";
}
}
const hitTextList = parseStringArray(out["hitText"]);
if (hitTextList.length > 0) {
out["matchedClass"] = "hit";
out["matchedText"] = "意图匹配";
} else {
out["matchedClass"] = "";
out["matchedText"] = "意图不匹配";
}
const scriptLine = firstScriptRecLine(out["scriptRec"]);
let list: UTSJSONObject[] = [];
const listRaw = out["conversationDetailDTOList"];
if (listRaw != null && listRaw instanceof Array) {
list = listRaw as UTSJSONObject[];
}
const itemOffset = getNum(out, "offset");
let i = 0;
while (i < list.length) {
const line = list[i];
const mo = getNum(line, "mergedOffset");
if (mo != null && mo >= 0) {
const sec = Math.floor(mo);
line["time"] = formatMmSs(sec);
line["text_id"] = `text_${Math.ceil(mo)}`;
}
i++;
}
if (scriptLine != "") {
let attached = false;
let j = 0;
while (j < list.length) {
const line = list[j];
const mo = getNum(line, "mergedOffset");
if (itemOffset != null && mo != null) {
const offSec = itemOffset > 1000 ? itemOffset / 1000.0 : itemOffset;
if (Math.abs(mo - offSec) < 0.001) {
line["scriptRec"] = scriptLine;
attached = true;
break;
}
}
j++;
}
if (!attached && list.length > 0) {
const last = list[list.length - 1];
last["scriptRec"] = scriptLine;
}
out["scriptRec"] = scriptLine;
}
if (list.length == 0) {
const stub = {} as UTSJSONObject;
stub["scriptRec"] = scriptLine != "" ? scriptLine : "暂无话术推荐";
list = [stub];
}
out["conversationDetailDTOList"] = list;
return out;
}
export function transformQualityCheckRows(rawRows: UTSJSONObject[]): UTSJSONObject[] {
const out: UTSJSONObject[] = [];
let i = 0;
while (i < rawRows.length) {
out.push(transformSingleQualityRow(rawRows[i]));
i++;
}
return out;
}
/**
* 将网关 findCheckResultListByReceptionId / findCheckResultByBatchId 返回的质检行
* 加工为 ReceptionQualityAnalysis / DetailData 所需字段(与功能清单第六节对齐)。
*/
import { formatMmSs, getNum, parseStringArray } from "./lists/reception-detail-helpers.uts";
function formatPlainText(s: string): string {
return s.replace(/\r\n/g, "\n").replace(/\n/g, " ").trim();
}
function firstScriptRecLine(raw: any | null): string {
const lines = parseStringArray(raw);
if (lines.length > 0) {
return formatPlainText(lines[0]);
}
return "";
}
/**
* 单条质检维度加工:formatScore、命中意图、话术首行、对话行 time/text_id、话术挂载
*/
export function transformSingleQualityRow(row: UTSJSONObject): UTSJSONObject {
const out = {} as UTSJSONObject;
for (const k in row) {
out[k] = row[k];
}
const scoreRaw = out["score"];
const sumRaw = out["sumScore"];
if (scoreRaw != null && sumRaw != null) {
out["formatScore"] = `${scoreRaw}/${sumRaw}`;
} else {
const fs = out["formatScore"] as string | null;
if (fs == null || fs.trim() == "") {
out["formatScore"] = "-";
}
}
const hitTextList = parseStringArray(out["hitText"]);
if (hitTextList.length > 0) {
out["matchedClass"] = "hit";
out["matchedText"] = "意图匹配";
} else {
out["matchedClass"] = "";
out["matchedText"] = "意图不匹配";
}
const scriptLine = firstScriptRecLine(out["scriptRec"]);
let list: UTSJSONObject[] = [];
const listRaw = out["conversationDetailDTOList"];
if (listRaw != null && listRaw instanceof Array) {
list = listRaw as UTSJSONObject[];
}
const itemOffset = getNum(out, "offset");
let i = 0;
while (i < list.length) {
const line = list[i];
const mo = getNum(line, "mergedOffset");
if (mo != null && mo >= 0) {
const sec = Math.floor(mo);
line["time"] = formatMmSs(sec);
line["text_id"] = `text_${Math.ceil(mo)}`;
}
i++;
}
if (scriptLine != "") {
let attached = false;
let j = 0;
while (j < list.length) {
const line = list[j];
const mo = getNum(line, "mergedOffset");
if (itemOffset != null && mo != null) {
const offSec = itemOffset > 1000 ? itemOffset / 1000.0 : itemOffset;
if (Math.abs(mo - offSec) < 0.001) {
line["scriptRec"] = scriptLine;
attached = true;
break;
}
}
j++;
}
if (!attached && list.length > 0) {
const last = list[list.length - 1];
last["scriptRec"] = scriptLine;
}
out["scriptRec"] = scriptLine;
}
if (list.length == 0) {
const stub = {} as UTSJSONObject;
stub["scriptRec"] = scriptLine != "" ? scriptLine : "暂无话术推荐";
list = [stub];
}
out["conversationDetailDTOList"] = list;
return out;
}
export function transformQualityCheckRows(rawRows: UTSJSONObject[]): UTSJSONObject[] {
const out: UTSJSONObject[] = [];
let i = 0;
while (i < rawRows.length) {
out.push(transformSingleQualityRow(rawRows[i]));
i++;
}
return out;
}
<template> <template>
<layout-root :page-vars="pageVars"> <layout-root :page-vars="pageVars">
<view class="detail-container"> <view class="detail-container">
<!-- 自定义导航页:按窗口安全区预留顶部,避免状态栏/刘海与首屏重叠 -->
<view class="reception-safe-top-spacer" :style="receptionSafeTopSpacerStyle"></view>
<!-- 与 FormDetail 一致:固定导航 + 占位,避免首屏内容被导航栏遮挡 --> <!-- 与 FormDetail 一致:固定导航 + 占位,避免首屏内容被导航栏遮挡 -->
<un-navbar title="接待详情" @leftClick="onBack" /> <un-navbar title="接待详情" @leftClick="onBack" />
<!-- 主内容区:竖屏单列滚动;横屏左右分栏(右侧 AI 模块已移除,保留分栏结构) --> <!-- 主内容区:竖屏单列滚动;横屏左右分栏(右侧 AI 模块已移除,保留分栏结构) -->
...@@ -173,12 +171,13 @@ ...@@ -173,12 +171,13 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { computed, onMounted, onUnmounted, onResize, ref, watch } from "vue"; import { computed, onUnmounted, ref, watch } from "vue";
import { findCheckResultByBatchId, findCheckResultListByReceptionId, getShortUrl } from "@/api/receiption.uts"; import { findCheckResultByBatchId, findCheckResultListByReceptionId, getShortUrl } from "@/api/receiption.uts";
import { useOrientation } from "@/services/adapter/hooks/index.uts";
import CustomEmpty from "@/components/CustomEmpty/index.uvue"; import CustomEmpty from "@/components/CustomEmpty/index.uvue";
import DetailData from "./DetailData.uvue"; import DetailData from "./DetailData.uvue";
import ReceptionQualityAnalysis from "./ReceptionQualityAnalysis.uvue"; import ReceptionQualityAnalysis from "./ReceptionQualityAnalysis.uvue";
import { updateOrientation } from "@/services/adapter/hooks/index.uts";
import pageVars from "./styles/index.vars.uts"; import pageVars from "./styles/index.vars.uts";
import { deepClone } from "@/utils/common.uts"; import { deepClone } from "@/utils/common.uts";
import { import {
...@@ -191,11 +190,15 @@ import { ...@@ -191,11 +190,15 @@ import {
parseNumberValue, parseNumberValue,
parseShortUrlFromResponse, parseShortUrlFromResponse,
pickQualityRowsFromResponse, pickQualityRowsFromResponse,
toTrimmedString toTrimmedString,
} from "./receptionDetail.helper.uts"; transformQualityCheckRows,
avatarSrc,
formatLineClock,
getNum,
lineContent,
lineKey
} from "./receptionDetail.helpers.uts";
import { USE_MOCK_QUALITY_ROWS, buildMockQualityRows } from "./receptionDetail.qualityMock.uts"; import { USE_MOCK_QUALITY_ROWS, buildMockQualityRows } from "./receptionDetail.qualityMock.uts";
import { transformQualityCheckRows } from "./receptionDetail.qualityTransform.uts";
import { avatarSrc, formatLineClock, getNum, lineContent, lineKey } from "./lists/reception-detail-helpers.uts";
type QualityAudioState = { type QualityAudioState = {
currentTime?: number currentTime?: number
paused?: boolean paused?: boolean
...@@ -478,7 +481,9 @@ function forwardQualityAnalysisSetProgress(seconds: number): void { ...@@ -478,7 +481,9 @@ function forwardQualityAnalysisSetProgress(seconds: number): void {
} }
} }
const windowWidth = ref(375); // 窗口宽度:从适配系统全局状态获取,无需本地维护
const _orientation = useOrientation();
const windowWidth = computed((): number => _orientation.windowWidth.value);
const localAudioCtx = uni.createInnerAudioContext(); const localAudioCtx = uni.createInnerAudioContext();
const localAudioPlaying = ref(false); const localAudioPlaying = ref(false);
...@@ -994,57 +999,12 @@ watch( ...@@ -994,57 +999,12 @@ watch(
} }
); );
/** 顶部安全区占位(px):与系统状态栏/刘海对齐,随窗口信息刷新 */
const receptionPageInsetTopPx = ref(0);
const receptionSafeTopSpacerStyle = computed((): UTSJSONObject => {
return {
height: `${receptionPageInsetTopPx.value}px`,
width: "100%",
} as UTSJSONObject;
});
function syncReceptionSafeTopSpacer(): void {
const info = uni.getWindowInfo();
let topInset = 0;
const insets = info.safeAreaInsets;
if (insets != null) {
const t = insets.top;
if (t > 0) {
topInset = Math.round(t);
}
}
if (topInset <= 0) {
const safe = info.safeArea;
if (safe != null) {
const st = safe.top;
if (st > 0) {
topInset = Math.round(st);
}
}
}
if (topInset <= 0) {
const sb = info.statusBarHeight;
if (sb > 0) {
topInset = Math.round(sb);
}
}
if (receptionPageInsetTopPx.value != topInset) {
receptionPageInsetTopPx.value = topInset;
}
}
/** /**
* 页面打开:与 FormAdd/FormDetail 同样通过 query record 传递 JSON 字符串 * 页面打开:与 FormAdd/FormDetail 同样通过 query record 传递 JSON 字符串
* url: /pages/receptionCenter/receptionDetail?record=${encodeURIComponent(JSON.stringify(item))} * url: /pages/receptionCenter/receptionDetail?record=${encodeURIComponent(JSON.stringify(item))}
*/ */
onLoad((options: UTSJSONObject | null) => { onLoad((options: UTSJSONObject | null) => {
pageMode.value = true; pageMode.value = true;
syncReceptionSafeTopSpacer();
const ec = getPageOpenerEventChannel(); const ec = getPageOpenerEventChannel();
if (ec != null) { if (ec != null) {
const onFn = (ec as UTSJSONObject)["on"] as any | null; const onFn = (ec as UTSJSONObject)["on"] as any | null;
...@@ -1076,39 +1036,13 @@ onHide((): void => { ...@@ -1076,39 +1036,13 @@ onHide((): void => {
localAudioCtx.stop(); localAudioCtx.stop();
}); });
const RECEPTION_DETAIL_LAYOUT_POLL_MS = 400;
let receptionDetailLayoutPollId: number | null = null;
onMounted((): void => {
updateOrientation();
syncReceptionSafeTopSpacer();
receptionDetailLayoutPollId = setInterval(syncReceptionSafeTopSpacer, RECEPTION_DETAIL_LAYOUT_POLL_MS);
});
onResize((_res: any): void => {
updateOrientation();
const info = uni.getWindowInfo();
windowWidth.value = info.windowWidth;
syncReceptionSafeTopSpacer();
});
onUnmounted((): void => { onUnmounted((): void => {
const ctx = localAudioCtx; const ctx = localAudioCtx;
ctx.stop(); ctx.stop();
ctx.destroy(); ctx.destroy();
localAudioPlaying.value = false; localAudioPlaying.value = false;
// 清理安全区轮询
const tid = receptionDetailLayoutPollId;
if (tid != null) {
clearInterval(tid);
receptionDetailLayoutPollId = null;
}
}); });
const pageInfo = uni.getWindowInfo();
windowWidth.value = pageInfo.windowWidth;
defineExpose({ defineExpose({
onTimeUpdate: forwardQualityAnalysisOnTimeUpdate, onTimeUpdate: forwardQualityAnalysisOnTimeUpdate,
setProgress: forwardQualityAnalysisSetProgress setProgress: forwardQualityAnalysisSetProgress
...@@ -1117,7 +1051,7 @@ defineExpose({ ...@@ -1117,7 +1051,7 @@ defineExpose({
<style scoped lang="scss"> <style scoped lang="scss">
/* 遵循 uni-app x 规范:px 单位、无 gap、文字样式在 text 上、flex 布局 */ /* 遵循 uni-app x 规范:px 单位、无 gap、文字样式在 text 上、flex 布局 */
@import "./styles/common.scss";
.detail-container, .detail-container,
.recv-detail-content-container, .recv-detail-content-container,
...@@ -1145,11 +1079,6 @@ defineExpose({ ...@@ -1145,11 +1079,6 @@ defineExpose({
background-color: #F8FAFC; background-color: #F8FAFC;
} }
.reception-safe-top-spacer {
width: 100%;
flex-shrink: 0;
}
/* un-navbar 固定定位时不占文档流高度,预留标题栏区域(与 FormDetail 一致) */ /* un-navbar 固定定位时不占文档流高度,预留标题栏区域(与 FormDetail 一致) */
.reception-navbar-spacer { .reception-navbar-spacer {
height: 44px; height: 44px;
...@@ -1182,7 +1111,7 @@ defineExpose({ ...@@ -1182,7 +1111,7 @@ defineExpose({
.recv-detail-landscape-right { .recv-detail-landscape-right {
display: var(--reception-detail-right-display, none); display: var(--reception-detail-right-display, none);
flex: var(--reception-detail-right-flex, 2); flex: 2;
min-height: 0; min-height: 0;
min-width: 0; min-width: 0;
overflow: hidden; overflow: hidden;
...@@ -1196,8 +1125,8 @@ defineExpose({ ...@@ -1196,8 +1125,8 @@ defineExpose({
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: var(--reception-detail-right-margin, 12px); margin: 12px;
padding: var(--reception-detail-right-padding, 12px); padding: 12px;
box-sizing: border-box; box-sizing: border-box;
background-color: #ffffff; background-color: #ffffff;
border-radius: 12px; border-radius: 12px;
......
/* common.scss 已清空 - 所有样式已迁移到各组件 scoped 样式或 CSS 变量中 */
// 约定式命名:必须叫 index.vars.uts // 约定式命名:必须叫 index.vars.uts
// 注意:以下值已在 CSS 中直接写死(无需变量):
// - funnel-gap: 14px
// - detail-right-margin/padding: 12px
// - detail-left-flex: 1, detail-right-flex: 2
// - list-container-justify: flex-start
// - pre-entry-btn-text-line-height: 1.35
// - form-add-item-padding-top/bottom 默认 0px(仅 768x1174 覆盖)
// - list-content-wrapper-padding portrait 默认 0
export default { export default {
common: { common: {
// receptionCenter: 客户列表子 Tab(ReceptionCustomerListTab)默认字号 // receptionCenter: 客户列表子 Tab(ReceptionCustomerListTab)默认字号
...@@ -14,7 +22,6 @@ export default { ...@@ -14,7 +22,6 @@ export default {
'--reception-list-filters-tabs-row-height': '40px', '--reception-list-filters-tabs-row-height': '40px',
'--reception-list-filters-pre-entry-btn-height': '40px', '--reception-list-filters-pre-entry-btn-height': '40px',
'--reception-list-filters-pre-entry-btn-text-font-size': '13px', '--reception-list-filters-pre-entry-btn-text-font-size': '13px',
'--reception-list-filters-pre-entry-btn-text-line-height': '1.35',
'--reception-list-filters-pre-entry-icon-size': '11px', '--reception-list-filters-pre-entry-icon-size': '11px',
// 复盘筛选下拉默认尺寸 // 复盘筛选下拉默认尺寸
'--reception-list-filters-review-tag-text-font-size': '13px', '--reception-list-filters-review-tag-text-font-size': '13px',
...@@ -37,24 +44,22 @@ export default { ...@@ -37,24 +44,22 @@ export default {
'--reception-customer-list-info-value-font-size': '13px', '--reception-customer-list-info-value-font-size': '13px',
'--reception-entry-mask-action-font-size': '13px', '--reception-entry-mask-action-font-size': '13px',
// 列表容器布局 // 列表容器布局(justify-content: flex-start 已写入 CSS)
'--reception-list-container-direction': 'column', '--reception-list-container-direction': 'column',
'--reception-list-container-wrap': 'nowrap', '--reception-list-container-wrap': 'nowrap',
'--reception-list-container-justify': 'flex-start',
// 列表卡片最小宽度 // 列表卡片最小宽度
'--reception-list-card-min-width': '100%', '--reception-list-card-min-width': '100%',
// 列表卡片右边距 // 列表卡片右边距
'--reception-list-card-margin-right': '0px', '--reception-list-card-margin-right': '0px',
// FormAdd(客户档案新增/编辑)默认样式 // FormAdd(客户档案新增/编辑)默认样式
// padding-top/bottom 默认 0px 已写入 CSS,仅在大屏分辨率覆盖
'--reception-form-add-label-font-size': '14px', '--reception-form-add-label-font-size': '14px',
'--reception-form-add-input-font-size': '14px', '--reception-form-add-input-font-size': '14px',
'--reception-form-add-placeholder-font-size': '14px', '--reception-form-add-placeholder-font-size': '14px',
'--reception-form-add-cell-value-font-size': '14px', '--reception-form-add-cell-value-font-size': '14px',
'--reception-form-add-btn-text-font-size': '16px', '--reception-form-add-btn-text-font-size': '16px',
'--reception-form-add-item-height': '56px', '--reception-form-add-item-height': '56px',
'--reception-form-add-item-padding-top': '0px',
'--reception-form-add-item-padding-bottom': '0px',
'--reception-form-add-navbar-title-font-size': '17px', '--reception-form-add-navbar-title-font-size': '17px',
// FormDetail(客户档案详情)默认样式 // FormDetail(客户档案详情)默认样式
...@@ -68,13 +73,10 @@ export default { ...@@ -68,13 +73,10 @@ export default {
'--reception-form-detail-goods-meta-line-height': '16px', '--reception-form-detail-goods-meta-line-height': '16px',
// receptionDetail 自适应布局变量(portrait/landscape 覆盖) // receptionDetail 自适应布局变量(portrait/landscape 覆盖)
// left-flex:1, right-flex:2, right-margin/padding:12px 已写入 CSS
'--reception-detail-layout-direction': 'column', '--reception-detail-layout-direction': 'column',
'--reception-detail-right-display': 'none', '--reception-detail-right-display': 'none',
'--reception-detail-portrait-right-display': 'flex', '--reception-detail-portrait-right-display': 'flex',
'--reception-detail-left-flex': '1',
'--reception-detail-right-flex': '2',
'--reception-detail-right-margin': '12px',
'--reception-detail-right-padding': '12px',
// 竖屏接待详情:对话列表(ListDetailRecord)默认可视高度 // 竖屏接待详情:对话列表(ListDetailRecord)默认可视高度
'--reception-detail-ldr-scroll-height': '560px', '--reception-detail-ldr-scroll-height': '560px',
// 对话列表文本样式 // 对话列表文本样式
...@@ -94,13 +96,12 @@ export default { ...@@ -94,13 +96,12 @@ export default {
'--reception-detail-portrait-detaildata-max-height': '360px', '--reception-detail-portrait-detaildata-max-height': '360px',
// DetailData(话术标签 + 质检表) // DetailData(话术标签 + 质检表)
// tag-flex-basis:31%, tag-margin-right:3.5% 已写入 CSS(竖屏默认三列)
'--reception-detail-data-container-padding': '14px', '--reception-detail-data-container-padding': '14px',
'--reception-detail-data-border-radius': '16.1px', '--reception-detail-data-border-radius': '16.1px',
'--reception-detail-data-title-font-size': '16px', '--reception-detail-data-title-font-size': '16px',
'--reception-detail-data-title-line-height': '20px', '--reception-detail-data-title-line-height': '20px',
'--reception-detail-data-tag-font-size': '16px', '--reception-detail-data-tag-font-size': '16px',
'--reception-detail-data-tag-flex-basis': '31%',
'--reception-detail-data-tag-margin-right': '3.5%',
'--reception-detail-data-table-header-font-size': '13px', '--reception-detail-data-table-header-font-size': '13px',
'--reception-detail-data-table-header-line-height': '18px', '--reception-detail-data-table-header-line-height': '18px',
'--reception-detail-data-table-cell-font-size': '13px', '--reception-detail-data-table-cell-font-size': '13px',
...@@ -110,7 +111,6 @@ export default { ...@@ -110,7 +111,6 @@ export default {
'--reception-detail-data-table-col1-width': '28%', '--reception-detail-data-table-col1-width': '28%',
'--reception-detail-data-table-col2-width': '22%', '--reception-detail-data-table-col2-width': '22%',
'--reception-detail-data-table-col3-width': '50%', '--reception-detail-data-table-col3-width': '50%',
'--card-container--funnel-gap': '14px',
}, },
portrait: { portrait: {
// 竖屏显示 // 竖屏显示
...@@ -120,24 +120,11 @@ export default { ...@@ -120,24 +120,11 @@ export default {
// 竖屏:列表双列布局(48% width + 2% margin-right × 2 = 100%) // 竖屏:列表双列布局(48% width + 2% margin-right × 2 = 100%)
'--reception-list-container-direction': 'row', '--reception-list-container-direction': 'row',
'--reception-list-container-wrap': 'wrap', '--reception-list-container-wrap': 'wrap',
'--reception-list-container-justify': 'flex-start',
'--reception-list-card-min-width': '48%', '--reception-list-card-min-width': '48%',
'--reception-list-card-margin-right': '2%', '--reception-list-card-margin-right': '2%',
// receptionDetail:竖屏单列
'--reception-detail-layout-direction': 'column',
'--reception-detail-right-display': 'none',
'--reception-detail-portrait-right-display': 'flex',
'--reception-detail-left-flex': '1',
'--reception-detail-right-flex': '2',
// 竖屏全宽:话术标签三列
'--reception-detail-data-tag-flex-basis': '31%',
'--reception-detail-data-tag-margin-right': '3.5%',
// 竖屏:对话列表默认更高 // 竖屏:对话列表默认更高
'--reception-detail-ldr-scroll-height': '520px', '--reception-detail-ldr-scroll-height': '520px',
'--list-content-wrapper-padding': 0,
}, },
landscape: { landscape: {
// 横屏隐藏 portrait 布局 // 横屏隐藏 portrait 布局
...@@ -147,7 +134,6 @@ export default { ...@@ -147,7 +134,6 @@ export default {
// 横屏:列表三列布局(31% width + 2% margin-right × 3 ≈ 99%) // 横屏:列表三列布局(31% width + 2% margin-right × 3 ≈ 99%)
'--reception-list-container-direction': 'row', '--reception-list-container-direction': 'row',
'--reception-list-container-wrap': 'wrap', '--reception-list-container-wrap': 'wrap',
'--reception-list-container-justify': 'flex-start',
'--reception-list-card-min-width': '31%', '--reception-list-card-min-width': '31%',
'--reception-list-card-margin-right': '2%', '--reception-list-card-margin-right': '2%',
...@@ -155,12 +141,7 @@ export default { ...@@ -155,12 +141,7 @@ export default {
'--reception-detail-layout-direction': 'row', '--reception-detail-layout-direction': 'row',
'--reception-detail-right-display': 'flex', '--reception-detail-right-display': 'flex',
'--reception-detail-portrait-right-display': 'none', '--reception-detail-portrait-right-display': 'none',
'--reception-detail-left-flex': '1',
'--reception-detail-right-flex': '2',
// 横屏侧栏较窄:话术两列
'--reception-detail-data-tag-flex-basis': '48%',
'--reception-detail-data-tag-margin-right': '4%',
// 质检表明细适度放大 // 质检表明细适度放大
'--reception-detail-data-table-cell-font-size': '14px', '--reception-detail-data-table-cell-font-size': '14px',
'--reception-detail-data-table-cell-line-height': '20px', '--reception-detail-data-table-cell-line-height': '20px',
...@@ -190,7 +171,6 @@ export default { ...@@ -190,7 +171,6 @@ export default {
'--reception-list-filters-tabs-row-height': '44px', '--reception-list-filters-tabs-row-height': '44px',
'--reception-list-filters-pre-entry-btn-height': '44px', '--reception-list-filters-pre-entry-btn-height': '44px',
'--reception-list-filters-pre-entry-btn-text-font-size': '15px', '--reception-list-filters-pre-entry-btn-text-font-size': '15px',
'--reception-list-filters-pre-entry-btn-text-line-height': '22px',
'--reception-list-filters-pre-entry-icon-size': '13px', '--reception-list-filters-pre-entry-icon-size': '13px',
// 复盘筛选下拉尺寸同步放大 // 复盘筛选下拉尺寸同步放大
'--reception-list-filters-review-tag-text-font-size': '15px', '--reception-list-filters-review-tag-text-font-size': '15px',
...@@ -268,7 +248,6 @@ export default { ...@@ -268,7 +248,6 @@ export default {
'landscape-1174x768': { 'landscape-1174x768': {
// 横屏右侧栏较窄,表格略增大字号 // 横屏右侧栏较窄,表格略增大字号
'--reception-detail-data-container-padding': '10px', '--reception-detail-data-container-padding': '10px',
'--reception-detail-data-tag-flex-basis': '48%',
'--reception-detail-data-tag-font-size': '14px', '--reception-detail-data-tag-font-size': '14px',
'--reception-detail-data-table-header-font-size': '12px', '--reception-detail-data-table-header-font-size': '12px',
'--reception-detail-data-table-header-line-height': '18px', '--reception-detail-data-table-header-line-height': '18px',
......
...@@ -453,13 +453,13 @@ const bottomSafeSpacerStyle = computed((): UTSJSONObject => { ...@@ -453,13 +453,13 @@ const bottomSafeSpacerStyle = computed((): UTSJSONObject => {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "../styles/common.scss";
.list-content-wrapper { .list-content-wrapper {
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 0 var(--list-content-wrapper-padding); padding: 0 var(--list-content-wrapper-padding, 0px);
} }
.list-scroll-view { .list-scroll-view {
......
...@@ -32,11 +32,15 @@ ...@@ -32,11 +32,15 @@
margin-right: var(--reports-entry-margin-right, 0px); margin-right: var(--reports-entry-margin-right, 0px);
margin-bottom: var(--reports-entry-margin-bottom, 12px); margin-bottom: var(--reports-entry-margin-bottom, 12px);
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: visible;
} }
.reports-entry-grid-wrap { .reports-entry-grid-wrap {
width: 100%; width: 100%;
/* 作为 flex 列容器,让内部 EntryGrid 用 flex:1 可靠填满,避免竖屏高度塌缩 */
display: flex;
flex-direction: column;
/* 竖屏/横屏均给确定高度,作为网格填充的基准 */
height: var(--reports-entry-grid-wrap-height, 38px); height: var(--reports-entry-grid-wrap-height, 38px);
flex-shrink: 0; flex-shrink: 0;
margin-top: var(--reports-entry-grid-wrap-margin-top, 0px); margin-top: var(--reports-entry-grid-wrap-margin-top, 0px);
......
...@@ -31,11 +31,15 @@ ...@@ -31,11 +31,15 @@
margin-right: var(--tasks-entry-panel-margin-right, 0px); margin-right: var(--tasks-entry-panel-margin-right, 0px);
margin-bottom: var(--tasks-entry-panel-margin-bottom, 12px); margin-bottom: var(--tasks-entry-panel-margin-bottom, 12px);
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: visible;
} }
.tasks-entry-grid-wrap { .tasks-entry-grid-wrap {
width: 100%; width: 100%;
/* 作为 flex 列容器,让内部 EntryGrid 用 flex:1 可靠填满,避免竖屏高度塌缩 */
display: flex;
flex-direction: column;
/* 竖屏/横屏均给确定高度,作为网格填充的基准 */
height: var(--tasks-entry-grid-wrap-height, 40px); height: var(--tasks-entry-grid-wrap-height, 40px);
flex-shrink: 0; flex-shrink: 0;
margin-top: var(--tasks-entry-grid-wrap-margin-top, 0px); margin-top: var(--tasks-entry-grid-wrap-margin-top, 0px);
......
...@@ -2,15 +2,10 @@ ...@@ -2,15 +2,10 @@
export const globalScreenVars = { export const globalScreenVars = {
// 横竖屏通用 // 横竖屏通用
common: { common: {
'--color-primary': '#1677FF',
'--radius': '8px',
'--opacity': 1,
'--padding': '12px',
// 全局背景色(替代渐变,iOS 兼容) // 全局背景色(替代渐变,iOS 兼容)
'--bg-page': '#F5F7FA', // 极光微灰:营造通透、现代的悬浮层次感 '--bg-page': '#F5F7FA', // 极光微灰:营造通透、现代的悬浮层次感
'--bg-card': '#FFFFFF', '--bg-card': '#FFFFFF',
'--bg-card-hover': '#F0F4FF', '--bg-card-hover': '#F0F4FF',
'--bg-error': '#FEF2F2',
// TabBar 尺寸:横竖屏统一,改这里即可全局生效 // TabBar 尺寸:横竖屏统一,改这里即可全局生效
'--tabbar-height': '60px', '--tabbar-height': '60px',
'--tabbar-icon-size': '32px', '--tabbar-icon-size': '32px',
...@@ -18,41 +13,21 @@ export const globalScreenVars = { ...@@ -18,41 +13,21 @@ export const globalScreenVars = {
// 竖屏全局 // 竖屏全局
portrait: { portrait: {
'--padding': '12px',
'--gap': '8px',
'--font-md': '14px',
}, },
// 横屏全局 // 横屏全局
landscape: { landscape: {
'--padding': '20px',
'--gap': '12px',
'--font-md': '16px',
// ✅ 横屏下内容区与左侧 tabBar 的间距(统一全局变量)
'--content-tabbar-gap': '12px',
}, },
// 精准分辨率 // 精准分辨率
resolutions: { resolutions: {
'portrait-768x1174': {
'--padding': '14px',
},
'landscape-1174x768': {
'--padding': '22px',
'--content-tabbar-gap': '16px', // ✅ 大屏平板横屏:稍大间距
},
'landscape-1024x768': {
'--content-tabbar-gap': '12px', // ✅ 标准 iPad 横屏
},
'landscape-816x393': { 'landscape-816x393': {
'--tabbar-height': '54px', '--tabbar-height': '54px',
'--tabbar-icon-size': '26px', '--tabbar-icon-size': '26px',
'--content-tabbar-gap': '10px', // ✅ 小屏 Pad 横屏:较小间距
}, },
'landscape-1024x640': { 'landscape-1024x640': {
'--tabbar-height': '54px', '--tabbar-height': '54px',
'--tabbar-icon-size': '26px', '--tabbar-icon-size': '26px',
'--content-tabbar-gap': '10px', // ✅ 矮屏设备横屏:较小间距
}, },
}, },
} }
export { export { useOrientation, updateOrientation } from './useOrientation';
useOrientation,
updateOrientation,
type UseOrientationReturn
} from './useOrientation';
export { useScreenVars } from './useScreenVars'; export { useScreenVars } from './useScreenVars';
export { usePageVars } from './usePageVars';
export { useWindowHeight } from './useWindowHeight'; export { useWindowHeight } from './useWindowHeight';
export { useIsPortrait } from './useIsPortrait'; export { useIsPortrait } from './useIsPortrait';
export { useColumnLayout, updateColumnCount, type UseColumnLayoutReturn } from './useColumnLayout'; export { useColumnLayout } from './useColumnLayout';
import { ref, computed, watch, type Ref, type ComputedRef } from 'vue' import { ref, computed, watch, type Ref, type ComputedRef } from 'vue'
import { useOrientation, updateOrientation } from './useOrientation' import { useOrientation } from './useOrientation'
/** /**
* 动态列数布局 Hook * 动态列数布局 Hook
...@@ -17,52 +17,16 @@ const columnCount = ref<number>(1) ...@@ -17,52 +17,16 @@ const columnCount = ref<number>(1)
// 全局唯一的 computed // 全局唯一的 computed
const cssVars = computed((): UTSJSONObject => { const cssVars = computed((): UTSJSONObject => {
const cols = columnCount.value const cols = columnCount.value
const hasGap = cols >= 2
// 计算每列的宽度和间距 // 列宽 = 100/cols,保留 3 位小数(2列=50%,3列≈33.333%,4列=25%,5列=20%)
// UVUE 不支持 gap 和 calc(),直接使用固定值 const widthPct = Math.round((100 / cols) * 1000) / 1000
let rowMarginLeft = "0px"
let rowMarginRight = "0px"
let cellPaddingLeft = "0px"
let cellPaddingRight = "0px"
let columnWidth = "50%" // 默认 2 列
if (cols == 2) {
columnWidth = "50%"
// 12px gap = 左右各 6px padding + 负 margin
rowMarginLeft = "-6px"
rowMarginRight = "-6px"
cellPaddingLeft = "6px"
cellPaddingRight = "6px"
} else if (cols == 3) {
columnWidth = "33.333%"
// 12px gap = 左右各 6px padding + 负 margin
rowMarginLeft = "-6px"
rowMarginRight = "-6px"
cellPaddingLeft = "6px"
cellPaddingRight = "6px"
} else if (cols == 4) {
columnWidth = "25%"
// 12px gap = 左右各 6px padding + 负 margin
rowMarginLeft = "-6px"
rowMarginRight = "-6px"
cellPaddingLeft = "6px"
cellPaddingRight = "6px"
} else if (cols == 5) {
columnWidth = "20%"
// 12px gap = 左右各 6px padding + 负 margin
rowMarginLeft = "-6px"
rowMarginRight = "-6px"
cellPaddingLeft = "6px"
cellPaddingRight = "6px"
}
return { return {
"--column-count": `${cols}`, "--column-count": `${cols}`,
"--column-width": columnWidth, "--column-width": `${widthPct}%`,
"--grid-row-margin-left": rowMarginLeft, "--grid-row-margin-left": hasGap ? "-6px" : "0px",
"--grid-row-margin-right": rowMarginRight, "--grid-row-margin-right": hasGap ? "-6px" : "0px",
"--grid-cell-padding-left": cellPaddingLeft, "--grid-cell-padding-left": hasGap ? "6px" : "0px",
"--grid-cell-padding-right": cellPaddingRight "--grid-cell-padding-right": hasGap ? "6px" : "0px",
} as UTSJSONObject } as UTSJSONObject
}) })
...@@ -87,11 +51,9 @@ function calculateColumnCount(): number { ...@@ -87,11 +51,9 @@ function calculateColumnCount(): number {
/** /**
* 更新列数 * 更新列数
*/ */
export function updateColumnCount(force: boolean = false): void { function updateColumnCount() {
const newColumnCount = calculateColumnCount() const newColumnCount = calculateColumnCount()
if (columnCount.value != newColumnCount) {
// ✅ UTS 避免 Number !== Number 比较,使用 !=
if (force || columnCount.value != newColumnCount) {
columnCount.value = newColumnCount columnCount.value = newColumnCount
console.log('[useColumnLayout] 列数更新为:', columnCount.value) console.log('[useColumnLayout] 列数更新为:', columnCount.value)
} }
...@@ -103,9 +65,8 @@ export function updateColumnCount(force: boolean = false): void { ...@@ -103,9 +65,8 @@ export function updateColumnCount(force: boolean = false): void {
* @returns 列数和 CSS 变量 * @returns 列数和 CSS 变量
*/ */
export function useColumnLayout(autoUpdate: boolean = true): UseColumnLayoutReturn { export function useColumnLayout(autoUpdate: boolean = true): UseColumnLayoutReturn {
// 初始更新 // 初始计算列数
updateOrientation(true) updateColumnCount()
updateColumnCount(true)
// ✅ 性能优化:横竖屏切换时不自动更新列数,避免 ANR // ✅ 性能优化:横竖屏切换时不自动更新列数,避免 ANR
// 用户如需响应式布局,可手动调用 updateColumnCount() // 用户如需响应式布局,可手动调用 updateColumnCount()
......
...@@ -24,40 +24,27 @@ const isTablet = computed((): boolean => { ...@@ -24,40 +24,27 @@ const isTablet = computed((): boolean => {
return shortSide >= 600 return shortSide >= 600
}) })
// 更新方向 // 更新方向(force: 强制更新,用于关键生命周期确保状态同步)
export function updateOrientation(force: boolean = false): void { export function updateOrientation(force: boolean = false): void {
const systemInfo = uni.getSystemInfoSync() const systemInfo = uni.getSystemInfoSync()
// ✅ 修复:优先使用 deviceOrientation 判断方向,避免 windowWidth/windowHeight 时序问题 // 优先使用 deviceOrientation 判断方向
// 使用 uni.getDeviceInfo() 获取设备方向(更可靠)
const deviceInfo = uni.getDeviceInfo() const deviceInfo = uni.getDeviceInfo()
const deviceOrient = deviceInfo.deviceOrientation != null ? deviceInfo.deviceOrientation : "" const deviceOrient = deviceInfo.deviceOrientation != null ? deviceInfo.deviceOrientation : ""
let nextPortrait: boolean let nextPortrait: boolean
if (deviceOrient != '') { if (deviceOrient != '') {
// 如果有 deviceOrientation,直接使用
nextPortrait = (deviceOrient === 'portrait' || deviceOrient === 'portrait-primary' || deviceOrient === 'portrait-secondary') nextPortrait = (deviceOrient === 'portrait' || deviceOrient === 'portrait-primary' || deviceOrient === 'portrait-secondary')
} else { } else {
// 否则回退到宽高比较
nextPortrait = systemInfo.windowWidth < systemInfo.windowHeight nextPortrait = systemInfo.windowWidth < systemInfo.windowHeight
} }
const { screenWidth: w, screenHeight: h } = systemInfo const newWidth = Math.round(systemInfo.screenWidth)
const newHeight = Math.round(systemInfo.screenHeight)
// 使用屏幕物理尺寸 // force 时强制更新;否则仅在值变化时更新
const newWidth = Math.round(w) if (force || windowWidth.value !== newWidth || windowHeight.value !== newHeight || isPortrait.value != nextPortrait) {
const newHeight = Math.round(h)
// 只在值变化时才更新,避免触发不必要的响应式更新
// ✅ UTS 避免 Boolean !== Boolean 比较,使用 !=
const shouldUpdate = force ||
windowWidth.value !== newWidth ||
windowHeight.value !== newHeight ||
isPortrait.value != nextPortrait;
if (shouldUpdate) {
windowWidth.value = newWidth windowWidth.value = newWidth
windowHeight.value = newHeight windowHeight.value = newHeight
isPortrait.value = nextPortrait isPortrait.value = nextPortrait
......
import { useScreenVars } from './useScreenVars'
/**
* 使用页面变量 Hook
* TODO: 此功能尚未完全实现,暂时返回空对象
* UTS 不支持 require() 动态导入,建议使用静态导入
*/
export function usePageVars() {
// TODO: 实现页面变量加载逻辑
// 当前 UTS 不支持 require() 动态导入
// 建议在具体页面中直接导入并使用 useScreenVars
return useScreenVars(null)
}
import { type Ref, watch, ref, computed, type ComputedRef, inject } from 'vue' import { type Ref, watch, ref, computed, type ComputedRef, inject } from 'vue'
import { useOrientation, updateOrientation } from './useOrientation' import { useOrientation } from './useOrientation'
import { globalScreenVars } from '../constants/screen.vars.global' import { globalScreenVars } from '../constants/screen.vars.global'
import { merge, getAsObject } from '@/utils/common' import { merge, getAsObject } from '@/utils/common'
import type { OptionalVars } from '@/types' import type { OptionalVars } from '@/types'
...@@ -11,9 +11,6 @@ import type { OptionalVars } from '@/types' ...@@ -11,9 +11,6 @@ import type { OptionalVars } from '@/types'
* @returns 响应式的屏幕变量对象 * @returns 响应式的屏幕变量对象
*/ */
export function useScreenVars(pageVars: OptionalVars | null = null, pageVarsGetter: (() => UTSJSONObject | null) | null = null): ComputedRef<UTSJSONObject> { export function useScreenVars(pageVars: OptionalVars | null = null, pageVarsGetter: (() => UTSJSONObject | null) | null = null): ComputedRef<UTSJSONObject> {
// ✅ 强制更新方向信息,确保 resolutionKey 正确(解决横屏首次加载样式不匹配问题)
updateOrientation(true);
// 如果没有传入 pageVars,尝试从 provide/inject 获取 // 如果没有传入 pageVars,尝试从 provide/inject 获取
let effectivePageVars = pageVars; let effectivePageVars = pageVars;
if (effectivePageVars == null) { if (effectivePageVars == null) {
......
.home-frame-container.mode-landscape.res-1080 {
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
}
.home-frame-container.mode-landscape.res-1920 {
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
}
.home-frame-container.mode-portrait.res-1080 {
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
}
.home-frame-container.mode-portrait.res-1920 {
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
}
.mode-landscape.res-1080 {
}
.mode-landscape.res-1920 {
}
.mode-portrait.res-1080 {
.start {
height: 96px;
}
}
.mode-portrait.res-1920 {
}
.mode-portrait.res-1080 .login-page {
.layout {
justify-content: flex-start;
align-items: stretch;
padding: 32px 24px;
}
.login {
align-items: stretch;
margin-top: 16px;
max-width: 320px;
margin-left: auto;
margin-right: auto;
}
.login .title {
font-size: 28px;
margin-bottom: 12px;
}
.login .sub-title {
font-size: 14px;
margin: 12px 0 20px;
}
.login .input {
width: 100%;
height: 48px;
border-radius: 24px;
margin-bottom: 16px;
}
.login .btn {
width: 100%;
height: 48px;
margin-top: 8px;
font-size: 18px;
}
.form-footer {
padding-left: 0;
margin-top: 16px;
}
.app-code {
bottom: 12px;
font-size: 10px !important;
line-height: 14px;
left: 50%;
transform: translateX(-50%) scale(0.85);
}
}
.mode-portrait.res-1920 .account-page {
}
.mode-portrait.res-1080 .account-page {
.layout {
padding-top: 48px;
padding-bottom: 24px;
}
.content-box {
top: 120px;
bottom: 48px;
width: 94%;
border-radius: 16px;
}
.step-box {
transform: scale(0.9);
}
.box {
padding: 0 16px;
justify-content: flex-start;
}
.box .items {
width: 100%;
margin-bottom: 16px;
}
}
export type ResponsiveImage = {
x1: string
x2?: string // 可选
x3?: string // 可选
}
export type DemoPageConfig = {
heroImageSrc: ResponsiveImage
heroImageWidth: string
paddingLeft: string
paddingRight: string
titleFontSize: string
}
// 可以在这里添加其他页面的配置类型
// export type HomePageConfig = { ... }
export type AppResolutionConfig = {
demo: DemoPageConfig
// home: HomePageConfig
}
...@@ -15,9 +15,9 @@ export function appMixin(app: VueApp) { ...@@ -15,9 +15,9 @@ export function appMixin(app: VueApp) {
}, },
onLoad() {}, onLoad() {},
onResize() { onResize() {
// 全局监听屏幕旋转,自动更新方向信息 // 全局监听屏幕旋转,强制更新方向信息
// 所有页面都会自动执行,无需在每个页面重复编写 // 所有页面都会自动执行,业务页面只需监听响应式状态
updateOrientation(); updateOrientation(true);
} }
}); });
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!