Commit e49d8f91 by Lin

feat(接待中心): 支持横屏模式并优化布局

- 在接待中心页面中实现横屏支持,调整客户和接待记录列表的展示方式
- 根据屏幕方向动态切换布局,横屏时采用左右分栏展示,竖屏时保持原有逻辑
- 优化样式以适应不同屏幕方向,确保用户体验一致性
- 移除默认竖屏锁定逻辑,允许系统自动处理屏幕方向
1 parent cc1177ba
......@@ -15,14 +15,14 @@ export default {
layoutService.init();
const sys = uni.getSystemInfoSync();
console.log(`[App] 当前分辨率:${ sys.screenWidth } x ${ sys.screenHeight}`);
// 默认竖屏:锁定后延迟刷新屏幕尺寸,并重试锁定避免首屏被框架改向
lockOrientation("portrait-primary");
// 默认竖屏:如需强制锁定竖屏,再开启这里的锁定逻辑
// lockOrientation("portrait-primary");
setTimeout(() => {
layoutService.refreshScreenInfo();
updateResolutionConfig();
}, 400);
setTimeout(() => { lockOrientation("portrait-primary"); }, 600);
setTimeout(() => { lockOrientation("portrait-primary"); }, 1200);
// setTimeout(() => { lockOrientation("portrait-primary"); }, 600);
// setTimeout(() => { lockOrientation("portrait-primary"); }, 1200);
// #endif
console.log("App Launch");
// 启动时仅做分辨率配置,避免后台定时器/录音模拟导致对象被长时间持有
......
......@@ -6,9 +6,7 @@
"versionCode": "126",
"uni-app-x": {
},
/* 快应用特有相关 */
"quickapp": {},
/* 小程序特有相关 */
"mp-weixin": {
"appid": "",
"setting": {
......@@ -38,10 +36,7 @@
"xxhdpi": "",
"xxxhdpi": ""
}
},
"orientation": [
"portrait-primary"
]
}
}
},
"app-android": {
......@@ -53,8 +48,8 @@
"system": {}
},
"lime-sqlite": {},
"uni-recorder-x": {}, // 录音模块
"uni-recorder": {}, // 录音模块
"uni-recorder-x": {},
"uni-recorder": {},
"uni-websocket": {}
},
"icons": {
......@@ -66,9 +61,6 @@
"splashScreens": {
"default": {}
},
"orientation": [
"portrait-primary"
],
"permissions": [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
......@@ -92,10 +84,7 @@
"distribute": {
"modules": {},
"icons": {},
"splashScreens": {},
"orientation": [
"portrait-primary"
]
"splashScreens": {}
}
},
"web": {
......
<template>
<!-- 客户录入列表:与 customervisits.customerInfoPage 字段对齐(ownerPhone / brandModel / customerTagName / arrivalDate / ownerName) -->
<view class="customer-entry-list">
<view :class="['customer-entry-list', isLandscape ? 'customer-entry-list-landscape' : '']">
<!-- 首次加载:列表为空时,用骨架卡片占位,避免空白 -->
<view
v-if="loading && (props.customerList == null || props.customerList.length == 0)"
v-for="i in skeletonCardCount"
:key="'entry-skeleton-' + i"
class="list-card list-card-entry glass-card"
:class="['list-card', 'list-card-entry', 'glass-card', isLandscape ? 'list-card-entry-landscape' : '']"
>
<un-skeleton rows="3" title loading></un-skeleton>
</view>
......@@ -14,7 +14,7 @@
v-else
v-for="item in props.customerList"
:key="getStr(item, 'id')"
class="list-card list-card-entry glass-card"
:class="['list-card', 'list-card-entry', 'glass-card', isLandscape ? 'list-card-entry-landscape' : '']"
@click="onEntryCardClick(item)"
@longpress="onEntryCardLongPress(item)"
>
......@@ -58,7 +58,7 @@
</template>
<script setup lang="uts">
import { computed, ref, watch } from 'vue'
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
const props = defineProps<{
/** 客户档案列表(由父级拉取并传入) */
......@@ -72,6 +72,31 @@ const props = defineProps<{
const loading = computed<boolean>(() => props.loading === true)
const skeletonCardCount = 3
/** 是否横屏(w > h)。uni-app x UTS 当前编译目标不支持 onWindowResize,使用轮询响应旋转 */
const isLandscape = ref(false)
let orientationPollId = 0
const ORIENTATION_POLL_MS = 400
function syncOrientation(): void {
const info = uni.getWindowInfo()
// 宽高优先取 systemInfo(部分机型旋转后 getWindowInfo 可能刷新不及时)
const sys = uni.getSystemInfoSync()
const sysSw = sys.screenWidth
const sysSh = sys.screenHeight
const ww = info.windowWidth
const wh = info.windowHeight
const sw = info.screenWidth
const sh = info.screenHeight
const w = sysSw > 0 ? sysSw : (sw > 0 ? sw : ww)
const h = sysSh > 0 ? sysSh : (sh > 0 ? sh : wh)
const nextLandscape = w > h
if (isLandscape.value != nextLandscape) {
isLandscape.value = nextLandscape
}
}
const emit = defineEmits<{
/** 点击卡片:打开客户档案详情 */
'entry-click': [item: UTSJSONObject]
......@@ -91,6 +116,21 @@ watch(
}
)
onMounted((): void => {
syncOrientation()
orientationPollId = setInterval((): void => {
syncOrientation()
}, ORIENTATION_POLL_MS)
})
onUnmounted((): void => {
const id = orientationPollId
if (id > 0) {
clearInterval(id)
orientationPollId = 0
}
})
function getStr(data: UTSJSONObject, key: string): string {
const v = data[key]
if (v == null) {
......@@ -229,6 +269,12 @@ function onEntryCardMaskDelete(item: UTSJSONObject): void {
width: 100%;
}
.customer-entry-list-landscape {
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
.glass-card {
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(255, 255, 255, 0.6);
......@@ -248,6 +294,10 @@ function onEntryCardMaskDelete(item: UTSJSONObject): void {
overflow: hidden;
}
.list-card-entry-landscape {
width: 49%;
}
.entry-card-mask {
position: absolute;
left: 0;
......
<template>
<!-- 接待复盘记录列表:与接待接口字段对齐,数据由父级拉取后传入 -->
<view class="reception-record-list">
<view :class="['reception-record-list', isLandscape ? 'reception-record-list-landscape' : '']">
<!-- 首次加载:列表为空时,用骨架卡片占位,避免空白 -->
<view
v-if="!loading && (props.receptionRecordList == null || props.receptionRecordList.length == 0)"
v-for="i in skeletonCardCount"
:key="'reception-skeleton-' + i"
class="list-card glass-card"
:class="['list-card', 'glass-card', isLandscape ? 'list-card-landscape' : '']"
>
<un-skeleton rows="3" title loading></un-skeleton>
</view>
......@@ -14,7 +14,7 @@
v-else
v-for="(item, idx) in props.receptionRecordList"
:key="getStr(item, 'batchId') != '' ? getStr(item, 'batchId') + '-' + idx : 'recv-' + idx"
class="list-card glass-card"
:class="['list-card', 'glass-card', isLandscape ? 'list-card-landscape' : '']"
@click="onCardClick(item)"
>
<un-skeleton :rows="3" title :loading="loading">
......@@ -48,7 +48,7 @@
</template>
<script setup lang="uts">
import { computed } from 'vue'
import { computed, onMounted, onUnmounted, ref } from 'vue'
const props = defineProps<{
/** 接待记录列表(由父级拉取并传入) */
......@@ -60,11 +60,51 @@ const props = defineProps<{
const loading = computed<boolean>(() => props.loading === true)
const skeletonCardCount = 3
/** 是否横屏(w > h)。uni-app x UTS 当前编译目标不支持 onWindowResize,使用轮询响应旋转 */
const isLandscape = ref(false)
let orientationPollId = 0
const ORIENTATION_POLL_MS = 400
function syncOrientation(): void {
const info = uni.getWindowInfo()
// 宽高优先取 systemInfo(部分机型旋转后 getWindowInfo 可能刷新不及时)
const sys = uni.getSystemInfoSync()
const sysSw = sys.screenWidth
const sysSh = sys.screenHeight
const ww = info.windowWidth
const wh = info.windowHeight
const sw = info.screenWidth
const sh = info.screenHeight
const w = sysSw > 0 ? sysSw : (sw > 0 ? sw : ww)
const h = sysSh > 0 ? sysSh : (sh > 0 ? sh : wh)
const nextLandscape = w > h
if (isLandscape.value != nextLandscape) {
isLandscape.value = nextLandscape
}
}
const emit = defineEmits<{
/** 点击卡片:父级根据 filterTabIndex 等处理详情或 toast */
'reception-click': [item: UTSJSONObject]
}>()
onMounted((): void => {
syncOrientation()
orientationPollId = setInterval((): void => {
syncOrientation()
}, ORIENTATION_POLL_MS)
})
onUnmounted((): void => {
const id = orientationPollId
if (id > 0) {
clearInterval(id)
orientationPollId = 0
}
})
function getStr(data: UTSJSONObject, key: string): string {
const v = data[key]
if (v == null) {
......@@ -209,6 +249,12 @@ function onCardClick(item: UTSJSONObject): void {
width: 100%;
}
.reception-record-list-landscape {
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
.glass-card {
background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(255, 255, 255, 0.6);
......@@ -223,6 +269,10 @@ function onCardClick(item: UTSJSONObject): void {
margin-bottom: 12px;
}
.list-card-landscape {
width: 49%;
}
.card-header-row {
flex-direction: row;
justify-content: space-between;
......
......@@ -143,7 +143,9 @@ const showReceptionEmpty = computed((): boolean => {
flex: 1;
min-height: 0;
width: 100%;
height: auto;
/* scroll-view 在 APP 端需要“确定高度”才能产生滚动,从而触发 scrolltolower
横屏分栏 flex 布局下 auto 高度容易导致不滚动 */
height: 100%;
}
.sub-tabs-row {
......
......@@ -4,7 +4,7 @@
*/
// #ifdef APP
import { layoutService } from '@/services/LayoutService.uts'
import { lockOrientation } from '@/utils/plus-screen.uts'
import { lockOrientation, unlockOrientation } from '@/utils/plus-screen.uts'
import { updateResolutionConfig } from '@/services/adapter/index.uts'
// #endif
......@@ -36,7 +36,8 @@ export function applyScreenOrientationLock(): void {
refreshTimer = 0
}, 800)
} else {
lockOrientation('portrait-primary')
// 不再默认锁定竖屏:手机等设备交由系统/用户旋转控制
unlockOrientation()
}
// #endif
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!