TabbarPortrait.uvue 2.12 KB
<template>
	<view class="home-tabbar home-tabbar-portrait 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"
		
		           @change="emit('tabChange', ($event as string | number))">
			<un-tabbar-item v-for="(item, index) in tabs"
			                :key="index"
			                :name="index"
			                :text="item.label">
				<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<{
  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";

/* 与 layout-root 注入的 index.vars.uts 中 --tabbar-icon-size 一致;横屏侧栏见 TabbarLandscape .landscape-vertical-tabs__icon */
.tabbar-icon-img {
	width: var(--tabbar-icon-size, 24px);
	height: var(--tabbar-icon-size, 24px);
}
</style>