Commit feca21ab by 岑成威

fix:样式

1 parent 2d8e13eb
...@@ -6,9 +6,14 @@ ...@@ -6,9 +6,14 @@
src="/static/images/home/left-bg.png" /> src="/static/images/home/left-bg.png" />
<view class="user-box user-box-clickable hf-landscape-user" <view class="user-box user-box-clickable hf-landscape-user"
@click="emit('jumpPersonCenter')"> @click="emit('jumpPersonCenter')">
<view class="user-info"> <view class="hf-landscape-profile">
<view class="user-avatar"></view> <un-avatar :text="avatarText"
<text class="user-name-text">{{ userName }}</text> shape="circle"
size="52"
bgColor="#2f6af7"
color="#ffffff"
fontSize="20" />
<text class="hf-landscape-name">{{ userName }}</text>
</view> </view>
</view> </view>
<view class="landscape-tabbar-wrap"> <view class="landscape-tabbar-wrap">
...@@ -31,8 +36,18 @@ ...@@ -31,8 +36,18 @@
</view> </view>
</view> </view>
<view class="home-tabbar-footer flex-col hf-landscape-footer"> <view class="home-tabbar-footer flex-col hf-landscape-footer">
<view class="btn-placeholder" @tap="emit('sceneChange')"></view> <view class="hf-landscape-footer-btn"
<view class="btn-placeholder" @tap="emit('setting')"></view> @tap="emit('sceneChange')">
<image class="hf-landscape-footer-icon"
mode="aspectFit"
src="/static/images/home/scene-change.png" />
</view>
<view class="hf-landscape-footer-btn hf-landscape-footer-btn--after"
@tap="emit('setting')">
<image class="hf-landscape-footer-icon"
mode="aspectFit"
src="/static/images/home/setting.png" />
</view>
</view> </view>
<CenterPopup :list="sceneTypeList" <CenterPopup :list="sceneTypeList"
title="选择场景" title="选择场景"
...@@ -76,6 +91,19 @@ const emit = defineEmits<{ ...@@ -76,6 +91,19 @@ const emit = defineEmits<{
const tabs = HOME_FRAME_TABS; const tabs = HOME_FRAME_TABS;
/** 与 MyCenterMain 一致:姓名首字,空则「我」 */
const avatarText = computed((): string => {
const n = props.userName;
if (n == null || n === "") {
return "我";
}
const s = n as string;
if (s.length <= 0) {
return "我";
}
return s.substring(0, 1);
});
const iconImageStyle = computed((): any => { const iconImageStyle = computed((): any => {
const s = props.landscapeTabbarIconSize; const s = props.landscapeTabbarIconSize;
return { return {
...@@ -107,6 +135,28 @@ function onTabItemClick(index: number): void { ...@@ -107,6 +135,28 @@ function onTabItemClick(index: number): void {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
box-sizing: border-box; box-sizing: border-box;
padding-top: 20px;
}
.hf-landscape-profile {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
/* 与 MyCenterMain .name 一致 */
.hf-landscape-name {
margin-top: 10px;
font-size: 19px;
font-weight: 600;
color: #1a2433;
line-height: 24px;
text-align: center;
max-width: 108px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
} }
.hf-landscape-footer { .hf-landscape-footer {
...@@ -117,6 +167,25 @@ function onTabItemClick(index: number): void { ...@@ -117,6 +167,25 @@ function onTabItemClick(index: number): void {
box-sizing: border-box; box-sizing: border-box;
} }
.hf-landscape-footer-btn {
width: 44px;
height: 44px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.hf-landscape-footer-btn--after {
margin-top: 12px;
}
.hf-landscape-footer-icon {
width: 40px;
height: 40px;
flex-shrink: 0;
}
/* 与原先 .landscape-un-tabbar 占位一致,内部强制纵向排列 item */ /* 与原先 .landscape-un-tabbar 占位一致,内部强制纵向排列 item */
.landscape-vertical-tabs { .landscape-vertical-tabs {
display: flex; display: flex;
...@@ -132,10 +201,14 @@ function onTabItemClick(index: number): void { ...@@ -132,10 +201,14 @@ function onTabItemClick(index: number): void {
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
padding: 10px 0; padding: 18px 0;
box-sizing: border-box; box-sizing: border-box;
} }
.landscape-vertical-tabs__item + .landscape-vertical-tabs__item {
margin-top: 10px;
}
.landscape-vertical-tabs__inner { .landscape-vertical-tabs__inner {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -148,7 +221,7 @@ function onTabItemClick(index: number): void { ...@@ -148,7 +221,7 @@ function onTabItemClick(index: number): void {
} }
.landscape-vertical-tabs__label { .landscape-vertical-tabs__label {
margin-top: 4px; margin-top: 6px;
font-size: 12px; font-size: 12px;
color: #8a98b5; color: #8a98b5;
text-align: center; text-align: center;
......
...@@ -2,6 +2,7 @@ import { computed, ref } from "vue"; ...@@ -2,6 +2,7 @@ import { computed, ref } from "vue";
import { cssClassRef } from "@/services/adapter"; import { cssClassRef } from "@/services/adapter";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
import { notifyUserSceneTypeChanged } from "@/utils/userSceneEvents.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts"; import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import { getLandscapeConfig } from "./styles/landscape.uts"; import { getLandscapeConfig } from "./styles/landscape.uts";
...@@ -290,6 +291,7 @@ export function useHomeFrameTabbar(source: HomeFrameTabbarSource) { ...@@ -290,6 +291,7 @@ export function useHomeFrameTabbar(source: HomeFrameTabbarSource) {
info.sceneType = sceneType; info.sceneType = sceneType;
uni.showLoading({ title: "切换中", mask: true }); uni.showLoading({ title: "切换中", mask: true });
storage.set("userInfo", info, 0); storage.set("userInfo", info, 0);
notifyUserSceneTypeChanged(sceneType);
uni.switchTab({ uni.switchTab({
url: "/pages/index/index", url: "/pages/index/index",
success: () => { success: () => {
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
:active-tab-index="0"> :active-tab-index="0">
<template #default="{ userInfo }"> <template #default="{ userInfo }">
<view class="tab-panel"> <view class="tab-panel">
<HomeMainTab :logic="logic" <HomeMainTab :key="homeMainTabSceneKey"
:logic="logic"
:user-info="userInfo" /> :user-info="userInfo" />
</view> </view>
</template> </template>
...@@ -19,15 +20,18 @@ ...@@ -19,15 +20,18 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ComponentPublicInstance, ref } from "vue"; import { ComponentPublicInstance, onMounted, onUnmounted, ref } from "vue";
import SceneShell from "@/components/HomeFrame/SceneShell.uvue"; import SceneShell from "@/components/HomeFrame/SceneShell.uvue";
import HomeMainTab from "@/components/HomeFrame/presets/HomeMainTab.uvue"; import HomeMainTab from "@/components/HomeFrame/presets/HomeMainTab.uvue";
import { useBoutiqueLogic } from "@/pages/boutique/useBoutiqueLogic.uts"; import { useBoutiqueLogic } from "@/pages/boutique/useBoutiqueLogic.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
import { USER_SCENE_TYPE_CHANGED } from "@/utils/userSceneEvents.uts";
const shellRef = ref(null); const shellRef = ref(null);
const logic = useBoutiqueLogic(); const logic = useBoutiqueLogic();
/** 场景切换后强制重建 HomeMainTab,避免 userInfo 引用未变导致子树不更新 */
const homeMainTabSceneKey = ref(0);
function readSceneType(): number { function readSceneType(): number {
const raw = storage.get("userInfo"); const raw = storage.get("userInfo");
...@@ -38,6 +42,30 @@ function readSceneType(): number { ...@@ -38,6 +42,30 @@ function readSceneType(): number {
return st != null ? st : 1; return st != null ? st : 1;
} }
async function syncHomeAfterSceneChange(_sceneType: number): Promise<void> {
if (shellRef.value != null) {
(shellRef.value as ComponentPublicInstance).$callMethod("updateApp");
}
homeMainTabSceneKey.value = homeMainTabSceneKey.value + 1;
const st = readSceneType();
if (st === 1) {
await logic.initIfNeeded();
logic.getBoutiquePackageList();
}
}
function onUserSceneTypeChanged(sceneType: number): void {
void syncHomeAfterSceneChange(sceneType);
}
onMounted((): void => {
uni.$on(USER_SCENE_TYPE_CHANGED, onUserSceneTypeChanged);
});
onUnmounted((): void => {
uni.$off(USER_SCENE_TYPE_CHANGED);
});
onShow(async () => { onShow(async () => {
if (logic.ensureLoginOrRelauch() === false) { if (logic.ensureLoginOrRelauch() === false) {
return; return;
......
...@@ -86,6 +86,7 @@ import { computed, ref, onMounted } from "vue"; ...@@ -86,6 +86,7 @@ import { computed, ref, onMounted } from "vue";
import CenterPopup from "@/components/CenterPopup.uvue"; import CenterPopup from "@/components/CenterPopup.uvue";
import { resolveMainHomeUrl } from "@/utils/homeRoute.uts"; import { resolveMainHomeUrl } from "@/utils/homeRoute.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
import { notifyUserSceneTypeChanged } from "@/utils/userSceneEvents.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts"; import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import SettingBox from "./SettingBox.uvue"; import SettingBox from "./SettingBox.uvue";
...@@ -238,6 +239,7 @@ function onChooseScene(index: number): void { ...@@ -238,6 +239,7 @@ function onChooseScene(index: number): void {
info.sceneType = sceneType; info.sceneType = sceneType;
uni.showLoading({ title: "切换中", mask: true }); uni.showLoading({ title: "切换中", mask: true });
storage.set("userInfo", info, 0); storage.set("userInfo", info, 0);
notifyUserSceneTypeChanged(sceneType);
uni.switchTab({ uni.switchTab({
url: resolveMainHomeUrl(), url: resolveMainHomeUrl(),
success: () => { success: () => {
......
/** 用户切换「业务场景」sceneType 后广播,供首页等同步 UI / 拉数 */
export const USER_SCENE_TYPE_CHANGED = "user-scene-type-changed";
export function notifyUserSceneTypeChanged(sceneType: number): void {
uni.$emit(USER_SCENE_TYPE_CHANGED, sceneType);
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!