123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <template>
- <!-- 自定义头部 -->
- <div class="">
- <div v-if="is_status_bar" :style="'height:'+StatusBar+'px'"></div>
- <view v-else :style="'height:'+CustomBar+'px'" >
- <view class="cu-custom title-size fixed fixed-top" :style="style" :class="[bgImage!=''?' text-white bg-img':'','']">
- <view
- class=" box flew flew-between w-100"
- :style="[{height:CustomBar-StatusBar+'px',top:StatusBar+'px'}]"
- >
- <view class="action flew-column flew flew-center " @tap="BackPage" v-if="isBack">
- <!-- <text class="cuIcon-back"></text>-->
- <slot name="backText"></slot>
- </view>
- <view class="content">
- <slot name="content"></slot>
- </view>
- <view class="right ">
- <slot name="right"></slot>
- </view>
- </view>
- </view>
- </view>
- </div>
- </template>
- <script>
- export default {
- name: "h_custom",
- data() {
- return {
- CustomBar: '',// 头部标题高度
- StatusBar: ''//标题内容距离顶部的距离
- }
- },
- computed: {
- style() {
- var StatusBar= this.StatusBar;
- var CustomBar= this.CustomBar;
- var bgImage = this.bgImage;
- var bgColor = this.bgColor;
- var textColor = this.textColor;
- var bgLinear = this.bgLinear;
- var style = `height:${CustomBar}px;color:${textColor};`;
- if (bgImage) {
- style = `${style}background-image:url(${bgImage});`;
- }
- if(bgColor){
- style = `${style}background-color:${bgColor};`;
- }
- if(bgLinear){
- style = `${style}background-image:${bgLinear};`;
- }
-
-
- return style
- }
- },
- props: {
- bgColor: {
- type: String,
- default: '#fff'
- },
- textColor: {
- type: String,
- default: '#000000'
- },
- isBack: {
- type: [Boolean, String],
- default: false
- },
- is_status_bar: {
- type: [Boolean, String],
- default: false
- },
- bgImage: {
- type: String,
- default: ''
- },
- circle: {
- type: [Boolean, String],
- default: false
- },
- bgLinear: {
- type: [ String],
- default: ''
- },
-
-
- },
- methods: {
- BackPage() {
- uni.navigateBack()
-
- },
- initTitleBar() {
-
-
- let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
-
-
- this.StatusBar = statusBarHeight;
- this.CustomBar = statusBarHeight+45;
-
-
-
-
-
- }
-
- },
- mounted() {
-
-
- // let custom = uni.getMenuButtonBoundingClientRect();
-
-
- this.initTitleBar()
-
-
-
- }
- }
- </script>
- <style>
- </style>
|