Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4c166a8a
authored
Apr 10, 2026
by
岑成威
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix:tab切换
1 parent
99d3a13c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
887 additions
and
96 deletions
apps/uniappX/uniapp-x-tape/components/HomeFrame/MainTabShellLandscape.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/MainTabShellPortrait.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/SceneShell.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/Tabbar.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/TabbarLandscape.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/TabbarPortrait.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/index.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/presets/HomeMainTab.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/presets/MyCenterTab.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/styles/common.scss
apps/uniappX/uniapp-x-tape/components/HomeFrame/tabbarShared.uts
apps/uniappX/uniapp-x-tape/pages/boutique/components/BoutiqueHomePanel.uvue
apps/uniappX/uniapp-x-tape/pages/equity/components/EquityHomePanel.uvue
apps/uniappX/uniapp-x-tape/pages/index/index.uvue
apps/uniappX/uniapp-x-tape/pages/person/myCenter.uvue
apps/uniappX/uniapp-x-tape/pages/receptionCenter/center.uvue
apps/uniappX/uniapp-x-tape/pages/usedCar/components/UsedCarHomePanel.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/MainTabShellLandscape.uvue
0 → 100644
View file @
4c166a8
<template>
<view class="main-tab-shell-root">
<view class="main-tab-shell-body main-tab-shell-body-landscape">
<HomeFrameTabbarLandscape :adapter-class-name="adapterClassName"
:user-name="userName"
:landscape-tabbar-root-style="landscapeTabbarRootStyle"
:landscape-tabbar-inner-height="landscapeTabbarInnerHeight"
:landscape-tabbar-icon-size="landscapeTabbarIconSize"
:current-tab-index="currentTabIndex"
:scene-type-list="sceneTypeList"
:show-scene-popup="showScenePopup"
:show-setting="showSetting"
@tab-change="onTabChange"
@scene-popup-visible="onScenePopupVisible"
@setting-visible="onSettingVisible"
@scene-change="onSceneChange"
@setting="onSetting"
@choose-scene="onChooseScene"
@jump-person-center="jumpPersonCenter" />
<view class="main-tab-shell-slot main-tab-shell-slot-landscape">
<slot :user-info="slotUserInfo"></slot>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { computed } from "vue";
import HomeFrameTabbarLandscape from "./TabbarLandscape.uvue";
import type { HomeFrameTabbarSource } from "./tabbarShared.uts";
import { useHomeFrameTabbar } from "./tabbarShared.uts";
type MainTabShellSlotProps = {
userInfo: UTSJSONObject
};
type MainTabShellSlots = {
default(props: MainTabShellSlotProps): any
};
defineSlots<MainTabShellSlots>();
const props = defineProps<{
activeTabIndex: number
userInfo?: null | UTSJSONObject
}>();
const tabbarSource: HomeFrameTabbarSource = {
getAdapterClass: (): null | string => null,
getTabIndex: (): number => props.activeTabIndex,
getUserInfo: (): null | UTSJSONObject => props.userInfo as null | UTSJSONObject
};
const _tabbar = useHomeFrameTabbar(tabbarSource);
const adapterClassName = _tabbar.adapterClassName;
const userName = _tabbar.userName;
const landscapeTabbarRootStyle = _tabbar.landscapeTabbarRootStyle;
const landscapeTabbarInnerHeight = _tabbar.landscapeTabbarInnerHeight;
const landscapeTabbarIconSize = _tabbar.landscapeTabbarIconSize;
const currentTabIndex = _tabbar.currentTabIndex;
const sceneTypeList = _tabbar.sceneTypeList;
const showScenePopup = _tabbar.showScenePopup;
const showSetting = _tabbar.showSetting;
const onTabChange = _tabbar.onTabChange;
const onScenePopupVisible = _tabbar.onScenePopupVisible;
const onSettingVisible = _tabbar.onSettingVisible;
const onSceneChange = _tabbar.onSceneChange;
const onSetting = _tabbar.onSetting;
const onChooseScene = _tabbar.onChooseScene;
const jumpPersonCenter = _tabbar.jumpPersonCenter;
const slotUserInfo = computed((): UTSJSONObject => {
const u = props.userInfo;
return u != null ? u : ({} as UTSJSONObject);
});
</script>
<style scoped lang="scss">
.main-tab-shell-root {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
min-height: 0;
min-width: 0;
}
.main-tab-shell-body-landscape {
flex: 1;
display: flex;
flex-direction: row;
width: 100%;
height: 100%;
min-height: 0;
min-width: 0;
overflow: hidden;
}
.main-tab-shell-slot-landscape {
flex: 1 1 0%;
min-width: 0;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
</style>
apps/uniappX/uniapp-x-tape/components/HomeFrame/MainTabShellPortrait.uvue
0 → 100644
View file @
4c166a8
<template>
<view class="main-tab-shell-root">
<view class="main-tab-shell-body main-tab-shell-body-portrait">
<view class="main-tab-shell-slot main-tab-shell-slot-portrait">
<slot :user-info="slotUserInfo"></slot>
</view>
<HomeFrameTabbarPortrait :adapter-class-name="adapterClassName"
:is-pad-portrait-mode="isPadPortraitMode"
:tabbar-height="tabbarHeight"
:tabbar-icon-size="tabbarIconSize"
:current-tab-index="currentTabIndex"
:scene-type-list="sceneTypeList"
:show-scene-popup="showScenePopup"
:show-setting="showSetting"
@tab-change="onTabChange"
@scene-popup-visible="onScenePopupVisible"
@setting-visible="onSettingVisible"
@choose-scene="onChooseScene" />
</view>
</view>
</template>
<script setup lang="uts">
import { computed } from "vue";
import HomeFrameTabbarPortrait from "./TabbarPortrait.uvue";
import type { HomeFrameTabbarSource } from "./tabbarShared.uts";
import { useHomeFrameTabbar } from "./tabbarShared.uts";
type MainTabShellSlotProps = {
userInfo: UTSJSONObject
};
type MainTabShellSlots = {
default(props: MainTabShellSlotProps): any
};
defineSlots<MainTabShellSlots>();
const props = defineProps<{
activeTabIndex: number
userInfo?: null | UTSJSONObject
}>();
const tabbarSource: HomeFrameTabbarSource = {
getAdapterClass: (): null | string => null,
getTabIndex: (): number => props.activeTabIndex,
getUserInfo: (): null | UTSJSONObject => props.userInfo as null | UTSJSONObject
};
const _tabbar = useHomeFrameTabbar(tabbarSource);
const adapterClassName = _tabbar.adapterClassName;
const isPadPortraitMode = _tabbar.isPadPortraitMode;
const tabbarHeight = _tabbar.tabbarHeight;
const tabbarIconSize = _tabbar.tabbarIconSize;
const currentTabIndex = _tabbar.currentTabIndex;
const sceneTypeList = _tabbar.sceneTypeList;
const showScenePopup = _tabbar.showScenePopup;
const showSetting = _tabbar.showSetting;
const onTabChange = _tabbar.onTabChange;
const onScenePopupVisible = _tabbar.onScenePopupVisible;
const onSettingVisible = _tabbar.onSettingVisible;
const onChooseScene = _tabbar.onChooseScene;
const slotUserInfo = computed((): UTSJSONObject => {
const u = props.userInfo;
return u != null ? u : ({} as UTSJSONObject);
});
</script>
<style scoped lang="scss">
.main-tab-shell-root {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
min-height: 0;
min-width: 0;
}
.main-tab-shell-body-portrait {
flex: 1;
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
min-height: 0;
min-width: 0;
overflow: hidden;
}
.main-tab-shell-slot-portrait {
flex: 1 1 0%;
min-height: 0;
min-width: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
</style>
apps/uniappX/uniapp-x-tape/components/HomeFrame/SceneShell.uvue
View file @
4c166a8
<template>
<template>
<!-- 物理 tab 三页共用:自定义 Tabbar + 默认槽(首页 / 接待 / 我的由 pages 填入不同主体) -->
<!-- 物理 tab 三页共用:横/竖两套壳 + 默认槽;方向由 updateOrientation + useOrientation 驱动 -->
<view class="home-frame-container scene-shell-root"
<MainTabShellPortrait v-if="shellIsPortrait"
:class="[modeClass, resolutionClass, adapterClass]">
:active-tab-index="props.activeTabIndex"
<view class="home-content">
:user-info="userInfo">
<HomeFrameTabbar :adapter-class="adapterClass"
<template #default="{ userInfo: u }">
:tab-index="activeTabIndex"
<slot :user-info="u"></slot>
:user-info="userInfo" />
</template>
<view class="right-side">
</MainTabShellPortrait>
<slot :user-info="userInfo"></slot>
<MainTabShellLandscape v-else
</view>
:active-tab-index="props.activeTabIndex"
</view>
:user-info="userInfo">
</view>
<template #default="{ userInfo: u }">
<slot :user-info="u"></slot>
</template>
</MainTabShellLandscape>
</template>
</template>
<script setup lang="uts">
<script setup lang="uts">
import { computed, defineExpose,
r
ef } from "vue";
import { computed, defineExpose,
onMounted, onResize, ref, type R
ef } from "vue";
import { cssClassRef, useResolutionConfig } from "@/services/adapter";
import { updateOrientation, useOrientation } from "@/services/adapter/hooks/index.uts";
import { layoutService } from "@/services/LayoutService.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";
import HomeFrameTabbar from "./Tabbar.uvue";
import MainTabShellLandscape from "./MainTabShellLandscape.uvue";
import MainTabShellPortrait from "./MainTabShellPortrait.uvue";
type SceneShellSlotProps = {
type SceneShellSlotProps = {
userInfo: UTSJSONObject
userInfo: UTSJSONObject
...
@@ -39,22 +42,20 @@ const props = defineProps<{
...
@@ -39,22 +42,20 @@ const props = defineProps<{
activeTabIndex: number
activeTabIndex: number
}>();
}>();
useResolutionConfig();
updateOrientation();
const orientationHook = useOrientation();
const
adapterClass = computed((): string
=> {
const
shellIsPortrait = computed((): boolean
=> {
const
cls = cssClassRef.value
;
const
ip = orientationHook.isPortrait as Ref<boolean>
;
return
cls != null ? (cls as string) : ""
;
return
ip.value == true
;
});
});
const modeClass = computed((): string => {
onMounted((): void => {
const modeRef = layoutService.getCurrentMode();
updateOrientation();
const m = modeRef.value;
return m == "portrait" ? "mode-portrait" : "mode-landscape";
});
});
const resolutionClass = computed((): string => {
onResize((_res: any): void => {
const bucket = layoutService.getResolutionBucket();
updateOrientation();
return `res-${bucket}`;
});
});
const userInfo = ref<UTSJSONObject>({});
const userInfo = ref<UTSJSONObject>({});
...
@@ -69,6 +70,7 @@ function updateApp(): void {
...
@@ -69,6 +70,7 @@ function updateApp(): void {
onLoad((_options) => {
onLoad((_options) => {
requestRecordPermission();
requestRecordPermission();
hideNativeTabBar();
hideNativeTabBar();
updateOrientation();
});
});
onShow(() => {
onShow(() => {
...
@@ -79,7 +81,3 @@ defineExpose({
...
@@ -79,7 +81,3 @@ defineExpose({
updateApp
updateApp
});
});
</script>
</script>
<style scoped lang="scss">
@import "./styles/common.scss";
</style>
apps/uniappX/uniapp-x-tape/components/HomeFrame/Tabbar.uvue
View file @
4c166a8
This diff is collapsed.
Click to expand it.
apps/uniappX/uniapp-x-tape/components/HomeFrame/TabbarLandscape.uvue
0 → 100644
View file @
4c166a8
<template>
<view class="home-tabbar home-tabbar-landscape"
:class="[adapterClassName]">
<image class="home-tabbar-bg-img"
mode="aspectFill"
src="/static/images/home/left-bg.png" />
<view class="user-box user-box-clickable hf-landscape-user"
@click="emit('jumpPersonCenter')">
<view class="user-info">
<view class="user-avatar"></view>
<text class="user-name-text">{{ userName }}</text>
</view>
</view>
<view class="landscape-tabbar-wrap">
<view class="landscape-un-tabbar landscape-vertical-tabs"
:style="landscapeTabbarRootStyle">
<view v-for="(item, index) in tabs"
:key="index"
class="landscape-vertical-tabs__item"
:class="index === currentTabIndex ? 'landscape-vertical-tabs__item--active' : ''"
:style="tabRowStyle"
@click="onTabItemClick(index)">
<view class="landscape-vertical-tabs__inner">
<image class="landscape-vertical-tabs__icon"
mode="aspectFit"
:style="iconImageStyle"
:src="index === currentTabIndex ? item.iconSrcActive : item.iconSrcInactive" />
<text class="landscape-vertical-tabs__label">{{ item.label }}</text>
</view>
</view>
</view>
</view>
<view class="home-tabbar-footer flex-col hf-landscape-footer">
<view class="btn-placeholder" @tap="emit('sceneChange')"></view>
<view class="btn-placeholder" @tap="emit('setting')"></view>
</view>
<CenterPopup :list="sceneTypeList"
title="选择场景"
:visible="showScenePopup"
@choose="emit('chooseScene', $event)"
@update:visible="emit('scenePopupVisible', $event)" />
<SettingBox :visible="showSetting"
@update:visible="emit('settingVisible', $event)" />
</view>
</template>
<script setup lang="uts">
import { computed } from "vue";
import CenterPopup from "@/components/CenterPopup.uvue";
import SettingBox from "@/pages/person/SettingBox.uvue";
import { HOME_FRAME_TABS } from "./tabbarShared.uts";
const props = defineProps<{
adapterClassName: string
userName: string
landscapeTabbarRootStyle: string
landscapeTabbarInnerHeight: number
landscapeTabbarIconSize: number
currentTabIndex: number
sceneTypeList: UTSJSONObject[]
showScenePopup: boolean
showSetting: boolean
}>();
const emit = defineEmits<{
tabChange: [name: string | number]
scenePopupVisible: [v: boolean]
settingVisible: [v: boolean]
sceneChange: []
setting: []
chooseScene: [index: number]
jumpPersonCenter: []
}>();
const tabs = HOME_FRAME_TABS;
const iconImageStyle = computed((): any => {
const s = props.landscapeTabbarIconSize;
return {
width: `${s}px`,
height: `${s}px`
};
});
/** 与原 un-tabbar :height 一致,保证每项可点区域高度 */
const tabRowStyle = computed((): any => {
const h = props.landscapeTabbarInnerHeight;
return {
minHeight: `${h}px`
};
});
function onTabItemClick(index: number): void {
emit("tabChange", index);
}
</script>
<style scoped lang="scss">
@import "./styles/common.scss";
/* 横屏侧栏:用户区 / Tab / 底按钮同一竖直中轴 */
.hf-landscape-user {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
}
.hf-landscape-footer {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
}
/* 与原先 .landscape-un-tabbar 占位一致,内部强制纵向排列 item */
.landscape-vertical-tabs {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.landscape-vertical-tabs__item {
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 10px 0;
box-sizing: border-box;
}
.landscape-vertical-tabs__inner {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.landscape-vertical-tabs__icon {
flex-shrink: 0;
}
.landscape-vertical-tabs__label {
margin-top: 4px;
font-size: 12px;
color: #8a98b5;
text-align: center;
max-width: 96px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.landscape-vertical-tabs__item--active .landscape-vertical-tabs__label {
color: #3773f8;
font-weight: 500;
}
</style>
apps/uniappX/uniapp-x-tape/components/HomeFrame/TabbarPortrait.uvue
0 → 100644
View file @
4c166a8
<template>
<view class="home-tabbar home-tabbar-portrait"
:class="[adapterClassName, isPadPortraitMode ? 'home-tabbar-portrait-pad' : '']">
<un-tabbar :model-value="currentTabIndex"
class="portrait-un-tabbar"
:fixed="true"
:placeholder="false"
:safe-area-inset-bottom="true"
active-color="#3773f8"
inactive-color="#8a98b5"
bg-color="#ffffff"
:height="tabbarHeight"
@change="emit('tabChange', ($event as string | number))">
<un-tabbar-item v-for="(item, index) in tabs"
:key="index"
:name="index"
:text="item.label"
:icon-size="tabbarIconSize">
<template #icon="{ active }">
<image v-if="active === true"
class="tabbar-icon-img"
mode="aspectFit"
:src="item.iconSrcActive" />
<image v-else
class="tabbar-icon-img"
mode="aspectFit"
:src="item.iconSrcInactive" />
</template>
</un-tabbar-item>
</un-tabbar>
<CenterPopup :list="sceneTypeList"
title="选择场景"
:visible="showScenePopup"
@choose="emit('chooseScene', $event)"
@update:visible="emit('scenePopupVisible', $event)" />
<SettingBox :visible="showSetting"
@update:visible="emit('settingVisible', $event)" />
</view>
</template>
<script setup lang="uts">
import CenterPopup from "@/components/CenterPopup.uvue";
import SettingBox from "@/pages/person/SettingBox.uvue";
import { HOME_FRAME_TABS } from "./tabbarShared.uts";
defineProps<{
adapterClassName: string
isPadPortraitMode: boolean
tabbarHeight: number
tabbarIconSize: number
currentTabIndex: number
sceneTypeList: UTSJSONObject[]
showScenePopup: boolean
showSetting: boolean
}>();
const emit = defineEmits<{
tabChange: [name: string | number]
scenePopupVisible: [v: boolean]
settingVisible: [v: boolean]
chooseScene: [index: number]
}>();
const tabs = HOME_FRAME_TABS;
</script>
<style scoped lang="scss">
@import "./styles/common.scss";
</style>
apps/uniappX/uniapp-x-tape/components/HomeFrame/index.uvue
View file @
4c166a8
<template>
<template>
<view class="home-frame-container"
<view class="home-frame-container
scene-shell-root
"
:class="[modeClass, resolutionClass, adapterClass, tabSlotEmbedClass]">
:class="[modeClass, resolutionClass, adapterClass, tabSlotEmbedClass]">
<!-- 首页内容区:横竖方向由容器 modeClass + common.scss 控制 .home-content -->
<!-- 主导航 Tabbar 由 SceneShell 横/竖壳承担;此处仅内容区 -->
<view class="home-content"
<view class="home-content hf-content-without-tabbar">
:class="tabbarVisible ? '' : 'hf-content-without-tabbar'">
<!-- Tabbar 在前:横屏 row 时自然在屏幕左侧;竖屏仍靠 order 把主内容置上;套壳页由 SceneShell 承载 Tabbar 时关闭 -->
<HomeFrameTabbar v-if="tabbarVisible"
:adapter-class="adapterClass"
:user-info="userInfo" />
<view class="right-side">
<view class="right-side">
<!-- 仅「场景首页」:接待中心 / 我的 为独立路由页(见 HomeFrameTabbar) -->
<!-- 仅「场景首页」:接待中心 / 我的 为独立路由页(见 HomeFrameTabbar) -->
<!-- 三卡片布局:轻改 / 权益等使用 swiperCustom -->
<!-- 三卡片布局:轻改 / 权益等使用 swiperCustom -->
...
@@ -83,7 +77,6 @@ import { layoutService } from "@/services/LayoutService.uts";
...
@@ -83,7 +77,6 @@ import { layoutService } from "@/services/LayoutService.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 HomeFrameTabbar from "./Tabbar.uvue";
import HomeFrameMessageIndex from "./MessageIndex.uvue";
import HomeFrameMessageIndex from "./MessageIndex.uvue";
import ProductIntroSwiper from "./ProductIntroSwiper.uvue";
import ProductIntroSwiper from "./ProductIntroSwiper.uvue";
...
@@ -92,8 +85,6 @@ import { getLandscapeConfig } from "./styles/landscape.uts";
...
@@ -92,8 +85,6 @@ import { getLandscapeConfig } from "./styles/landscape.uts";
import { getPortraitConfig } from "./styles/portrait.uts";
import { getPortraitConfig } from "./styles/portrait.uts";
const props = withDefaults(defineProps<{
const props = withDefaults(defineProps<{
/** false:仅渲染主内容区,外层由 SceneShell 等提供 Tabbar(避免双 Tabbar) */
showTabbar?: boolean
showFooter?: boolean
showFooter?: boolean
swiperCustom?: boolean
swiperCustom?: boolean
/** 产品介绍区:与 swiperCustom 配套,由页面传入列表与文案 */
/** 产品介绍区:与 swiperCustom 配套,由页面传入列表与文案 */
...
@@ -114,15 +105,10 @@ const props = withDefaults(defineProps<{
...
@@ -114,15 +105,10 @@ const props = withDefaults(defineProps<{
*/
*/
embedInTabSlot?: boolean
embedInTabSlot?: boolean
}>(), {
}>(), {
showTabbar: true,
showStartReception: true,
showStartReception: true,
embedInTabSlot: false,
embedInTabSlot: false,
});
});
const tabbarVisible = computed((): boolean => {
return props.showTabbar !== false;
});
const tabSlotEmbedClass = computed((): string => {
const tabSlotEmbedClass = computed((): string => {
return props.embedInTabSlot === true ? "hf-embed-in-tab-slot" : "";
return props.embedInTabSlot === true ? "hf-embed-in-tab-slot" : "";
});
});
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/presets/HomeMainTab.uvue
View file @
4c166a8
<template>
<template>
<!--
<!--
层级(仅 index 物理 tab 页):
层级(仅 index 物理 tab 页):
1) SceneShell:
系统级 tab 壳(侧栏/底栏 + 右侧槽)
,见 SceneShell.uvue
1) SceneShell:
横/竖两套 MainTabShell + 槽
,见 SceneShell.uvue
2) HomeMainTab:按 userInfo.sceneType 切换下方三选一子树
2) HomeMainTab:按 userInfo.sceneType 切换下方三选一子树
3) *HomePanel:各场景业务 + 内层 HomeFrame(三卡片区,embedInTabSlot 与壳分工)
3) *HomePanel:各场景业务 + 内层 HomeFrame(三卡片区,embedInTabSlot 与壳分工)
-->
-->
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/presets/MyCenterTab.uvue
View file @
4c166a8
<template>
<template>
<view class="home-frame-container scene-shell-root"
:class="[modeClass, resolutionClass, adapterClass]">
<view class="my-center-wrap">
<view class="my-center-wrap">
<MyCenterMain :user-info="resolvedUserInfo" />
<MyCenterMain :user-info="resolvedUserInfo" />
</view>
</view>
</view>
</template>
</template>
<script setup lang="uts">
<script setup lang="uts">
import { computed } from "vue";
import { computed } from "vue";
import { cssClassRef, useResolutionConfig } from "@/services/adapter";
import { layoutService } from "@/services/LayoutService.uts";
import MyCenterMain from "@/pages/person/MyCenterMain.uvue";
import MyCenterMain from "@/pages/person/MyCenterMain.uvue";
const props = defineProps<{
const props = defineProps<{
userInfo?: null | UTSJSONObject
userInfo?: null | UTSJSONObject
}>();
}>();
useResolutionConfig();
const adapterClass = computed((): string => {
const cls = cssClassRef.value;
return cls != null ? (cls as string) : "";
});
const modeClass = computed((): string => {
const modeRef = layoutService.getCurrentMode();
const m = modeRef.value;
return m == "portrait" ? "mode-portrait" : "mode-landscape";
});
const resolutionClass = computed((): string => {
const bucket = layoutService.getResolutionBucket();
return `res-${bucket}`;
});
const resolvedUserInfo = computed((): UTSJSONObject => {
const resolvedUserInfo = computed((): UTSJSONObject => {
const u = props.userInfo;
const u = props.userInfo;
return u != null ? u : ({} as UTSJSONObject);
return u != null ? u : ({} as UTSJSONObject);
...
@@ -20,10 +43,14 @@ const resolvedUserInfo = computed((): UTSJSONObject => {
...
@@ -20,10 +43,14 @@ const resolvedUserInfo = computed((): UTSJSONObject => {
</script>
</script>
<style scoped lang="scss">
<style scoped lang="scss">
@import "../styles/common.scss";
.my-center-wrap {
.my-center-wrap {
flex: 1;
flex: 1;
width: 100%;
width: 100%;
height: 100%;
height: 100%;
min-height: 0;
min-height: 0;
display: flex;
flex-direction: column;
}
}
</style>
</style>
apps/uniappX/uniapp-x-tape/components/HomeFrame/styles/common.scss
View file @
4c166a8
...
@@ -556,44 +556,3 @@
...
@@ -556,44 +556,3 @@
border-radius
:
20px
;
border-radius
:
20px
;
margin
:
var
(
--
l-spacing-sm
)
auto
0
;
margin
:
var
(
--
l-spacing-sm
)
auto
0
;
}
}
// ========================================================================
// 首页布局调试(仅 pages/index 的 SceneShell 挂 hf-layout-debug 时生效)
// 验证横竖屏分区后删除:index.uvue 上的 hf-layout-debug + 本段样式
// ========================================================================
.hf-layout-debug.scene-shell-root
>
.home-content
>
.right-side
{
background-color
:
rgba
(
160
,
140
,
255
,
0
.22
);
}
.hf-layout-debug
.home-tabbar-landscape
{
background-color
:
rgba
(
255
,
100
,
100
,
0
.38
)
!
important
;
}
.hf-layout-debug
.home-tabbar-portrait
{
background-color
:
rgba
(
255
,
160
,
90
,
0
.42
)
!
important
;
}
/* 内层 HomeFrame(embed)整块主区 */
.hf-layout-debug
.hf-embed-in-tab-slot
>
.home-content
>
.right-side
{
background-color
:
rgba
(
90
,
200
,
220
,
0
.2
);
}
.hf-layout-debug
.app-content-box.show-content-box
{
background-color
:
rgba
(
120
,
120
,
120
,
0
.12
);
}
.hf-layout-debug
.start
{
background-color
:
rgba
(
255
,
230
,
80
,
0
.55
)
!
important
;
}
.hf-layout-debug
.app-content-box
.content-left
.module-box
{
background-color
:
rgba
(
80
,
200
,
130
,
0
.4
);
}
.hf-layout-debug
.app-content-box
.content-left
.tool-box
{
background-color
:
rgba
(
80
,
140
,
255
,
0
.38
);
}
.hf-layout-debug
.app-content-box
.content-right
{
background-color
:
rgba
(
200
,
120
,
255
,
0
.38
);
}
apps/uniappX/uniapp-x-tape/components/HomeFrame/tabbarShared.uts
0 → 100644
View file @
4c166a8
import { computed, ref } from "vue";
import { cssClassRef } from "@/services/adapter";
import { storage } from "@/utils/storage.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import { getLandscapeConfig } from "./styles/landscape.uts";
import { getPortraitConfig, PORTRAIT_COMMON } from "./styles/portrait.uts";
export type HomeFrameTabbarSource = {
getAdapterClass: () => null | string
getTabIndex: () => number
getUserInfo: () => null | UTSJSONObject
}
export type TabItem = {
label: string;
icon: string;
name: string;
/** 模板内仅用路径字段,避免 UTS 在 slot 中调用 import 的函数 */
iconSrcActive: string;
iconSrcInactive: string;
};
export type SceneTypeItem = { describe: string; icon: string; title: string; }
export const HOME_FRAME_TABS: TabItem[] = [
{
label: "首页",
icon: "home",
name: "HomeSlot",
iconSrcActive: "/static/images/tabbar/home-active.png",
iconSrcInactive: "/static/images/tabbar/home.png"
},
{
label: "接待中心",
icon: "record",
name: "ReceptionCenter",
iconSrcActive: "/static/images/tabbar/record-active.png",
iconSrcInactive: "/static/images/tabbar/record.png"
},
{
label: "我的",
icon: "my",
name: "MyCenter",
iconSrcActive: "/static/images/tabbar/study-active.png",
iconSrcInactive: "/static/images/tabbar/study.png"
},
];
export function getSceneTypeItem(sceneId: number): null | SceneTypeItem {
if (sceneId == 1) return { title: "轻改", describe: "太阳膜升级转化", icon: "轻" };
if (sceneId == 0) return { title: "会员权益/升级", describe: "权益延保", icon: "权" };
if (sceneId == 7) return { title: "二手车", describe: "二手车业务", icon: "二" };
return null;
}
export function getTabIconSrc(icon: string, active: boolean): string {
if (icon === "home") {
return active ? "/static/images/tabbar/home-active.png" : "/static/images/tabbar/home.png";
}
if (icon === "record") {
return active ? "/static/images/tabbar/record-active.png" : "/static/images/tabbar/record.png";
}
if (icon === "study") {
return active ? "/static/images/tabbar/study-active.png" : "/static/images/tabbar/study.png";
}
if (icon === "my") {
return active ? "/static/images/tabbar/study-active.png" : "/static/images/tabbar/study.png";
}
return "/static/images/tabbar/home.png";
}
function reLaunchPage(pagesJsonPath: string): void {
const trimmed = pagesJsonPath.startsWith("/") ? pagesJsonPath.substring(1) : pagesJsonPath;
const withSlash = "/" + trimmed;
uni.reLaunch({
url: withSlash,
fail: (_err: any) => {
uni.reLaunch({ url: trimmed });
}
});
}
function switchTabPage(pagesJsonPath: string): void {
const trimmed = pagesJsonPath.startsWith("/") ? pagesJsonPath.substring(1) : pagesJsonPath;
const url = "/" + trimmed;
uni.switchTab({
url,
success: () => {
hideNativeTabBar();
},
fail: (_err: any) => {
reLaunchPage(trimmed);
}
});
}
export function useHomeFrameTabbar(source: HomeFrameTabbarSource) {
const showScenePopup = ref(false);
const showSetting = ref(false);
const adapterClassName = computed((): string => {
const cls = source.getAdapterClass();
if (cls != null && cls !== "") {
return cls as string;
}
const fromRef = cssClassRef.value;
return fromRef != null ? (fromRef as string) : "";
});
const isPadPortraitMode = computed((): boolean => {
const cls = adapterClassName.value;
return cls.indexOf("layout-portrait-768x1174") >= 0;
});
const tabbarHeight = computed((): number => {
const adapterCls = cssClassRef.value;
const portraitConfig = getPortraitConfig(adapterCls);
if (portraitConfig != null) {
return portraitConfig.tabbarHeight as number;
}
return PORTRAIT_COMMON.tabbarHeight as number;
});
const tabbarIconSize = computed((): number => {
const adapterCls = cssClassRef.value;
const portraitConfig = getPortraitConfig(adapterCls);
if (portraitConfig != null) {
return portraitConfig.tabbarIconSize as number;
}
return PORTRAIT_COMMON.tabbarIconSize as number;
});
const landscapeTabbarRootStyle = computed((): string => {
const adapterCls = cssClassRef.value;
const lc = getLandscapeConfig(adapterCls);
const h = lc != null ? lc.leftTabsHeight : "540px";
const padX = lc != null ? lc.leftTabsPaddingLeft : "16px";
/* 左右对称,与用户区、底栏在同一中轴上对齐 */
return `display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:${h};padding-left:${padX};padding-right:${padX};padding-top:8px;padding-bottom:8px;box-sizing:border-box;`;
});
const landscapeTabbarInnerHeight = computed((): number => {
const adapterCls = cssClassRef.value;
const lc = getLandscapeConfig(adapterCls);
if (lc != null && adapterCls.indexOf("1920") >= 0) {
return 64;
}
if (lc != null) {
return 58;
}
return 56;
});
const landscapeTabbarIconSize = computed((): number => {
const adapterCls = cssClassRef.value;
if (adapterCls.indexOf("1920") >= 0) {
return 32;
}
return 28;
});
const currentTabIndex = computed((): number => {
return source.getTabIndex();
});
const sceneTypeList = computed((): UTSJSONObject[] => {
const info = source.getUserInfo();
let openArr: number[] = [1, 0, 7];
if (info != null) {
const arr = (info as UTSJSONObject).openSceneArr as null | number[];
if (arr != null && arr.length > 0) {
openArr = arr;
}
}
const result: UTSJSONObject[] = [];
const valid = [1, 0, 7];
for (const element of openArr) {
const e = element as number;
if (valid.indexOf(e) >= 0) {
const item = getSceneTypeItem(e);
if (item != null) {
result.push({ title: item.title, describe: item.describe, icon: item.icon } as UTSJSONObject);
}
}
}
if (result.length === 0) {
result.push(
{ title: "轻改", describe: "太阳膜升级转化", icon: "轻" } as UTSJSONObject,
{ title: "会员权益/升级", describe: "权益延保", icon: "权" } as UTSJSONObject,
{ title: "二手车", describe: "二手车业务", icon: "二" } as UTSJSONObject
);
}
return result;
});
const sceneTypeIdList = computed((): number[] => {
const info = source.getUserInfo();
let openArr: number[] = [1, 0, 7];
if (info != null) {
const arr = (info as UTSJSONObject).openSceneArr as null | number[];
if (arr != null && arr.length > 0) {
openArr = arr;
}
}
const valid = [1, 0, 7];
const result: number[] = [];
for (const element of openArr) {
const e = element as number;
if (valid.indexOf(e) >= 0) {
result.push(e);
}
}
if (result.length === 0) {
return [1, 0, 7];
}
return result;
});
const userName = computed((): string => {
const info = source.getUserInfo();
if (info == null) {
return "";
}
const obj = info as UTSJSONObject;
const raw = obj.name ?? obj.staffName ?? obj.merchantName;
if (raw == null) {
return "";
}
const s = `${raw}`;
return s !== "" ? s : "";
});
const navigateToTab = (index: number): void => {
const cur = source.getTabIndex();
if (index == cur) {
return;
}
if (index == 0) {
switchTabPage("pages/index/index");
return;
}
if (index == 1) {
switchTabPage("pages/receptionCenter/center");
return;
}
if (index == 2) {
switchTabPage("pages/person/myCenter");
return;
}
};
const onTabChange = (name: string | number): void => {
const idx = name as number;
navigateToTab(idx);
};
const onScenePopupVisible = (v: boolean): void => {
showScenePopup.value = v;
};
const onSettingVisible = (v: boolean): void => {
showSetting.value = v;
};
const onSceneChange = (): void => {
showScenePopup.value = true;
};
const onSetting = (): void => {
showSetting.value = true;
};
const onChooseScene = (index: number): void => {
const ids = sceneTypeIdList.value;
if (index < 0 || index >= ids.length) {
return;
}
const sceneType = ids[index];
const raw = storage.get("userInfo");
if (raw == null) {
return;
}
const info = raw as UTSJSONObject;
const current = info.sceneType as null | number;
if (current != null && current == sceneType) {
return;
}
info.sceneType = sceneType;
uni.showLoading({ title: "切换中", mask: true });
storage.set("userInfo", info, 0);
uni.switchTab({
url: "/pages/index/index",
success: () => {
hideNativeTabBar();
},
complete: () => {
uni.hideLoading();
},
fail: (_err: any) => {
uni.hideLoading();
reLaunchPage("pages/index/index");
}
});
};
const jumpPersonCenter = (): void => {
uni.navigateTo({ url: "/pages/person/attendance" });
};
return {
showScenePopup,
showSetting,
adapterClassName,
isPadPortraitMode,
tabbarHeight,
tabbarIconSize,
landscapeTabbarRootStyle,
landscapeTabbarInnerHeight,
landscapeTabbarIconSize,
currentTabIndex,
sceneTypeList,
sceneTypeIdList,
userName,
onTabChange,
onScenePopupVisible,
onSettingVisible,
onSceneChange,
onSetting,
onChooseScene,
jumpPersonCenter
};
}
apps/uniappX/uniapp-x-tape/pages/boutique/components/BoutiqueHomePanel.uvue
View file @
4c166a8
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
class="boutique-home-frame-root"
class="boutique-home-frame-root"
:embed-in-tab-slot="true"
:embed-in-tab-slot="true"
:show-footer="true"
:show-footer="true"
:show-tabbar="false"
:swiper-custom="true"
:swiper-custom="true"
:intro-load-complete="logic.loadComplete.value"
:intro-load-complete="logic.loadComplete.value"
:intro-swiper-list="boutiqueIntroSwiperList"
:intro-swiper-list="boutiqueIntroSwiperList"
...
...
apps/uniappX/uniapp-x-tape/pages/equity/components/EquityHomePanel.uvue
View file @
4c166a8
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
<view class="page-container equity-page hf-equity-tab-root fade-in">
<view class="page-container equity-page hf-equity-tab-root fade-in">
<HomeFrame ref="homeRef"
<HomeFrame ref="homeRef"
:embed-in-tab-slot="true"
:embed-in-tab-slot="true"
:show-tabbar="false"
:show-footer="true"
:show-footer="true"
:swiper-custom="true"
:swiper-custom="true"
:intro-load-complete="loadComplete"
:intro-load-complete="loadComplete"
...
...
apps/uniappX/uniapp-x-tape/pages/index/index.uvue
View file @
4c166a8
...
@@ -4,9 +4,7 @@
...
@@ -4,9 +4,7 @@
<view class="index-shell-page">
<view class="index-shell-page">
<!-- 可拉伸层:单列 flex 下单个子项须 flex:1+min-height:0 才吃满高度;接待/我的等同层无 flex 故无此问题 -->
<!-- 可拉伸层:单列 flex 下单个子项须 flex:1+min-height:0 才吃满高度;接待/我的等同层无 flex 故无此问题 -->
<view class="index-shell-scene-stretch">
<view class="index-shell-scene-stretch">
<!-- 布局调试:确认结构后去掉 hf-layout-debug -->
<SceneShell ref="shellRef"
<SceneShell ref="shellRef"
class="hf-layout-debug"
:active-tab-index="0">
:active-tab-index="0">
<template #default="{ userInfo }">
<template #default="{ userInfo }">
<view class="tab-panel">
<view class="tab-panel">
...
@@ -74,6 +72,14 @@ onShow(async () => {
...
@@ -74,6 +72,14 @@ onShow(async () => {
flex-direction: column;
flex-direction: column;
}
}
.index-shell-scene-stretch :deep(.main-tab-shell-root) {
flex: 1;
min-height: 0;
min-width: 0;
width: 100%;
height: 100%;
}
.index-shell-scene-stretch :deep(.scene-shell-root) {
.index-shell-scene-stretch :deep(.scene-shell-root) {
flex: 1;
flex: 1;
min-height: 0;
min-height: 0;
...
...
apps/uniappX/uniapp-x-tape/pages/person/myCenter.uvue
View file @
4c166a8
...
@@ -30,5 +30,15 @@ onShow(() => {
...
@@ -30,5 +30,15 @@ onShow(() => {
.page-container {
.page-container {
width: 100%;
width: 100%;
height: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.page-container :deep(.main-tab-shell-root) {
flex: 1;
min-height: 0;
min-width: 0;
width: 100%;
height: 100%;
}
}
</style>
</style>
apps/uniappX/uniapp-x-tape/pages/receptionCenter/center.uvue
View file @
4c166a8
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
:active-tab-index="1"
:active-tab-index="1"
>
>
<template #default>
<template #default>
<view class="home-frame-container scene-shell-root"
:class="[receptionModeClass, receptionResolutionClass, receptionAdapterClass]">
<!-- <view class="test test-view">
<!-- <view class="test test-view">
<text class="test-orientation-text">hooks:{{ hookOrientation }} isLandscape:{{ isLandscape }} {{ hookOrientation=='landscape'?'横屏':'竖屏'}} {{ isLandscape }}</text>
<text class="test-orientation-text">hooks:{{ hookOrientation }} isLandscape:{{ isLandscape }} {{ hookOrientation=='landscape'?'横屏':'竖屏'}} {{ isLandscape }}</text>
</view> -->
</view> -->
...
@@ -166,6 +168,7 @@
...
@@ -166,6 +168,7 @@
<ReceptionDetail :item="receptionRecordItem" @close="onReceptionRecordDetailClose" />
<ReceptionDetail :item="receptionRecordItem" @close="onReceptionRecordDetailClose" />
</view>
</view>
</view>
</view>
</view>
</template>
</template>
</SceneShell>
</SceneShell>
</view>
</view>
...
@@ -187,12 +190,31 @@ import { getStr, getNum, getTs, getCurrentMonthRange, getTodayDayRangeStrings, g
...
@@ -187,12 +190,31 @@ import { getStr, getNum, getTs, getCurrentMonthRange, getTodayDayRangeStrings, g
import { getMerchantPerformance, getCustomerFileList, getReceptionList } from '@/api/receiption.uts'
import { getMerchantPerformance, getCustomerFileList, getReceptionList } from '@/api/receiption.uts'
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, useResolutionConfig } from "@/services/adapter";
import { layoutService } from "@/services/LayoutService.uts";
import { updateOrientation, useOrientation } from '@/services/adapter/hooks/index.uts'
import { updateOrientation, useOrientation } from '@/services/adapter/hooks/index.uts'
import pageVars from './styles/index.vars'
import pageVars from './styles/index.vars'
const shellRef = ref(null)
const shellRef = ref(null)
useResolutionConfig();
const receptionAdapterClass = computed((): string => {
const cls = cssClassRef.value;
return cls != null ? (cls as string) : "";
});
const receptionModeClass = computed((): string => {
const modeRef = layoutService.getCurrentMode();
const m = modeRef.value;
return m == "portrait" ? "mode-portrait" : "mode-landscape";
});
const receptionResolutionClass = computed((): string => {
const bucket = layoutService.getResolutionBucket();
return `res-${bucket}`;
});
onShow(() => {
onShow(() => {
if (shellRef.value != null) {
if (shellRef.value != null) {
(shellRef.value as ComponentPublicInstance).$callMethod('updateApp')
(shellRef.value as ComponentPublicInstance).$callMethod('updateApp')
...
@@ -1170,6 +1192,7 @@ onUnmounted(() => {
...
@@ -1170,6 +1192,7 @@ onUnmounted(() => {
<style scoped lang="scss">
<style scoped lang="scss">
@import "./styles/common.scss";
@import "./styles/common.scss";
@import "../../components/HomeFrame/styles/common.scss";
// @import "./styles/landscape.scss";
// @import "./styles/landscape.scss";
// @import "./styles/portrait.scss";
// @import "./styles/portrait.scss";
...
@@ -1180,6 +1203,14 @@ onUnmounted(() => {
...
@@ -1180,6 +1203,14 @@ onUnmounted(() => {
flex-direction: column;
flex-direction: column;
}
}
.reception-shell-page :deep(.main-tab-shell-root) {
flex: 1;
min-height: 0;
min-width: 0;
width: 100%;
height: 100%;
}
.reception-shell-page :deep(.scene-shell-root) {
.reception-shell-page :deep(.scene-shell-root) {
flex: 1;
flex: 1;
min-height: 0;
min-height: 0;
...
...
apps/uniappX/uniapp-x-tape/pages/usedCar/components/UsedCarHomePanel.uvue
View file @
4c166a8
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
<view class="page-container used-car-home-in-tab">
<view class="page-container used-car-home-in-tab">
<HomeFrame ref="homeRef"
<HomeFrame ref="homeRef"
:embed-in-tab-slot="true"
:embed-in-tab-slot="true"
:show-tabbar="false"
:show-footer="true">
:show-footer="true">
<template #home>
<template #home>
<view class="home-content">
<view class="home-content">
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment