| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <template>
- <view class="navbar__container">
- <Theme>
- <up-navbar
- placeholder
- :border="border"
- :fixed="fixed"
- :bgColor="bgColor"
- :height="height"
- :style="{ '--borderColor': borderColor }"
- @leftClick="handleLeftClick"
- @rightClick="handleRightClick"
- v-if="!navShow"
- >
- <template #left>
- <slot name="left">
- <view class="left">
- <u-icon
- :size="iconSize"
- :color="leftIconColor"
- :name="!leftShow ? 'arrow-left' : leftIcon"
- ></u-icon>
- <view class="left_text" :style="leftStyle" v-if="!!leftText">{{
- t(leftText)
- }}</view>
- </view>
- </slot>
- </template>
- <template #center>
- <slot name="center">
- <trans
- class="nav_title"
- :style="navStyle"
- v-if="!!title"
- :_t="title"
- />
- </slot>
- </template>
- <template #right>
- <slot name="right"></slot>
- </template>
- </up-navbar>
- </Theme>
- </view>
- </template>
- <script setup>
- import { t } from "@/locale";
- const props = defineProps({
- autoBack: Boolean,
- fixed: Boolean,
- leftText: {
- type: [String, Number],
- default: "",
- },
- bgColor: {
- type: String,
- default: "var(--light)",
- },
- iconSize: {
- type: Number,
- default: 20,
- },
- leftIconColor: {
- type: String,
- default: "var(--text)",
- },
- title: {
- type: String,
- default: "",
- },
- leftIcon: {
- type: String,
- default: "",
- },
- leftShow: Boolean,
- border: Boolean,
- height: {
- type: String,
- default: "44px",
- },
- leftStyle: {
- type: Object,
- default: () => ({}),
- },
- navStyle: {
- type: Object,
- default: () => ({}),
- },
- borderColor: {
- type: String,
- default: "var(--bor-color)",
- },
- navShow: Boolean,
- });
- const emit = defineEmits(["leftClick", "rightClick"]);
- const handleLeftClick = () => {
- if (props.autoBack) return emit("leftClick");
- if (props.leftShow) return;
- uni.navigateBack();
- };
- const handleRightClick = () => {
- if (props.leftShow) return;
- emit("rightClick");
- };
- </script>
- <style lang="less" scoped>
- @import url("../style.less");
- .navbar__container {
- max-width: 1536rpx;
- }
- .left {
- .flex_position(center, flex-end);
- /deep/ .u-icon--right {
- .u-icon__icon {
- font-weight: 700 !important;
- }
- }
- .left_text {
- .size(15px);
- color: var(--text);
- margin-left: 3px;
- }
- }
- .nav_title {
- width: 12.5rem;
- .size(14px);
- color: var(--text);
- text-align: center;
- font-weight: 700;
- }
- /deep/ .u-border-bottom {
- border-color: var(--bor-color) !important;
- }
- /deep/ .u-navbar--fixed {
- z-index: 1000;
- }
- </style>
|