123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <template>
- <view class="capsule" :style="{ backgroundColor: bgColor, paddingTop: top + 'px' }">
- <view class="title" v-if="showBorder" :style="{ height: height, paddingLeft: titleLeft, display: isSecurity ? 'none' : 'block' }">
- <slot name="top"></slot>
- </view>
- </view>
- </template>
- <script>
- export default {
- created() {
-
-
- let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
-
- this.height = menuButtonInfo.height + 'px'
- this.top = menuButtonInfo.top
-
- uni.getSystemInfo({
- success: res => {
-
-
- if (this.isSecurity) {
- this.top = res.safeAreaInsets.bottom + 'px'
- return
- }
- this.titleLeft = res.windowWidth - menuButtonInfo.right + "px"
- }
- })
-
- },
- props: {
- title: {
- type: String,
- },
- bgColor: {
- type: String,
- },
-
- isSecurity: {
- type: Boolean,
- default: false
- },
-
- showBorder: {
- type: Boolean,
- default: false
- },
- showIcon: {
- type: Boolean,
- default: false
- },
- },
- data() {
- return {
- height: null,
- top: null,
- titleLeft: null,
- }
- },
- mounted () {
-
- this.$emit('getHeight', this.top)
- },
- methods: {
- }
- }
- </script>
- <style lang="scss" scoped>
- .capsule {
- width: 100%;
- .title {
- padding-left: 30rpx;
- box-sizing: border-box;
- color: rgba(0, 0, 0, 0.8);
- font-size: 32rpx;
- font-weight: 700;
- display: flex !important;
- align-items: center;
- gap: 10rpx;
- }
- }
- </style>
|