Commit 89a7a9cd by 岑成威

fix: 整理

1 parent 60c53226
<template>
<view class="app-navbar-root">
<!-- fixed 时占位,避免内容顶到屏幕最上(总高 = 安全区 + 导航条) -->
<view
v-if="fixed && placeholder"
class="app-navbar-placeholder"
:style="placeholderStyle"
></view>
<view class="app-navbar-shell" :class="shellClass" :style="shellStyle">
<view
v-if="safeAreaInsetTop"
class="app-navbar-safe-top"
:style="safeTopStyle"
></view>
<view
class="app-navbar-bar"
:class="barBorderClass"
:style="barRowStyle"
>
<view
v-if="showBack"
class="app-navbar-left"
@tap="onLeftTap"
>
<uni-icons
:color="leftIconColor"
:size="leftIconSizeNum"
:type="leftIcon"
></uni-icons>
<text
v-if="leftText != ''"
class="app-navbar-left-text"
>{{ leftText }}</text>
</view>
<view v-else class="app-navbar-left-spacer"></view>
<view class="app-navbar-center">
<slot name="center">
<text
v-if="title != ''"
class="app-navbar-title"
>{{ title }}</text>
</slot>
</view>
<view class="app-navbar-right">
<slot name="right"></slot>
</view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { computed, onMounted, ref } from "vue"
import { calcWindowTopInsetPx } from "@/utils/safe-area.uts"
import { router } from "@/utils/router.uts"
type AppNavbarProps = {
title?: string
/** 是否显示左侧返回区(图标 ± 文案) */
showBack?: boolean
/** 为 true 时点击左侧默认 router.back()(与项目路由钩子一致) */
autoBack?: boolean
safeAreaInsetTop?: boolean
bgColor?: string
border?: boolean
fixed?: boolean
placeholder?: boolean
/** 导航条内容区高度(px),不含安全区 */
barHeight?: number
leftIcon?: string
leftIconColor?: string
leftIconSize?: number
leftText?: string
/** fixed 时壳层 z-index;不传默认 200(详情页全屏时可传 0 压低层级) */
zIndex?: number | null
}
const props = withDefaults(defineProps<AppNavbarProps>(), {
title: "",
showBack: true,
autoBack: true,
safeAreaInsetTop: true,
bgColor: "#ffffff",
border: false,
fixed: false,
placeholder: false,
barHeight: 48,
leftIcon: "left",
leftIconColor: "#000000",
leftIconSize: 20,
leftText: "",
zIndex: null
})
const emit = defineEmits<{
leftClick: []
}>()
const insetTopPx = ref(0)
function refreshInset(): void {
insetTopPx.value = calcWindowTopInsetPx(uni.getWindowInfo())
}
onMounted(() => {
refreshInset()
})
const barHeightPx = computed((): number => {
const h = props.barHeight
return h > 0 ? h : 48
})
const totalHeightPx = computed((): number => {
const safe = props.safeAreaInsetTop ? insetTopPx.value : 0
return safe + barHeightPx.value
})
const placeholderStyle = computed((): UTSJSONObject => {
return {
height: `${totalHeightPx.value}px`,
width: "100%"
} as UTSJSONObject
})
const shellClass = computed((): string => {
return props.fixed ? "app-navbar-shell--fixed" : ""
})
const shellStyle = computed((): UTSJSONObject => {
const style = {
backgroundColor: props.bgColor,
width: "100%"
} as UTSJSONObject
if (props.fixed) {
style["position"] = "fixed"
style["top"] = "0"
style["left"] = "0"
const zi = props.zIndex
style["zIndex"] = zi != null ? zi : 200
}
return style
})
const safeTopStyle = computed((): UTSJSONObject => {
return {
height: `${insetTopPx.value}px`,
width: "100%"
} as UTSJSONObject
})
const barRowStyle = computed((): UTSJSONObject => {
return {
height: `${barHeightPx.value}px`,
width: "100%"
} as UTSJSONObject
})
const barBorderClass = computed((): string => {
return props.border ? "app-navbar-bar--border" : ""
})
const leftIconSizeNum = computed((): number => {
const s = props.leftIconSize
return s > 0 ? s : 20
})
function onLeftTap(): void {
emit("leftClick")
if (props.autoBack) {
router.back(null)
}
}
</script>
<style>
.app-navbar-root {
width: 100%;
display: flex;
flex-direction: column;
}
.app-navbar-placeholder {
flex-shrink: 0;
}
.app-navbar-shell {
display: flex;
flex-direction: column;
flex-shrink: 0;
}
.app-navbar-shell--fixed {
width: 100%;
}
.app-navbar-safe-top {
flex-shrink: 0;
width: 100%;
}
.app-navbar-bar {
display: flex;
flex-direction: row;
flex-shrink: 0;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding-left: 4px;
padding-right: 8px;
}
.app-navbar-bar--border {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #eeeeee;
}
.app-navbar-left {
width: 48px;
height: 100%;
display: flex;
flex-direction: row;
flex-shrink: 0;
align-items: center;
justify-content: center;
}
.app-navbar-left-text {
margin-left: 2px;
font-size: 15px;
color: #000000;
}
.app-navbar-left-spacer {
width: 48px;
flex-shrink: 0;
height: 100%;
}
.app-navbar-center {
flex: 1;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
overflow: hidden;
padding-left: 8px;
padding-right: 8px;
}
.app-navbar-title {
font-size: 17px;
font-weight: 500;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
}
.app-navbar-right {
min-width: 48px;
height: 100%;
display: flex;
flex-direction: row;
flex-shrink: 0;
align-items: center;
justify-content: flex-end;
}
</style>
...@@ -93,8 +93,8 @@ ...@@ -93,8 +93,8 @@
</scroll-view> </scroll-view>
<!-- 底部按钮 --> <!-- 底部按钮 -->
<view class="popup-footer"> <view class="popup-footer">
<view class="flex-1" style="margin-right: 12px;"> <view class="flex-1 popup-footer-item popup-footer-item-first">
<un-button :block="true" <un-button :block="true"
round="8px" round="8px"
size="large" size="large"
...@@ -554,8 +554,8 @@ defineExpose({ open, close }); ...@@ -554,8 +554,8 @@ defineExpose({ open, close });
} }
.portrait-wrapper { .portrait-wrapper {
width: 100vw; width: 100%;
max-height: 85vh; height: 85%;
border-radius: 20px 20px 0 0; border-radius: 20px 20px 0 0;
} }
...@@ -602,7 +602,6 @@ defineExpose({ open, close }); ...@@ -602,7 +602,6 @@ defineExpose({ open, close });
.content { .content {
width: 100%; width: 100%;
min-height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-bottom: 20px; padding-bottom: 20px;
...@@ -612,8 +611,7 @@ defineExpose({ open, close }); ...@@ -612,8 +611,7 @@ defineExpose({ open, close });
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding: 16px 20px; padding: 16px 20px;
padding-bottom: calc(24px + env(safe-area-inset-bottom)); /* 确保无论是否有安全区,底部都留有24px的间隔 */ padding-bottom: 24px;
gap: 16px;
flex-shrink: 0; flex-shrink: 0;
align-items: center; align-items: center;
background: #ffffff; background: #ffffff;
...@@ -622,6 +620,14 @@ defineExpose({ open, close }); ...@@ -622,6 +620,14 @@ defineExpose({ open, close });
z-index: 2; z-index: 2;
} }
.popup-footer-item {
width: 0;
}
.popup-footer-item-first {
margin-right: 16px;
}
.pop-tips { .pop-tips {
width: 100%; width: 100%;
background: rgba(44, 102, 247, 0.1); background: rgba(44, 102, 247, 0.1);
......
<template> <template>
<view class="layout-root" :class="[resolutionState.cssClass]"> <un-page class="layout-root layout-column-shell" :class="[resolutionState.cssClass]">
<slot /> <slot />
</view> </un-page>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
...@@ -11,8 +11,8 @@ import { resolutionState, useResolutionConfig } from "@/services/adapter/index.u ...@@ -11,8 +11,8 @@ import { resolutionState, useResolutionConfig } from "@/services/adapter/index.u
useResolutionConfig(); useResolutionConfig();
</script> </script>
<style scoped> <style>
.layout-root { .layout-column-shell {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
......
<template> <template>
<view class="layout-root" :class="[modeClass, resolutionClass, adapterClass]" :style="styleObj"> <view class="layout-root" :class="[modeClass, resolutionClass, adapterClass]" :style="styleObj">
<slot></slot> <slot></slot>
</view> </un-page>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
...@@ -79,8 +79,8 @@ onUnmounted(() => { ...@@ -79,8 +79,8 @@ onUnmounted(() => {
}) })
</script> </script>
<style scoped> <style>
.layout-root { .layout-root-shell {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
......
...@@ -171,7 +171,6 @@ ...@@ -171,7 +171,6 @@
background-size: cover; background-size: cover;
background-repeat: no-repeat; background-repeat: no-repeat;
z-index: -1; z-index: -1;
will-change: transform;
} }
.skeleton-box { .skeleton-box {
...@@ -218,4 +217,4 @@ ...@@ -218,4 +217,4 @@
height: 100% !important; height: 100% !important;
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -183,6 +183,5 @@ type TouchEvent = { ...@@ -183,6 +183,5 @@ type TouchEvent = {
left: 0; left: 0;
top: 0; top: 0;
transform-origin: center center; transform-origin: center center;
will-change: transform;
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -759,6 +759,7 @@ defineExpose({ ...@@ -759,6 +759,7 @@ defineExpose({
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
background: linear-gradient(180deg, rgba(240, 244, 255, 0.96), rgba(220, 230, 248, 0.92)); background: linear-gradient(180deg, rgba(240, 244, 255, 0.96), rgba(220, 230, 248, 0.92));
display: flex; display: flex;
flex-direction: row;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
overflow: hidden; overflow: hidden;
......
...@@ -82,7 +82,8 @@ ...@@ -82,7 +82,8 @@
"^layout-root$": "@/components/LayoutRoot/index.uvue", "^layout-root$": "@/components/LayoutRoot/index.uvue",
"^Layout$": "@/components/Layout/index.uvue", "^Layout$": "@/components/Layout/index.uvue",
"^segment-tab$": "@/pages/receptionCenter/SegmentTab.uvue", "^segment-tab$": "@/pages/receptionCenter/SegmentTab.uvue",
"^reception-detail$": "@/pages/receptionCenter/receptionDetail.uvue" "^reception-detail$": "@/pages/receptionCenter/receptionDetail.uvue",
"^app-navbar$": "@/components/AppNavbar/index.uvue",
} }
}, },
"globalStyle": { "globalStyle": {
......
...@@ -331,7 +331,7 @@ defineExpose({ ...@@ -331,7 +331,7 @@ defineExpose({
.swiper-name { .swiper-name {
padding-top: var(--l-spacing-lg); padding-top: var(--l-spacing-lg);
text-indent: 67px; padding-left: 67px;
color: #333; color: #333;
font-size: var(--l-font-base); font-size: var(--l-font-base);
font-weight: 500; font-weight: 500;
...@@ -530,7 +530,7 @@ defineExpose({ ...@@ -530,7 +530,7 @@ defineExpose({
.swiper-name { .swiper-name {
padding-top: var(--l-spacing-lg); padding-top: var(--l-spacing-lg);
text-indent: 67px; padding-left: 67px;
color: #333; color: #333;
font-size: var(--l-font-base); font-size: var(--l-font-base);
font-weight: 500; font-weight: 500;
......
...@@ -124,10 +124,6 @@ const open = (): void => { ...@@ -124,10 +124,6 @@ const open = (): void => {
inputFocus.value = true; inputFocus.value = true;
}; };
const back = (): void => {
uni.navigateBack();
};
const setStep = (index: number): void => { const setStep = (index: number): void => {
if (index == 2) return; if (index == 2) return;
if (stepIndex.value > index) { if (stepIndex.value > index) {
...@@ -189,6 +185,7 @@ const chooseMerchant = (userInfo: any): void => { ...@@ -189,6 +185,7 @@ const chooseMerchant = (userInfo: any): void => {
padding-top: 0; padding-top: 0;
padding-bottom: 0; padding-bottom: 0;
box-sizing: border-box; box-sizing: border-box;
display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
display: flex; display: flex;
......
...@@ -308,7 +308,6 @@ ...@@ -308,7 +308,6 @@
top: 0; top: 0;
left: 0; left: 0;
visibility: hidden; visibility: hidden;
will-change: transform;
} }
.swipe-stack-show { .swipe-stack-show {
position: absolute; position: absolute;
......
...@@ -2,16 +2,13 @@ ...@@ -2,16 +2,13 @@
<layout-root> <layout-root>
<view :key="dateilKey" <view :key="dateilKey"
class="detail-box"> class="detail-box">
<view class="nav-bar" <app-navbar fixed
:style="{ 'z-index': backZindex }"> :placeholder="false"
<view class="back" bg-color="transparent"
@tap="back"> :border="false"
<uni-icons color="#000" :auto-back="false"
:size="20" :z-index="backZindex"
type="left"> @left-click="back" />
</uni-icons>
</view>
</view>
<ModuleSwipeStack v-model:current-id="id" <ModuleSwipeStack v-model:current-id="id"
:draw-status="drawStatus" :draw-status="drawStatus"
:items="moduleList" :items="moduleList"
...@@ -598,22 +595,6 @@ onBackPress((options: OnBackPressOptions) => { ...@@ -598,22 +595,6 @@ onBackPress((options: OnBackPressOptions) => {
height: 100%; height: 100%;
margin: 0 auto; margin: 0 auto;
} }
.nav-bar {
position: fixed;
width: 100%;
height: 48px;
left: 0;
top: 24px;
z-index: 9;
.back {
width: 48px;
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
}
.pen-box { .pen-box {
position: fixed; position: fixed;
right: 20px; right: 20px;
......
...@@ -112,7 +112,7 @@ function onPlayRecord(): void { ...@@ -112,7 +112,7 @@ function onPlayRecord(): void {
<style scoped lang="scss"> <style scoped lang="scss">
.page { .page {
width: 100%; width: 100%;
min-height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background: #f5f7fa; background: #f5f7fa;
......
...@@ -1388,7 +1388,6 @@ defineExpose({ ...@@ -1388,7 +1388,6 @@ defineExpose({
border-radius: 12px; border-radius: 12px;
background-color: #ffffff; background-color: #ffffff;
background-image: linear-gradient(to bottom, #f0f6ff 0%, #ffffff 100%); background-image: linear-gradient(to bottom, #f0f6ff 0%, #ffffff 100%);
backdrop-filter: blur(8px);
box-shadow: inset 0 0 8px 0 #ffffff; box-shadow: inset 0 0 8px 0 #ffffff;
border-width: 1px; border-width: 1px;
border-style: solid; border-style: solid;
...@@ -1428,7 +1427,6 @@ defineExpose({ ...@@ -1428,7 +1427,6 @@ defineExpose({
font-size: 14px; font-size: 14px;
color: #9CA3AF; color: #9CA3AF;
margin-left: 8px; margin-left: 8px;
text-decoration: underline;
} }
.tag-row { .tag-row {
...@@ -1621,7 +1619,6 @@ defineExpose({ ...@@ -1621,7 +1619,6 @@ defineExpose({
border-color: #FFFFFF; border-color: #FFFFFF;
opacity: 1; opacity: 1;
background: #ffffff33; background: #ffffff33;
backdrop-filter: blur(8px);
box-shadow: inset 0 0 8px 0 #ffffff; box-shadow: inset 0 0 8px 0 #ffffff;
overflow: hidden; overflow: hidden;
} }
...@@ -1971,7 +1968,6 @@ defineExpose({ ...@@ -1971,7 +1968,6 @@ defineExpose({
.bubble-text { .bubble-text {
font-size: 14px; font-size: 14px;
color: #374151; color: #374151;
word-break: break-all;
} }
.bubble-text-selected { .bubble-text-selected {
...@@ -2033,7 +2029,6 @@ defineExpose({ ...@@ -2033,7 +2029,6 @@ defineExpose({
font-size: 12px; font-size: 12px;
color: #4B5563; color: #4B5563;
line-height: 1.5; line-height: 1.5;
word-break: break-all;
} }
/* ── 底部占位 ───────────────────────────────────────────────────────────────── */ /* ── 底部占位 ───────────────────────────────────────────────────────────────── */
......
...@@ -95,6 +95,14 @@ export function isEmpty(value: any): boolean { ...@@ -95,6 +95,14 @@ export function isEmpty(value: any): boolean {
*/ */
export const nullValues = [null, ""]; export const nullValues = [null, ""];
export function keys(object: any): string[] {
if (!isObject(object)) {
return [];
}
return UTSJSONObject.keys(object as UTSJSONObject);
}
/** /**
* 格式化日期时间 * 格式化日期时间
*/ */
...@@ -214,7 +222,8 @@ export function map<T, U>(array: T[], iteratee: (item: T, index: number) => U): ...@@ -214,7 +222,8 @@ export function map<T, U>(array: T[], iteratee: (item: T, index: number) => U):
if (!isArray(array)) return result; if (!isArray(array)) return result;
for (const [i, element] of array.entries()) { for (let i = 0; i < array.length; i++) {
const element = array[i];
result.push(iteratee(element, i)); result.push(iteratee(element, i));
} }
...@@ -233,7 +242,8 @@ export function reduce<T, U>( ...@@ -233,7 +242,8 @@ export function reduce<T, U>(
if (!isArray(array)) return initialValue; if (!isArray(array)) return initialValue;
let accumulator: U = initialValue; let accumulator: U = initialValue;
for (const [i, element] of array.entries()) { for (let i = 0; i < array.length; i++) {
const element = array[i];
accumulator = iteratee(accumulator, element, i); accumulator = iteratee(accumulator, element, i);
} }
...@@ -247,7 +257,8 @@ export function reduce<T, U>( ...@@ -247,7 +257,8 @@ export function reduce<T, U>(
export function every<T>(array: T[], predicate: (value: T, index: number) => boolean): boolean { export function every<T>(array: T[], predicate: (value: T, index: number) => boolean): boolean {
if (!isArray(array)) return true; if (!isArray(array)) return true;
for (const [i, element] of array.entries()) { for (let i = 0; i < array.length; i++) {
const element = array[i];
if (!predicate(element, i)) { if (!predicate(element, i)) {
return false; return false;
} }
...@@ -263,7 +274,8 @@ export function every<T>(array: T[], predicate: (value: T, index: number) => boo ...@@ -263,7 +274,8 @@ export function every<T>(array: T[], predicate: (value: T, index: number) => boo
export function some<T>(array: T[], predicate: (value: T, index: number) => boolean): boolean { export function some<T>(array: T[], predicate: (value: T, index: number) => boolean): boolean {
if (!isArray(array)) return false; if (!isArray(array)) return false;
for (const [i, element] of array.entries()) { for (let i = 0; i < array.length; i++) {
const element = array[i];
if (predicate(element, i)) { if (predicate(element, i)) {
return true; return true;
} }
...@@ -446,7 +458,8 @@ export function remove<T>(array: T[], predicate: (value: T, index: number) => bo ...@@ -446,7 +458,8 @@ export function remove<T>(array: T[], predicate: (value: T, index: number) => bo
const result: T[] = []; const result: T[] = [];
for (const [i, element] of array.entries()) { for (let i = 0; i < array.length; i++) {
const element = array[i];
if (!predicate(element, i)) { if (!predicate(element, i)) {
result.push(element); result.push(element);
} }
...@@ -463,7 +476,8 @@ export function forEach<T>(data: T[], iteratee: (value: T, index: number) => voi ...@@ -463,7 +476,8 @@ export function forEach<T>(data: T[], iteratee: (value: T, index: number) => voi
if (isArray(data)) { if (isArray(data)) {
const array = data as T[]; const array = data as T[];
for (const [i, element] of array.entries()) { for (let i = 0; i < array.length; i++) {
const element = array[i];
if (element != null) { if (element != null) {
iteratee(element, i); iteratee(element, i);
} }
...@@ -478,7 +492,8 @@ export function forEach<T>(data: T[], iteratee: (value: T, index: number) => voi ...@@ -478,7 +492,8 @@ export function forEach<T>(data: T[], iteratee: (value: T, index: number) => voi
export function find<T>(array: T[], predicate: (value: T, index: number) => boolean): null | T { export function find<T>(array: T[], predicate: (value: T, index: number) => boolean): null | T {
if (!isArray(array)) return null; if (!isArray(array)) return null;
for (const [i, element] of array.entries()) { for (let i = 0; i < array.length; i++) {
const element = array[i];
if (predicate(element, i)) { if (predicate(element, i)) {
return element; return element;
} }
......
...@@ -80,16 +80,17 @@ PAGES.forEach((e) => { ...@@ -80,16 +80,17 @@ PAGES.forEach((e) => {
}); });
// TABS 用于存储 tabBar 配置项 // TABS 用于存储 tabBar 配置项
// export let TABS: TabBarItem[] = []; export let TABS: TabBarItem[] = [];
// 如果 tabBar 配置存在且列表不为空,则初始化 TABS // Android 端静态初始化阶段,tabBar 可能为空,需先判空再访问 list
// if (ctx.tabBar.list != null) { const tabBar = ctx.tabBar;
// TABS = ctx.tabBar.list; if (tabBar != null && tabBar.list != null) {
TABS = [...tabBar.list];
// // 确保每个 tabBar 页面的路径都以 "/" 开头 // 确保每个 tabBar 页面的路径都以 "/" 开头
// TABS.forEach((e) => { TABS.forEach((e) => {
// if (!e.pagePath.startsWith("/")) { if (!e.pagePath.startsWith("/")) {
// e.pagePath = "/" + e.pagePath; e.pagePath = "/" + e.pagePath;
// } }
// }); });
// } }
...@@ -306,7 +306,15 @@ export class Router { ...@@ -306,7 +306,15 @@ export class Router {
if (path == "/") { if (path == "/") {
path = this.defaultPath("home"); path = this.defaultPath("home");
} }
return !isNull(TABS.find((e) => path == e.pagePath));
for (let i = 0; i < TABS.length; i++) {
const tab = TABS[i];
if (path == tab.pagePath) {
return true;
}
}
return false;
} }
// 判断是否为登录页 // 判断是否为登录页
......
/**
* 与窗口安全区/状态栏对齐的顶部 inset(px),用于自定义导航栏占位。
* 优先 safeAreaInsets.top,其次 safeArea.top,最后 statusBarHeight。
*/
export function calcWindowTopInsetPx(info: GetWindowInfoResult): number {
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
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!