Landscape.uvue 6.04 KB
<template>
	<view class="home-tabbar home-tabbar-landscape">
		<!-- <image class="home-tabbar-bg-img"
		       mode="aspectFill"
		       src="/static/images/home/left-bg.png" /> -->
		<view class="hf-landscape-column">
			<view class="user-box user-box-clickable hf-landscape-user"
			      @click="emit('jumpPersonCenter')">
				<view class="hf-landscape-profile">
					<un-avatar :text="avatarText"
					           shape="circle"
					           size="42"
					           bgColor="#2f6af7"
					           color="#ffffff"
					           fontSize="20" />
					<text class="hf-landscape-name">{{ userName }}</text>
				</view>
			</view>
		</view>
		<view class="landscape-tabbar-wrap">
			<view class="landscape-un-tabbar landscape-vertical-tabs">
				<view v-for="(item, index) in tabs"
				      :key="index"
				      class="landscape-vertical-tabs__item"
				      :class="index === currentTabIndex ? 'landscape-vertical-tabs__item--active' : ''"
				      @click="onTabItemClick(index)">
					<view class="landscape-vertical-tabs__inner">
						<image class="landscape-vertical-tabs__icon"
						       mode="aspectFit"
						       :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">
			<!-- ✅ 分隔线,与上方 Tab 区域区分 -->
			<view class="hf-landscape-footer-divider"></view>

			<!-- ✅ 切换门店按钮 -->
			<view class="hf-landscape-footer-btn"
			      @tap="emit('switchStore')">
				<image class="hf-landscape-footer-icon"
				       mode="aspectFit"
				       src="/static/images/home/scene-change.png" />
				<text class="hf-landscape-footer-label">切换</text>
			</view>

			<!-- ✅ 设置按钮 -->
			<view class="hf-landscape-footer-btn"
			      @tap="emit('setting')">
				<image class="hf-landscape-footer-icon"
				       mode="aspectFit"
				       src="/static/images/home/setting.png" />
				<text class="hf-landscape-footer-label">设置</text>
			</view>
		</view>
	</view>
</template>

<script setup lang="uts">
import { useTabbarCommon, useLandscapeUserInfo } from "./hooks";

const props = defineProps<{
  currentTabIndex: number
}>();

const emit = defineEmits<{
  tabChange: [name: string | number]
  setting: []
  jumpPersonCenter: []
  switchStore: []
}>();

const { tabs } = useTabbarCommon();
const { userName, avatarText } = useLandscapeUserInfo();

function onTabItemClick(index: number): void {
	emit("tabChange", index);
}
</script>

<style scoped lang="scss">
@import "../styles/common.scss";

/* 顶部用户区:仅内容高度,不把中间 Tab 区挤没 */
.hf-landscape-column {
	flex-shrink: 0;
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	box-sizing: border-box;
	padding: 14px 10px 0;
	position: relative;
	z-index: 1;
}

/* 横屏侧栏:用户区 / Tab / 底按钮同一竖直中轴 */
.hf-landscape-user {
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	box-sizing: border-box;
	padding-top: 0;
	flex-shrink: 0;
}

.hf-landscape-profile {
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
}

/* 与 MyCenterMain .name 一致;与 Tab 文案同宽便于视觉对齐 */
.hf-landscape-name {
	margin-top: 10px;
	font-size: 14px;
	font-weight: 600;
	color: #1a2433;
	line-height: 24px;
	text-align: center;
	width: 100%;
	max-width: 104px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hf-landscape-footer {
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	box-sizing: border-box;
	flex-shrink: 0;
	padding: 24px 10px 4px; /* ✅ 增加上下内边距 */
}

/* ✅ 分隔线:与上方 Tab 区域明确区分 */
.hf-landscape-footer-divider {
	width: 40px;
	height: 1px; /* ✅ 改为 1px,更细腻 */
	background-color: #e5edf8;
	// margin-bottom: 10px; /* ✅ 分隔线与按钮的间距 */
}

.hf-landscape-footer-btn {
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	// padding: 2px 0; /* ✅ 按钮内边距 */
	margin-top: 8px; /* ✅ 按钮之间的间距 */
	border-radius: 8px;
	transition: background-color 0.2s;
}

.hf-landscape-footer-btn:active {
	background-color: #f5f7fa; /* ✅ 点击反馈 */
}

.hf-landscape-footer-icon {
	width: 24px; /* ✅ 缩小图标,与导航图标(28px)形成层次 */
	height: 24px;
	flex-shrink: 0;
	opacity: 0.7; /* ✅ 降低透明度,与导航图标区分 */
}

.hf-landscape-footer-label {
	margin-top: 4px;
	font-size: 11px; /* ✅ 小字号 */
	color: #8a98b5; /* ✅ 灰色文字 */
	text-align: center;
	line-height: 16px;
}

.hf-landscape-footer-switch {
	font-size: 13px;
	font-weight: 600;
	color: #3773f8;
	line-height: 20px;
	text-align: center;
}

/* 横屏侧栏 Tab:占满中间 landscape-tabbar-wrap,条目在剩余高度内垂直居中 */
.landscape-vertical-tabs {
	flex: 1;
	min-height: 0;
	width: 100%;
	padding-left: var(--tabbar-padding, 16px);
	padding-right: var(--tabbar-padding, 16px);
	padding-top: 8px;
	padding-bottom: 8px;
	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: 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;
	align-items: center;
	justify-content: center;
}

.landscape-vertical-tabs__icon {
	width: var(--tabbar-icon-size, 28px);
	height: var(--tabbar-icon-size, 28px);
	flex-shrink: 0;
}

.landscape-vertical-tabs__label {
	margin-top: 6px;
	font-size: 12px;
	color: #8a98b5;
	text-align: center;
	width: 100%;
	max-width: 104px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.landscape-vertical-tabs__item--active .landscape-vertical-tabs__label {
	color: #3773f8;
	font-weight: 500;
}
</style>