Commit feca21ab by 岑成威

fix:样式

1 parent 2d8e13eb
......@@ -6,9 +6,14 @@
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 class="hf-landscape-profile">
<un-avatar :text="avatarText"
shape="circle"
size="52"
bgColor="#2f6af7"
color="#ffffff"
fontSize="20" />
<text class="hf-landscape-name">{{ userName }}</text>
</view>
</view>
<view class="landscape-tabbar-wrap">
......@@ -31,8 +36,18 @@
</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 class="hf-landscape-footer-btn"
@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>
<CenterPopup :list="sceneTypeList"
title="选择场景"
......@@ -76,6 +91,19 @@ const emit = defineEmits<{
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 s = props.landscapeTabbarIconSize;
return {
......@@ -107,6 +135,28 @@ function onTabItemClick(index: number): void {
flex-direction: column;
align-items: center;
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 {
......@@ -117,6 +167,25 @@ function onTabItemClick(index: number): void {
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-vertical-tabs {
display: flex;
......@@ -132,10 +201,14 @@ function onTabItemClick(index: number): void {
flex-direction: row;
justify-content: center;
align-items: center;
padding: 10px 0;
padding: 18px 0;
box-sizing: border-box;
}
.landscape-vertical-tabs__item + .landscape-vertical-tabs__item {
margin-top: 10px;
}
.landscape-vertical-tabs__inner {
display: flex;
flex-direction: column;
......@@ -148,7 +221,7 @@ function onTabItemClick(index: number): void {
}
.landscape-vertical-tabs__label {
margin-top: 4px;
margin-top: 6px;
font-size: 12px;
color: #8a98b5;
text-align: center;
......
......@@ -2,6 +2,7 @@ import { computed, ref } from "vue";
import { cssClassRef } from "@/services/adapter";
import { storage } from "@/utils/storage.uts";
import { notifyUserSceneTypeChanged } from "@/utils/userSceneEvents.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import { getLandscapeConfig } from "./styles/landscape.uts";
......@@ -290,6 +291,7 @@ export function useHomeFrameTabbar(source: HomeFrameTabbarSource) {
info.sceneType = sceneType;
uni.showLoading({ title: "切换中", mask: true });
storage.set("userInfo", info, 0);
notifyUserSceneTypeChanged(sceneType);
uni.switchTab({
url: "/pages/index/index",
success: () => {
......
......@@ -8,7 +8,8 @@
:active-tab-index="0">
<template #default="{ userInfo }">
<view class="tab-panel">
<HomeMainTab :logic="logic"
<HomeMainTab :key="homeMainTabSceneKey"
:logic="logic"
:user-info="userInfo" />
</view>
</template>
......@@ -19,15 +20,18 @@
</template>
<script setup lang="uts">
import { ComponentPublicInstance, ref } from "vue";
import { ComponentPublicInstance, onMounted, onUnmounted, ref } from "vue";
import SceneShell from "@/components/HomeFrame/SceneShell.uvue";
import HomeMainTab from "@/components/HomeFrame/presets/HomeMainTab.uvue";
import { useBoutiqueLogic } from "@/pages/boutique/useBoutiqueLogic.uts";
import { storage } from "@/utils/storage.uts";
import { USER_SCENE_TYPE_CHANGED } from "@/utils/userSceneEvents.uts";
const shellRef = ref(null);
const logic = useBoutiqueLogic();
/** 场景切换后强制重建 HomeMainTab,避免 userInfo 引用未变导致子树不更新 */
const homeMainTabSceneKey = ref(0);
function readSceneType(): number {
const raw = storage.get("userInfo");
......@@ -38,6 +42,30 @@ function readSceneType(): number {
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 () => {
if (logic.ensureLoginOrRelauch() === false) {
return;
......
......@@ -86,6 +86,7 @@ import { computed, ref, onMounted } from "vue";
import CenterPopup from "@/components/CenterPopup.uvue";
import { resolveMainHomeUrl } from "@/utils/homeRoute.uts";
import { storage } from "@/utils/storage.uts";
import { notifyUserSceneTypeChanged } from "@/utils/userSceneEvents.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import SettingBox from "./SettingBox.uvue";
......@@ -238,6 +239,7 @@ function onChooseScene(index: number): void {
info.sceneType = sceneType;
uni.showLoading({ title: "切换中", mask: true });
storage.set("userInfo", info, 0);
notifyUserSceneTypeChanged(sceneType);
uni.switchTab({
url: resolveMainHomeUrl(),
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!