Commit d3f276a6 by Lin

feat(reception): 更新接待中心样式和功能以支持动态适配

- 在接待中心页面中集成屏幕方向检测,优化布局响应能力
- 移除不必要的样式文件,替换为 SCSS 格式以提升可维护性
- 更新多个组件的样式,确保在不同分辨率下的适应性
- 引入新的样式变量,增强整体视觉一致性和用户体验
1 parent 9c8c02af
<template> <template>
<!-- 接待中心 Tab 聚合页 --> <!-- 接待中心 Tab 聚合页 -->
<layout-root :key="isLandscape"> <layout-root :page-vars="pageVars">
<!-- <view class="test" :style="dynamicModuleBoxStyle"> <!-- <view class="test test-view">
测试文案 {{ dynamicModuleBoxStyle}} <text class="test-orientation-text">hooks:{{ hookOrientation }} {{ hookOrientation=='landscape'?'横屏':'竖屏'}} {{ isLandscape }}</text>
</view> --> </view> -->
<view class="reception-center-page"> <view class="reception-center-page">
<!-- 顶部安全区 -->
<view
v-if="isPortrait768x1174"
class="reception-safe-top-spacer"
:style="receptionSafeTopSpacerStyle"
></view>
<!-- <un-navbar title="接待中心" left-icon="" /> --> <!-- <un-navbar title="接待中心" left-icon="" /> -->
<!-- <view class="reception-navbar-spacer"></view> --> <!-- <view class="reception-navbar-spacer"></view> -->
...@@ -175,7 +168,7 @@ ...@@ -175,7 +168,7 @@
<script setup lang="uts"> <script setup lang="uts">
// 接待中心 Tab 聚合页 // 接待中心 Tab 聚合页
import { ref, computed, onMounted, onUnmounted, watch, onResize } from 'vue' import { ref, computed, onMounted, onUnmounted, watch, onResize, type Ref } from 'vue'
import { type UnPickerColumn, type UnPickerColumnItem, type UnPickerConfirmEvent, type UnTabItem } from '@/uni_modules/uview-unix' import { type UnPickerColumn, type UnPickerColumnItem, type UnPickerConfirmEvent, type UnTabItem } from '@/uni_modules/uview-unix'
import FormDetail from './forms/FormDetail.uvue' import FormDetail from './forms/FormDetail.uvue'
import ReceptionDetail from './receptionDetail.uvue' import ReceptionDetail from './receptionDetail.uvue'
...@@ -187,6 +180,7 @@ import { getMerchantPerformance, getCustomerFileList, getReceptionList } from '@ ...@@ -187,6 +180,7 @@ import { getMerchantPerformance, getCustomerFileList, getReceptionList } from '@
import { storage } from '@/utils/storage.uts' import { storage } from '@/utils/storage.uts'
import { resolutionState } from '@/services/adapter/index.uts' import { resolutionState } from '@/services/adapter/index.uts'
import { cssClassRef } from "@/services/adapter"; import { cssClassRef } from "@/services/adapter";
import { updateOrientation, useOrientation } from '@/services/adapter/hooks/index.uts'
// 导入样式变量 // 导入样式变量
import { getLandscapeConfig } from "./styles/landscape.uts"; import { getLandscapeConfig } from "./styles/landscape.uts";
import { import {
...@@ -194,12 +188,18 @@ import { ...@@ -194,12 +188,18 @@ import {
getReceptionPortraitMainTabsConfig, getReceptionPortraitMainTabsConfig,
type ReceptionPortraitMainTabsConfig type ReceptionPortraitMainTabsConfig
} from "./styles/portrait.uts"; } from "./styles/portrait.uts";
import pageVars from './styles/index.vars'
const isPortrait768x1174 = computed((): boolean => { const isPortrait768x1174 = computed((): boolean => {
// 仅在 768x1174 分辨率(竖屏适配类名)下展示顶部安全区占位 // 仅在 768x1174 分辨率(竖屏适配类名)下展示顶部安全区占位
return cssClassRef.value.indexOf('layout-portrait-768x1174') >= 0 return cssClassRef.value.indexOf('layout-portrait-768x1174') >= 0
}) })
// ========== Tab 管理 ==========
/** useOrientation 全局状态,配合 updateOrientation 在 onMounted / onResize 刷新后展示 */
const receptionOrientationHook = useOrientation()
const hookOrientation = computed((): string => {
return (receptionOrientationHook.orientationKey as Ref<string>).value
})
// ========== Tab 管理 ========== // ========== Tab 管理 ==========
/** 主 Tab:0=业绩看板,1=客户列表 */ /** 主 Tab:0=业绩看板,1=客户列表 */
const mainTabIndex = ref(0) const mainTabIndex = ref(0)
...@@ -369,61 +369,26 @@ const receptionFilterNarrowMode = ref(false) ...@@ -369,61 +369,26 @@ const receptionFilterNarrowMode = ref(false)
let receptionDashboardLayoutPollId: number | null = null let receptionDashboardLayoutPollId: number | null = null
const RECEPTION_LAYOUT_POLL_MS = 400 const RECEPTION_LAYOUT_POLL_MS = 400
/** 是否横屏(windowWidth > windowHeight)。横屏模式下隐藏 Tabs,左右分栏同时展示两个模块 */ /** 是否横屏:与 orientationKey / hookOrientation 同源(useOrientation 的 isPortrait),保持 computed 随 updateOrientation 更新 */
const isLandscape = ref(false) const isLandscape = computed((): boolean => {
return (receptionOrientationHook.isPortrait as Ref<boolean>).value != true
})
/** 记录上一次打印过的方向,避免轮询期间刷屏 */ /** 记录上一次打印过的方向,避免轮询期间刷屏 */
let lastOrientationLogLandscape: boolean | null = null let lastOrientationLogLandscape: boolean | null = null
/** 顶部安全区占位(px):与系统状态栏/刘海对齐,随窗口信息刷新 */
const receptionPageInsetTopPx = ref(0)
const receptionSafeTopSpacerStyle = computed((): UTSJSONObject => {
return {
height: `${receptionPageInsetTopPx.value}px`,
width: '100%',
} as UTSJSONObject
})
function syncReceptionDashboardLayout(): void { function syncReceptionDashboardLayout(): void {
/** /**
* 接待中心「布局同步」: * 接待中心「布局同步」:
* - 计算顶部安全区占位,避免自定义导航与状态栏/刘海重叠 * - 横竖屏 UI 由 useOrientation(isPortrait / orientationKey)与 isLandscape(computed)驱动,须先刷新全局方向再读 isLandscape
* - 判断横竖屏(横屏用于左右分栏展示、竖屏用于 Tab 切换展示)
* - 横屏窄宽时启用筛选区窄模式,避免 segmented 等控件最小宽度导致溢出 * - 横屏窄宽时启用筛选区窄模式,避免 segmented 等控件最小宽度导致溢出
* *
* 说明: * 说明:
* - uni-app x(尤其 APP 端)对 onWindowResize 支持不稳定,因此通过定时轮询触发同步 * - uni-app x(尤其 APP 端)对 onWindowResize 支持不稳定,因此通过定时轮询触发同步
* - 部分机型旋转后 getWindowInfo 的 windowWidth/windowHeight 刷新可能滞后,这里优先用 systemInfo 的 screenWidth/screenHeight 做兜底 * - 部分机型旋转后 getWindowInfo 的 windowWidth/windowHeight 刷新可能滞后,这里优先用 systemInfo 的 screenWidth/screenHeight 做兜底
*/ */
updateOrientation()
// 必须用 uni.getWindowInfo():uview-unix 的 getWindowInfo 在 Android 上返回 GetWindowInfoResult,不能 as UTSJSONObject // 必须用 uni.getWindowInfo():uview-unix 的 getWindowInfo 在 Android 上返回 GetWindowInfoResult,不能 as UTSJSONObject
const info = uni.getWindowInfo() const info = uni.getWindowInfo()
// 自定义导航:预留顶部安全区,避免与状态栏/刘海重叠(优先 safeAreaInsets.top -> safeArea.top -> statusBarHeight)
let topInset = 0
const insets = info.safeAreaInsets
if (insets != null) {
const t = insets.top
if (t != null && t > 0) {
topInset = Math.round(t)
}
}
if (topInset <= 0) {
const safe = info.safeArea
if (safe != null) {
const st = safe.top
if (st != null && st > 0) {
topInset = Math.round(st)
}
}
}
if (topInset <= 0) {
const sb = info.statusBarHeight
if (sb != null && sb > 0) {
topInset = Math.round(sb)
}
}
if (receptionPageInsetTopPx.value != topInset) {
receptionPageInsetTopPx.value = topInset
}
// 宽高优先取 systemInfo(部分机型旋转后 getWindowInfo 可能刷新不及时) // 宽高优先取 systemInfo(部分机型旋转后 getWindowInfo 可能刷新不及时)
const sys = uni.getSystemInfoSync() const sys = uni.getSystemInfoSync()
const sysSw = sys.screenWidth const sysSw = sys.screenWidth
...@@ -437,21 +402,17 @@ function syncReceptionDashboardLayout(): void { ...@@ -437,21 +402,17 @@ function syncReceptionDashboardLayout(): void {
// 横屏判定:宽 > 高。取值优先级:systemInfo.screen* -> windowInfo.screen* -> windowInfo.window* // 横屏判定:宽 > 高。取值优先级:systemInfo.screen* -> windowInfo.screen* -> windowInfo.window*
const w = sysSw > 0 ? sysSw : (sw > 0 ? sw : ww) const w = sysSw > 0 ? sysSw : (sw > 0 ? sw : ww)
const h = sysSh > 0 ? sysSh : (sh > 0 ? sh : wh) const h = sysSh > 0 ? sysSh : (sh > 0 ? sh : wh)
const nextSplit = w > h if (lastOrientationLogLandscape == null || lastOrientationLogLandscape != isLandscape.value) {
if (isLandscape.value != nextSplit) { lastOrientationLogLandscape = isLandscape.value
isLandscape.value = nextSplit
}
if (lastOrientationLogLandscape == null || lastOrientationLogLandscape != nextSplit) {
lastOrientationLogLandscape = nextSplit
console.log( console.log(
`[ReceptionCenter] 屏幕方向变化:${nextSplit ? '横屏' : '竖屏'}(w=${w}, h=${h}, window=${ww}x${wh}, screen=${sw}x${sh})` `[ReceptionCenter] 屏幕方向变化:${isLandscape.value ? '横屏' : '竖屏'}(w=${w}, h=${h}, window=${ww}x${wh}, screen=${sw}x${sh})`
) )
} }
console.log('[ReceptionCenter] syncReceptionDashboardLayout'); console.log('[ReceptionCenter] syncReceptionDashboardLayout');
// 横屏窄宽适配:避免右侧筛选区控件(如 segmented)在小于阈值时出现横向溢出 // 横屏窄宽适配:避免右侧筛选区控件(如 segmented)在小于阈值时出现横向溢出
const RECEPTION_FILTER_NARROW_WIDTH = 920 const RECEPTION_FILTER_NARROW_WIDTH = 920
const nextFilterNarrowMode = nextSplit && w > 0 && w < RECEPTION_FILTER_NARROW_WIDTH const nextFilterNarrowMode = isLandscape.value && w > 0 && w < RECEPTION_FILTER_NARROW_WIDTH
if (receptionFilterNarrowMode.value != nextFilterNarrowMode) { if (receptionFilterNarrowMode.value != nextFilterNarrowMode) {
receptionFilterNarrowMode.value = nextFilterNarrowMode receptionFilterNarrowMode.value = nextFilterNarrowMode
} }
...@@ -493,6 +454,8 @@ onResize((res: any) => { ...@@ -493,6 +454,8 @@ onResize((res: any) => {
console.log(`[ReceptionCenter][onResize] size = ${w}x${h}`) console.log(`[ReceptionCenter][onResize] size = ${w}x${h}`)
} }
} }
updateOrientation()
syncReceptionDashboardLayout()
}) })
function getPerformanceData(): Promise<void> { function getPerformanceData(): Promise<void> {
...@@ -1221,7 +1184,8 @@ function openReviewPicker(): void { ...@@ -1221,7 +1184,8 @@ function openReviewPicker(): void {
} }
onMounted(() => { onMounted(() => {
// JS判断安全区顶部占位、横竖屏判断、以及 横屏窄宽时右侧筛选区的窄屏模式 // 先刷新全局方向,再同步安全区与窄屏模式(与 isLandscape 的 computed 数据源一致)
updateOrientation()
syncReceptionDashboardLayout() syncReceptionDashboardLayout()
// uni-app x(尤其 APP 端)对 onWindowResize 支持不稳定,这里统一用轮询保证兼容性 // uni-app x(尤其 APP 端)对 onWindowResize 支持不稳定,这里统一用轮询保证兼容性
// 如需 H5 实时监听,可在 H5 条件编译块里单独注册 // 如需 H5 实时监听,可在 H5 条件编译块里单独注册
...@@ -1266,7 +1230,7 @@ onUnmounted(() => { ...@@ -1266,7 +1230,7 @@ onUnmounted(() => {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
// @import "./styles/common.scss"; @import "./styles/common.scss";
// @import "./styles/landscape.scss"; // @import "./styles/landscape.scss";
// @import "./styles/portrait.scss"; // @import "./styles/portrait.scss";
/* 接待中心页面包一层:供预录表单绝对定位覆盖 */ /* 接待中心页面包一层:供预录表单绝对定位覆盖 */
...@@ -1280,18 +1244,12 @@ onUnmounted(() => { ...@@ -1280,18 +1244,12 @@ onUnmounted(() => {
flex-direction: column; flex-direction: column;
} }
/* 动态高度由 receptionSafeTopSpacerStyle 注入,避免与状态栏区域重叠 */
.reception-safe-top-spacer {
width: 100%;
flex-shrink: 0;
}
/* ========== Tab 容器 ========== */ /* ========== Tab 容器 ========== */
.reception-tabs-container { .reception-tabs-container {
background-color: #ffffff; background-color: #ffffff;
flex-shrink: 0; flex-shrink: 0;
border-bottom: 1px solid #eef2f7; border-bottom: 1px solid #eef2f7;
padding: 8px 12px 6px; padding: 0px 12px 6px;
box-sizing: border-box; box-sizing: border-box;
} }
......
...@@ -127,8 +127,8 @@ const preEntryIconSize = computed((): number => { ...@@ -127,8 +127,8 @@ const preEntryIconSize = computed((): number => {
}) })
</script> </script>
<style> <style scoped lang="scss">
@import "../styles/reception-filter-shared.css"; @import "../styles/reception-filter-shared.scss";
.filter-group-compact.filter-group-entry-segmented { .filter-group-compact.filter-group-entry-segmented {
flex: 1 1 0; flex: 1 1 0;
......
...@@ -133,8 +133,8 @@ const reviewTagArrowStyle = computed((): UTSJSONObject => { ...@@ -133,8 +133,8 @@ const reviewTagArrowStyle = computed((): UTSJSONObject => {
}) })
</script> </script>
<style> <style scoped lang="scss">
@import "../styles/reception-filter-shared.css"; @import "../styles/reception-filter-shared.scss";
.filter-actions.filter-actions--review { .filter-actions.filter-actions--review {
flex: 2 1 0; flex: 2 1 0;
......
.adapter{
color:var(--adapter-color);
font-size: var(--adapter-fontsize);
}
.test-view{
height: var(--test-view-height);
background-color: var(--test-view-bg, transparent);
}
.reception-tabs-container{
padding: var(--reception-tabs-container-padding);
}
\ No newline at end of file \ No newline at end of file
// 约定式命名:必须叫 index.vars.uts
export default {
common: {
'--home-box-bg': '#FF4444',
},
portrait: {
'--adapter-color': 'red',
'--adapter-fontsize': '50px',
'--test-view-height': '60px',
'--test-view-bg': 'red',
// 'padding': '10px'
},
landscape: {
'--adapter-color': 'green',
'--adapter-fontsize': '50px',
'--test-view-height': '30px',
'--test-view-bg': 'green',
// 'padding': '10px'
},
resolutions: {
'portrait-768x1174': {
'--adapter-color': 'blue',
'--adapter-fontsize': '50px',
'--test-view-height': '60px',
'--test-view-bg': 'blue',
// 'padding': '10px'
'--reception-tabs-container-padding': '8px 12px 60px'
},
'landscape-1174x768': {
'--adapter-color': '#FF4444',
'--adapter-fontsize': '20px',
'--test-view-width': '100%',
'--test-view-height': '30px',
'--test-view-bg': 'pink',
// 'padding': '10px'
},
},
}
...@@ -27,35 +27,35 @@ ...@@ -27,35 +27,35 @@
.entry-filter-segmented-wrap { .entry-filter-segmented-wrap {
align-items: stretch; align-items: stretch;
}
.entry-filter-segmented-wrap .un-segmented { .un-segmented {
flex: 1; flex: 1;
width: 100%; width: 100%;
border-width: 0; border-width: 0;
background-color: rgba(0, 0, 0, 0.04); background-color: rgba(0, 0, 0, 0.04);
border-radius: 10px; border-radius: 10px;
padding: 2px; padding: 2px;
} }
.entry-filter-segmented-wrap .un-segmented__item { .un-segmented__item {
border-width: 0; border-width: 0;
border-radius: 10px; border-radius: 10px;
}
.entry-filter-segmented-wrap .un-segmented__item .un-segmented__item__text { .un-segmented__item__text {
color: #64748b; color: #64748b;
font-size: 14px; font-size: 14px;
} }
.entry-filter-segmented-wrap .un-segmented__item--active { &--active {
background-color: #ffffff; background-color: #ffffff;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.entry-filter-segmented-wrap .un-segmented__item--active .un-segmented__item__text { .un-segmented__item__text {
color: #1677ff; color: #1677ff;
font-weight: 600; font-weight: 600;
}
}
}
} }
.filter-actions { .filter-actions {
......
<template> <template>
<layout-root :page-vars="pageVars">
<view class="list-content-wrapper"> <view class="list-content-wrapper">
<!-- 横屏分栏时:子 Tab + 筛选区固定在列表上方,仅下方列表滚动,避免随滚动移出视区 --> <!-- 横屏分栏时:子 Tab + 筛选区固定在列表上方,仅下方列表滚动,避免随滚动移出视区 -->
<view v-if="stickyHeader == true" class="list-header-fixed"> <view v-if="stickyHeader == true" class="list-header-fixed">
...@@ -141,6 +142,7 @@ ...@@ -141,6 +142,7 @@
</list-item> </list-item>
</list-view> </list-view>
</view> </view>
</layout-root>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
...@@ -155,7 +157,7 @@ import { ...@@ -155,7 +157,7 @@ import {
getReceptionPortraitListSubTabsConfig, getReceptionPortraitListSubTabsConfig,
type ReceptionPortraitListSubTabsConfig, type ReceptionPortraitListSubTabsConfig,
} from '../styles/portrait.uts' } from '../styles/portrait.uts'
import pageVars from '../styles/index.vars'
const props = defineProps<{ const props = defineProps<{
/** 横屏分栏时为 true:子 Tab + 筛选区不参与纵向滚动,固定在列表区域顶部 */ /** 横屏分栏时为 true:子 Tab + 筛选区不参与纵向滚动,固定在列表区域顶部 */
stickyHeader?: boolean stickyHeader?: boolean
...@@ -219,7 +221,8 @@ const showReceptionEmpty = computed((): boolean => { ...@@ -219,7 +221,8 @@ const showReceptionEmpty = computed((): boolean => {
}) })
</script> </script>
<style> <style scoped lang="scss">
@import "../styles/common.scss";
.list-content-wrapper { .list-content-wrapper {
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
......
<template> <template>
<scroll-view class="dashboard-scroll-view" :scroll-y="true" :show-scrollbar="false"> <layout-root :page-vars="pageVars">
<!-- <scroll-view class="dashboard-scroll-view" :scroll-y="true" :show-scrollbar="false"> -->
<!-- <view class="test test-view">
<text class="test-orientation-text">hooks</text>
</view> -->
<view class="dashboard-content" :style="dashboardContentStyle"> <view class="dashboard-content" :style="dashboardContentStyle">
<view class="card-header" :style="dashboardCardHeaderStyle"> <view class="card-header" :style="dashboardCardHeaderStyle">
<view class="header-surface" :style="dashboardHeaderSurfaceStyle"> <view class="header-surface" :style="dashboardHeaderSurfaceStyle">
...@@ -51,7 +55,8 @@ ...@@ -51,7 +55,8 @@
:metrics-visible="performanceMetricsVisible" :metrics-visible="performanceMetricsVisible"
/> />
</view> </view>
</scroll-view> <!-- </scroll-view> -->
</layout-root>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
...@@ -61,6 +66,7 @@ import CardOutputValue from '../cards/CardOutputValue.uvue' ...@@ -61,6 +66,7 @@ import CardOutputValue from '../cards/CardOutputValue.uvue'
import CardMonthValue from '../cards/CardMonthValue.uvue' import CardMonthValue from '../cards/CardMonthValue.uvue'
import type { CompareRow, OutputSummary } from '../types/reception-output-types.uts' import type { CompareRow, OutputSummary } from '../types/reception-output-types.uts'
import { cssClassRef } from "@/services/adapter"; import { cssClassRef } from "@/services/adapter";
import pageVars from '../styles/index.vars'
// 导入样式变量 // 导入样式变量
import { import {
getReceptionPortraitDashboardConfig, getReceptionPortraitDashboardConfig,
...@@ -243,7 +249,8 @@ const progressWidth = computed((): string => { ...@@ -243,7 +249,8 @@ const progressWidth = computed((): string => {
}) })
</script> </script>
<style> <style scoped lang="scss">
@import "../styles/common.scss";
.dashboard-scroll-view { .dashboard-scroll-view {
flex: 1; flex: 1;
min-height: 0; min-height: 0;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!