From 68c5ef7d9fea3f911e250fb5f8b300bc76099e49 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 26 十月 2023 13:55:49 +0800
Subject: [PATCH] 小程序
---
minipro_standard/uni_modules/uview-ui/components/u-navbar/u-navbar.vue | 186 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 186 insertions(+), 0 deletions(-)
diff --git a/minipro_standard/uni_modules/uview-ui/components/u-navbar/u-navbar.vue b/minipro_standard/uni_modules/uview-ui/components/u-navbar/u-navbar.vue
new file mode 100644
index 0000000..2b206b7
--- /dev/null
+++ b/minipro_standard/uni_modules/uview-ui/components/u-navbar/u-navbar.vue
@@ -0,0 +1,186 @@
+<template>
+ <view class="u-navbar">
+ <view
+ class="u-navbar__placeholder"
+ v-if="fixed && placeholder"
+ :style="{
+ height: $u.addUnit($u.getPx(height) + $u.sys().statusBarHeight,'px'),
+ }"
+ ></view>
+ <view :class="[fixed && 'u-navbar--fixed']">
+ <u-status-bar
+ v-if="safeAreaInsetTop"
+ :bgColor="bgColor"
+ ></u-status-bar>
+ <view
+ class="u-navbar__content"
+ :class="[border && 'u-border-bottom']"
+ :style="{
+ height: $u.addUnit(height),
+ backgroundColor: bgColor,
+ }"
+ >
+ <view
+ class="u-navbar__content__left"
+ hover-class="u-navbar__content__left--hover"
+ hover-start-time="150"
+ @tap="leftClick"
+ >
+ <slot name="left">
+ <u-icon
+ v-if="leftIcon"
+ :name="leftIcon"
+ :size="leftIconSize"
+ :color="leftIconColor"
+ ></u-icon>
+ <text
+ v-if="leftText"
+ :style="{
+ color: leftIconColor
+ }"
+ class="u-navbar__content__left__text"
+ >{{ leftText }}</text>
+ </slot>
+ </view>
+ <slot name="center">
+ <text
+ class="u-line-1 u-navbar__content__title"
+ :style="[{
+ width: $u.addUnit(titleWidth),
+ }, $u.addStyle(titleStyle)]"
+ >{{ title }}</text>
+ </slot>
+ <view
+ class="u-navbar__content__right"
+ v-if="$slots.right || rightIcon || rightText"
+ @tap="rightClick"
+ >
+ <slot name="right">
+ <u-icon
+ v-if="rightIcon"
+ :name="rightIcon"
+ size="20"
+ ></u-icon>
+ <text
+ v-if="rightText"
+ class="u-navbar__content__right__text"
+ >{{ rightText }}</text>
+ </slot>
+ </view>
+ </view>
+ </view>
+ </view>
+</template>
+
+<script>
+ import props from './props.js';
+ /**
+ * Navbar 鑷畾涔夊鑸爮
+ * @description 姝ょ粍浠朵竴鑸敤浜庡湪鐗规畩鎯呭喌涓嬶紝闇�瑕佽嚜瀹氫箟瀵艰埅鏍忕殑鏃跺�欑敤鍒帮紝涓�鑸缓璁娇鐢╱ni-app甯︾殑瀵艰埅鏍忋��
+ * @tutorial https://www.uviewui.com/components/navbar.html
+ * @property {Boolean} safeAreaInsetTop 鏄惁寮�鍚《閮ㄥ畨鍏ㄥ尯閫傞厤 锛堥粯璁� true 锛�
+ * @property {Boolean} placeholder 鍥哄畾鍦ㄩ《閮ㄦ椂锛屾槸鍚︾敓鎴愪竴涓瓑楂樺厓绱狅紝浠ラ槻姝㈠闄� 锛堥粯璁� false 锛�
+ * @property {Boolean} fixed 瀵艰埅鏍忔槸鍚﹀浐瀹氬湪椤堕儴 锛堥粯璁� false 锛�
+ * @property {Boolean} border 瀵艰埅鏍忓簳閮ㄦ槸鍚︽樉绀轰笅杈规 锛堥粯璁� false 锛�
+ * @property {String} leftIcon 宸﹁竟杩斿洖鍥炬爣鐨勫悕绉帮紝鍙兘涓簎View鑷甫鐨勫浘鏍� 锛堥粯璁� 'arrow-left' 锛�
+ * @property {String} leftText 宸﹁竟鐨勬彁绀烘枃瀛�
+ * @property {String} rightText 鍙宠竟鐨勬彁绀烘枃瀛�
+ * @property {String} rightIcon 鍙宠竟杩斿洖鍥炬爣鐨勫悕绉帮紝鍙兘涓簎View鑷甫鐨勫浘鏍�
+ * @property {String} title 瀵艰埅鏍忔爣棰橈紝濡傝缃负绌哄瓧绗︼紝灏嗕細闅愯棌鏍囬鍗犱綅鍖哄煙
+ * @property {String} bgColor 瀵艰埅鏍忚儗鏅缃� 锛堥粯璁� '#ffffff' 锛�
+ * @property {String | Number} titleWidth 瀵艰埅鏍忔爣棰樼殑鏈�澶у搴︼紝鍐呭瓒呭嚭浼氫互鐪佺暐鍙烽殣钘� 锛堥粯璁� '400rpx' 锛�
+ * @property {String | Number} height 瀵艰埅鏍忛珮搴�(涓嶅寘鎷姸鎬佹爮楂樺害鍦ㄥ唴锛屽唴閮ㄨ嚜鍔ㄥ姞涓�)锛堥粯璁� '44px' 锛�
+ * @property {String | Number} leftIconSize 宸︿晶杩斿洖鍥炬爣鐨勫ぇ灏忥紙榛樿 20px 锛�
+ * @property {String | Number} leftIconColor 宸︿晶杩斿洖鍥炬爣鐨勯鑹诧紙榛樿 #303133 锛�
+ * @property {Boolean} autoBack 鐐瑰嚮宸︿晶鍖哄煙(杩斿洖鍥炬爣)锛屾槸鍚﹁嚜鍔ㄨ繑鍥炰笂涓�椤碉紙榛樿 false 锛�
+ * @property {Object | String} titleStyle 鏍囬鐨勬牱寮忥紝瀵硅薄鎴栧瓧绗︿覆
+ * @event {Function} leftClick 鐐瑰嚮宸︿晶鍖哄煙
+ * @event {Function} rightClick 鐐瑰嚮鍙充晶鍖哄煙
+ * @example <u-navbar title="鍓戞湭閰嶅Ε锛屽嚭闂ㄥ凡鏄睙婀�" left-text="杩斿洖" right-text="甯姪" @click-left="onClickBack" @click-right="onClickRight"></u-navbar>
+ */
+ export default {
+ name: 'u-navbar',
+ mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
+ data() {
+ return {
+
+ }
+ },
+ methods: {
+ // 鐐瑰嚮宸︿晶鍖哄煙
+ leftClick() {
+ // 濡傛灉閰嶇疆浜哸utoBack锛岃嚜鍔ㄨ繑鍥炰笂涓�椤�
+ this.$emit('leftClick')
+ if(this.autoBack) {
+ uni.navigateBack()
+ }
+ },
+ // 鐐瑰嚮鍙充晶鍖哄煙
+ rightClick() {
+ this.$emit('rightClick')
+ },
+ }
+ }
+</script>
+
+<style lang="scss" scoped>
+ @import "../../libs/css/components.scss";
+
+ .u-navbar {
+
+ &--fixed {
+ position: fixed;
+ left: 0;
+ right: 0;
+ top: 0;
+ z-index: 11;
+ }
+
+ &__content {
+ @include flex(row);
+ align-items: center;
+ height: 44px;
+ background-color: #9acafc;
+ position: relative;
+ justify-content: center;
+
+ &__left,
+ &__right {
+ padding: 0 13px;
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ @include flex(row);
+ align-items: center;
+ }
+
+ &__left {
+ left: 0;
+
+ &--hover {
+ opacity: 0.7;
+ }
+
+ &__text {
+ font-size: 15px;
+ margin-left: 3px;
+ }
+ }
+
+ &__title {
+ text-align: center;
+ font-size: 16px;
+ color: $u-main-color;
+ }
+
+ &__right {
+ right: 0;
+
+ &__text {
+ font-size: 15px;
+ margin-left: 3px;
+ }
+ }
+ }
+ }
+</style>
--
Gitblit v1.9.3