Commit 05f4c1c3 by Lin

feat(reception): 增强接待中心组件的安全区适配

- 添加顶部安全区以避免与状态栏/刘海重叠,提升用户体验
- 更新多个组件的样式以适应不同屏幕,确保一致性和可读性
- 调整字体和边距,优化布局响应性
1 parent 7acbf9b9
......@@ -285,6 +285,14 @@ async function imgTransformBase64(imgList: Array<any>= [], keyList: string[]): P
/** 转 base64 */
async function getBase64(url: string): Promise<string> {
function isRequestableUrl(value: string): boolean {
if (value == null || value == "") return false;
const trimmed = value.trim();
if (trimmed == "") return false;
if (trimmed.startsWith("data:image/")) return false;
return /^https?:\/\//.test(trimmed);
}
function isProbablyBase64(raw: string): boolean {
if (raw == null || raw == "") return false;
const cleaned = raw.replace(/\s/g, "");
......@@ -293,6 +301,10 @@ async function getBase64(url: string): Promise<string> {
return /^[A-Za-z0-9+/=]+$/.test(cleaned);
}
if (!isRequestableUrl(url)) {
return url;
}
return new Promise((resolve, reject) => {
uni.request({
url,
......
......@@ -281,10 +281,10 @@ function selectBrand(item: any, index: number): void {
}
}
watch(watchStatus.value, () => {
watch(watchStatus, () => {
close();
}, { immediate: true });
watch(updateView.value, ()=>{
watch(updateView, () => {
const carBrandListData = storage.get("carBrandList");
carBrandList.value = carBrandListData != null ? (carBrandListData as Array<any>) : [];
}, { immediate: true, deep: true });
......
<template>
<view class="form-add-root">
<!-- 自定义导航页:按窗口安全区预留顶部,避免状态栏/刘海与首屏重叠 -->
<view class="reception-safe-top-spacer" :style="receptionSafeTopSpacerStyle"></view>
<view class="form-add-wrap">
<view class="form-add-header">
<text class="form-add-title">客户档案</text>
......@@ -124,7 +126,7 @@
</template>
<script setup lang="uts">
import { ref, watch, nextTick, computed } from 'vue'
import { ref, watch, nextTick, computed, onMounted, onUnmounted } from 'vue'
import { ComponentPublicInstance } from 'vue'
import CarBrands from '@/components/CarBrands.uvue'
import SenceSelect from './SenceSelect.uvue'
......@@ -189,6 +191,50 @@ function getEmptyForm(): FormDataModel {
const formData = ref<FormDataModel>(getEmptyForm())
const submitLock = ref(false)
/** 顶部安全区占位(px):与 system 状态栏/刘海对齐,随窗口信息刷新 */
const receptionPageInsetTopPx = ref(0)
const receptionSafeTopSpacerStyle = computed((): UTSJSONObject => {
return {
height: `${receptionPageInsetTopPx.value}px`,
width: '100%',
} as UTSJSONObject
})
function syncReceptionSafeTopSpacer(): void {
// 必须用 uni.getWindowInfo():不同端返回字段略有差异
const info = uni.getWindowInfo()
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
}
}
let receptionFormLayoutPollId: number | null = null
const RECEPTION_FORM_LAYOUT_POLL_MS = 400
// 到店日期选择器
const datePickerShow = ref(false)
const arrivalDateValue = ref<string | number>('')
......@@ -651,6 +697,19 @@ async function handleSubmit(): Promise<void> {
submitLock.value = false
}
}
onMounted(() => {
syncReceptionSafeTopSpacer()
receptionFormLayoutPollId = setInterval(syncReceptionSafeTopSpacer, RECEPTION_FORM_LAYOUT_POLL_MS)
})
onUnmounted(() => {
const tid = receptionFormLayoutPollId
if (tid != null) {
clearInterval(tid)
receptionFormLayoutPollId = null
}
})
</script>
<style lang="scss" scoped>
......@@ -665,10 +724,16 @@ async function handleSubmit(): Promise<void> {
background-color: #ffffff;
}
.reception-safe-top-spacer {
width: 100%;
flex-shrink: 0;
}
.form-add-wrap {
display: flex;
flex-direction: column;
height: 100%;
flex: 1;
min-height: 0;
padding: 24px 24px 0;
padding-bottom: 24px;
overflow: hidden;
......
<template>
<view class="form-detail-root">
<!-- 自定义导航页:按窗口安全区预留顶部,避免状态栏/刘海与首屏重叠 -->
<view class="reception-safe-top-spacer" :style="receptionSafeTopSpacerStyle"></view>
<view class="form-detail-top-bar">
<view class="form-detail-back-btn" @click="handleClose">
<un-icon name="arrow-left"></un-icon>
......@@ -70,7 +72,7 @@
</template>
<script setup lang="uts">
import { ref, computed, onMounted, nextTick, watch } from 'vue'
import { ref, computed, onMounted, onUnmounted, nextTick, watch } from 'vue'
import { findVisitsInfo } from '@/api/receiption.uts'
import { getMaterialResponsePage } from '@/api/customer-api.uts'
import { storage } from '@/utils/storage.uts'
......@@ -89,6 +91,44 @@ type GoodsCardItem = {
/** 顶部返回栏占位(与 updateLayoutHeights 内扣减一致) */
const FORM_DETAIL_TOP_BAR_PX = 48
/** 顶部安全区占位(px):与系统状态栏/刘海对齐,随窗口信息刷新 */
const receptionPageInsetTopPx = ref(0)
const receptionSafeTopSpacerStyle = computed((): UTSJSONObject => {
return {
height: `${receptionPageInsetTopPx.value}px`,
width: '100%',
} as UTSJSONObject
})
function calcReceptionSafeTopInsetPx(info: GetWindowInfoResult): number {
// 自定义导航:预留顶部安全区,避免与状态栏/刘海重叠(优先 safeAreaInsets.top)
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)
}
}
return topInset
}
const props = withDefaults(
defineProps<{
show?: boolean
......@@ -117,8 +157,10 @@ function updateLayoutHeights(): void {
const info = uni.getWindowInfo()
const wh = info.windowHeight > 0 ? info.windowHeight : info.screenHeight
const fullH = wh > 0 ? wh : 667
// 全屏覆盖层内:内容区 = 窗口高度 − 顶部返回栏
const contentH = fullH - FORM_DETAIL_TOP_BAR_PX
// 全屏覆盖层内:内容区 = 窗口高度 − 顶部安全区 − 顶部返回栏
const topInset = calcReceptionSafeTopInsetPx(info)
receptionPageInsetTopPx.value = topInset
const contentH = fullH - FORM_DETAIL_TOP_BAR_PX - topInset
wrapHeightPx.value = contentH > 200 ? contentH : 200
const scrollH = wrapHeightPx.value - FORM_DETAIL_VERTICAL_RESERVE
scrollAreaHeightPx.value = scrollH > 160 ? scrollH : 160
......@@ -136,8 +178,15 @@ const scrollViewStyle = computed((): UTSJSONObject => {
} as UTSJSONObject
})
// uview-unix 在部分端/旋转时安全区会变化;用轮询兜底刷新布局
const FORM_DETAIL_LAYOUT_POLL_MS = 400
let formDetailLayoutPollId: number | null = null
onMounted(() => {
updateLayoutHeights()
formDetailLayoutPollId = setInterval(() => {
updateLayoutHeights()
}, FORM_DETAIL_LAYOUT_POLL_MS)
})
/** UTS 无法为 toRef(props,'show') 推断泛型;用显式 boolean 的 computed 再 watch(同 CustomPopup) */
......@@ -153,6 +202,14 @@ watch(showForLayout, (visible: boolean) => {
}
})
onUnmounted(() => {
const tid = formDetailLayoutPollId
if (tid != null) {
clearInterval(tid)
formDetailLayoutPollId = null
}
})
function fieldStr(data: UTSJSONObject, key: string): string {
const v = data[key]
if (v == null) {
......@@ -688,6 +745,11 @@ function handleClose(): void {
background-color: #ffffff;
}
.reception-safe-top-spacer {
width: 100%;
flex-shrink: 0;
}
.form-detail-top-bar {
display: flex;
flex-direction: row;
......
......@@ -191,7 +191,7 @@ function onCardClick(item: UTSJSONObject): void {
background-color: rgba(255, 255, 255, 0.7);
border: 1px solid rgba(255, 255, 255, 0.4);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
border-radius: 32px;
border-radius: 16px;
flex-direction: column;
}
......
<template>
<view class="detail-container">
<!-- 自定义导航页:按窗口安全区预留顶部,避免状态栏/刘海与首屏重叠 -->
<view class="reception-safe-top-spacer" :style="receptionSafeTopSpacerStyle"></view>
<!-- 顶部返回按钮:用于关闭该详情组件(由父级处理 close 事件) -->
<view class="detail-header">
<view class="back-btn" @click="onBack">
......@@ -177,7 +179,7 @@
</template>
<script setup lang="uts">
import { computed, defineExpose, onUnmounted, ref, watch } from "vue";
import { computed, defineExpose, onMounted, onUnmounted, ref, watch } from "vue";
import { findCheckResultByBatchId, getAiagent, getShortUrl } from "@/api/receiption.uts";
import CustomEmpty from "@/components/CustomEmpty/index.uvue";
import DetailData from "./DetailData.uvue";
......@@ -1268,11 +1270,70 @@ 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;
}
}
const RECEPTION_DETAIL_LAYOUT_POLL_MS = 400;
let receptionDetailLayoutPollId: number | null = null;
onMounted((): void => {
syncReceptionSafeTopSpacer();
receptionDetailLayoutPollId = setInterval(syncReceptionSafeTopSpacer, RECEPTION_DETAIL_LAYOUT_POLL_MS);
});
onUnmounted((): void => {
const ctx = localAudioCtx;
ctx.stop();
ctx.destroy();
localAudioPlaying.value = false;
// 清理安全区轮询
const tid = receptionDetailLayoutPollId;
if (tid != null) {
clearInterval(tid);
receptionDetailLayoutPollId = null;
}
});
const pageInfo = uni.getWindowInfo();
......@@ -1292,6 +1353,7 @@ defineExpose({
flex-direction: column;
width: 100%;
height: 100%;
min-height: 0;
background-color: #F8FAFC;
}
......@@ -1303,7 +1365,12 @@ defineExpose({
width: 100%;
box-sizing: border-box;
padding-left: 8px;
margin-top: 5px;
margin-top: 0;
}
.reception-safe-top-spacer {
width: 100%;
flex-shrink: 0;
}
.back-btn {
......@@ -1320,6 +1387,7 @@ defineExpose({
flex-direction: column;
flex: 1;
width: 100%;
min-height: 0;
}
/* ── 客户卡片 ───────────────────────────────────────────────────────────────── */
......
......@@ -562,7 +562,7 @@ defineExpose({
.panel-close-text {
font-size: 16px;
font-weight: 300;
font-weight: 400;
color: #94a3b8;
line-height: 16px;
}
......
......@@ -79,7 +79,7 @@
</view>
</view>
<view v-else class="swiper-loading">
<un-skeleton :loading="true" :animate="true" title avatar rows="6"></un-skeleton>
<un-skeleton :loading="true" :animate="true" rows="6"></un-skeleton>
</view>
</template>
......@@ -506,3 +506,195 @@ defineExpose({
color: #4673ff;
}
</style>
.swiper-custom-content {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.package-swiper {
flex: 1;
width: 100%;
}
.swiper-bg {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: -1;
}
.swiper-name {
padding-top: var(--l-spacing-lg);
text-indent: 67px;
color: #333;
font-size: var(--l-font-base);
font-weight: 500;
}
.swiper-content-box {
margin: var(--l-spacing-md) var(--l-spacing-xl) 0;
height: 132px;
position: relative;
}
.swiper-content-box .price,
.swiper-content-box .briefIntroduction {
position: absolute;
}
.price-1 {
color: #999;
font-size: 10px;
left: var(--l-spacing-xl);
top: 32px;
width: 97px;
text-align: center;
}
.price-1 .num {
color: #333;
font-size: var(--l-font-base);
font-weight: 700;
display: flex;
flex-direction: row;
justify-content: center;
}
.price-1 .unit {
margin-right: 4px;
}
.price-2 {
left: 129px;
top: 48px;
width: 94px;
color: #ff4747;
font-size: var(--l-font-lg);
font-weight: 700;
display: flex;
flex-direction: row;
justify-content: center;
}
.price-3 {
top: 27px;
left: 228px;
color: #999;
font-size: 14px;
width: 148px;
text-align: center;
}
.price-3 .num {
color: #ff4747;
font-size: 22px;
font-weight: 700;
display: flex;
flex-direction: row;
justify-content: center;
}
.price-3 .unit {
margin-right: 8px;
}
.briefIntroduction {
left: 0;
top: 106px;
color: #666;
font-size: 12px;
width: 100%;
text-align: center;
}
.swiper-btn {
color: #4673ff;
font-size: 13px;
text-align: center;
margin-top: var(--l-spacing-md);
}
.swiper-dots {
display: flex;
flex-direction: row;
justify-content: center;
padding: var(--l-spacing-sm) 0;
}
.dot {
width: 8px;
height: 8px;
border-radius: 4px;
background: #ccc;
margin: 0 4px;
}
.dot.active {
background: #4673ff;
}
.swiper-empty,
.swiper-loading {
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.empty-text {
font-size: var(--l-font-sm);
color: #999;
}
.detail-content {
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.detail-title {
font-size: var(--l-font-2xl);
color: #333;
}
.package-detail-box {
padding-bottom: 50px;
margin: 0 var(--l-spacing-xl);
}
.package-box {
border-radius: var(--l-radius-xl);
background: #ffffff;
box-shadow: 0 6px 24px rgba(44, 102, 247, 0.15);
margin-bottom: var(--l-spacing-xl);
box-sizing: border-box;
padding: var(--l-spacing-xl);
}
.package-name {
color: #333;
font-size: var(--l-font-xl);
font-weight: 500;
line-height: 28px;
margin-bottom: var(--l-spacing-md);
}
.package-content {
line-height: 22px;
color: #333;
font-size: 14px;
}
.package-detail {
border: 2px solid rgba(70, 115, 255, 0.5);
background: rgba(70, 115, 255, 0.1);
box-shadow: 0 6px 24px rgba(44, 102, 247, 0.15);
}
.package-detail .package-name {
color: #4673ff;
}
......@@ -41,10 +41,8 @@
</view>
<view v-else class="loading-wrap">
<un-skeleton :animate="true"
avatar
:loading="true"
rows="8"
title>
rows="8">
</un-skeleton>
</view>
</template>
......
......@@ -3,10 +3,8 @@
<view>
<view v-if="!flag" class="skeleton-wrap">
<un-skeleton :animate="true"
avatar
:loading="true"
rows="6"
title>
rows="6">
</un-skeleton>
</view>
<view v-else class="box">
......
<template>
<view v-if="!flag" class="skeleton-wrap">
<un-skeleton :animate="true"
avatar
:loading="true"
rows="6"
title>
rows="6">
</un-skeleton>
</view>
<view v-if="flag" class="box">
......@@ -352,4 +350,3 @@ defineExpose({
border: 2px solid #347bff;
}
</style>
......@@ -17,10 +17,10 @@
<view v-if="mobile != ''"
class="icon"
@click="clearMobile">
<icon color="#000"
size="16"
type="clear">
</icon>
<uni-icons color="#000"
size="16"
type="clear">
</uni-icons>
</view>
</view>
......@@ -48,7 +48,7 @@
<button class="btn"
@click="login">
登录
<text class="btn-text">登录</text>
</button>
<view class="form-footer">
......
......@@ -87,11 +87,14 @@
justify-content: center;
width: 400px;
height: 56px;
background: #2c66f7;
border-radius: 28px;
}
.btn-text {
font-size: 20px;
font-weight: 600;
color: #fff;
background: #2c66f7;
border-radius: 28px;
}
.btn-disabled {
......@@ -128,16 +131,19 @@
bottom: 10px;
left: 50%;
transform: translate(-50%);
display: flex;
flex-direction: row;
align-items: center;
}
.app-code-text {
font-size: 12px;
line-height: 20px;
color: #999;
}
.app-code-text {
font-size: 12px;
line-height: 20px;
color: #999;
}
.icon-clone {
width: 12px;
height: 12px;
margin-left: 10px;
}
.icon-clone {
width: 12px;
height: 12px;
margin-left: 10px;
}
......@@ -60,7 +60,7 @@
</view>
</view>
<view v-else class="swiper-loading">
<un-skeleton :loading="true" :animate="true" title avatar rows="6"></un-skeleton>
<un-skeleton :loading="true" :animate="true" rows="6"></un-skeleton>
</view>
</template>
......@@ -439,7 +439,11 @@ async function getSoure(brandIdList: number[], subBrandIdList: number[]): Promis
let data: null | UTSJSONObject = null;
if (cachedData != null && cachedData !== "") {
try {
data = JSON.parse(cachedData as string) as UTSJSONObject;
if (typeof cachedData === "string") {
data = JSON.parse<UTSJSONObject>(cachedData as string);
} else if (cachedData instanceof UTSJSONObject) {
data = cachedData;
}
} catch (error) {
console.error("解析缓存数据失败:", error);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!