|  | @@ -1,13 +1,6 @@
 | 
	
		
			
				|  |  |  <template>
 | 
	
		
			
				|  |  | -  <div
 | 
	
		
			
				|  |  | -    class="mheader"
 | 
	
		
			
				|  |  | -    :style="{ height: `calc(${titleHeight}px + ${navBarHeight}px)` }"
 | 
	
		
			
				|  |  | -  >
 | 
	
		
			
				|  |  | -    <header
 | 
	
		
			
				|  |  | -      class="m-nav-header"
 | 
	
		
			
				|  |  | -      :class="[isFixed ? 'fixed' : '']"
 | 
	
		
			
				|  |  | -      :style="[headStyle]"
 | 
	
		
			
				|  |  | -    >
 | 
	
		
			
				|  |  | +  <div class="mheader">
 | 
	
		
			
				|  |  | +    <header class="m-nav-header" :class="[isFixed ? 'fixed' : '']">
 | 
	
		
			
				|  |  |        <div class="m-nav-bar__left" @click="goBack" v-show="isBack">
 | 
	
		
			
				|  |  |          <van-icon class="arrow-left" name="arrow-left"></van-icon>
 | 
	
		
			
				|  |  |        </div>
 | 
	
	
		
			
				|  | @@ -28,15 +21,10 @@
 | 
	
		
			
				|  |  |          这里
 | 
	
		
			
				|  |  |      </template>
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  | -import { postMessage } from "@/helpers/native-message";
 | 
	
		
			
				|  |  |  export default {
 | 
	
		
			
				|  |  |    name: "mheader",
 | 
	
		
			
				|  |  |    props: {
 | 
	
		
			
				|  |  |      name: String, // 标题名称
 | 
	
		
			
				|  |  | -    isNative: {
 | 
	
		
			
				|  |  | -      type: Boolean,
 | 
	
		
			
				|  |  | -      default: true,
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  |      isBack: {
 | 
	
		
			
				|  |  |        // 是否显示返回按钮
 | 
	
		
			
				|  |  |        type: Boolean,
 | 
	
	
		
			
				|  | @@ -59,56 +47,7 @@ export default {
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  | -  data() {
 | 
	
		
			
				|  |  | -    return {
 | 
	
		
			
				|  |  | -      navBarHeight: 0, // 顶部导航栏高度
 | 
	
		
			
				|  |  | -      headStyle: {},
 | 
	
		
			
				|  |  | -      titleHeight: 44, // 顶部导航高度(默认44px)
 | 
	
		
			
				|  |  | -    };
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  | -  mounted() {
 | 
	
		
			
				|  |  | -    if (!this.isNative) {
 | 
	
		
			
				|  |  | -      postMessage({ api: "setBarStatus", content: { status: 0 } });
 | 
	
		
			
				|  |  | -      this.getNav();
 | 
	
		
			
				|  |  | -      this.isBack = false;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  |    methods: {
 | 
	
		
			
				|  |  | -    async getNav() {
 | 
	
		
			
				|  |  | -      let sNavHeight = sessionStorage.getItem("navHeight");
 | 
	
		
			
				|  |  | -      let sTitleHeight = sessionStorage.getItem("titleHeight");
 | 
	
		
			
				|  |  | -      if (sNavHeight && sTitleHeight) {
 | 
	
		
			
				|  |  | -        this.navBarHeight = sNavHeight;
 | 
	
		
			
				|  |  | -        this.headStyle = {
 | 
	
		
			
				|  |  | -          paddingTop: sNavHeight + "px",
 | 
	
		
			
				|  |  | -          height: sTitleHeight + "px",
 | 
	
		
			
				|  |  | -          lineHeight: sTitleHeight + "px",
 | 
	
		
			
				|  |  | -        };
 | 
	
		
			
				|  |  | -      } else {
 | 
	
		
			
				|  |  | -        await postMessage({ api: "getNavHeight" }, (res) => {
 | 
	
		
			
				|  |  | -          const { content } = res;
 | 
	
		
			
				|  |  | -          let headStyle = {};
 | 
	
		
			
				|  |  | -          const dpi = content.dpi || 2;
 | 
	
		
			
				|  |  | -          if (content.navHeight) {
 | 
	
		
			
				|  |  | -            const navHeight = content.navHeight / dpi;
 | 
	
		
			
				|  |  | -            sessionStorage.setItem("navHeight", navHeight);
 | 
	
		
			
				|  |  | -            this.navBarHeight = navHeight;
 | 
	
		
			
				|  |  | -            headStyle = {
 | 
	
		
			
				|  |  | -              paddingTop: navHeight + "px",
 | 
	
		
			
				|  |  | -            };
 | 
	
		
			
				|  |  | -          }
 | 
	
		
			
				|  |  | -          if (content.titleHeight) {
 | 
	
		
			
				|  |  | -            // 导航栏的高度
 | 
	
		
			
				|  |  | -            const titleHeight = content.titleHeight / dpi;
 | 
	
		
			
				|  |  | -            sessionStorage.setItem("titleHeight", titleHeight);
 | 
	
		
			
				|  |  | -            this.titleHeight = titleHeight;
 | 
	
		
			
				|  |  | -            headStyle.height = titleHeight + "px";
 | 
	
		
			
				|  |  | -            headStyle.lineHeight = titleHeight + "px";
 | 
	
		
			
				|  |  | -          }
 | 
	
		
			
				|  |  | -          this.headStyle = headStyle;
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  |      goBack() {
 | 
	
		
			
				|  |  |        // 返回上层
 | 
	
		
			
				|  |  |        let urlObj = this.backUrl;
 | 
	
	
		
			
				|  | @@ -127,12 +66,6 @@ export default {
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  | -  beforeDestroy() {
 | 
	
		
			
				|  |  | -    if (!this.isNative) {
 | 
	
		
			
				|  |  | -      postMessage({ api: "setBarStatus", content: { status: 1 } });
 | 
	
		
			
				|  |  | -      this.isBack = true;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -  },
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  </script>
 | 
	
		
			
				|  |  |  
 |