en-nav.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="">
  3. <view class="header" :style="style">
  4. <view class="flexbox"
  5. :style="[{'height': customBarH + 'px', 'padding-top': statusBarH + 'px','background':bgckgroundBox}]">
  6. <view @tap="goBack">
  7. <text class="iconfont" v-if="leftShow">
  8. &#xe60e;
  9. </text>
  10. </view>
  11. <!-- <view v-if="false">
  12. </view> -->
  13. <view class="title-text" :style="[{'marginLeft':left +'px'}]">{{title}}</view>
  14. <view style="width: 36px;"></view>
  15. </view>
  16. </view>
  17. <view class="box">
  18. <view class="" :style="[{'height': customBarH + 'px', 'padding-top': statusBarH + 'px'}]">
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. statusBarH: 0,
  28. customBarH: 0,
  29. left: 35
  30. }
  31. },
  32. props: {
  33. title: {
  34. type: String,
  35. default: ''
  36. },
  37. leftShow: {
  38. type: Boolean,
  39. default: true
  40. },
  41. imgurl: {
  42. type: String,
  43. default: require('../../static/home/retreat.png')
  44. },
  45. bgckgroundBox: {
  46. type: String,
  47. default: '#fff'
  48. },
  49. // titleColor: {
  50. // type: String,
  51. // default: '#fff'
  52. // },
  53. // bgColor: {
  54. // type: String,
  55. // default: '#707'
  56. // },
  57. },
  58. computed: {
  59. style() {
  60. let _style = `height: ${this.customBarH}px;`
  61. return _style
  62. }
  63. },
  64. watch: {
  65. leftShow(e) {
  66. if (e == true) {
  67. this.left = 0
  68. }
  69. }
  70. },
  71. methods: {
  72. goBack() {
  73. if(!this.leftShow){
  74. return ;
  75. }
  76. this.$emit('leftClick')
  77. }
  78. },
  79. created() {
  80. let self = this;
  81. uni.getSystemInfo({
  82. success: function(e) {
  83. self.statusBarH = e.statusBarHeight + 10
  84. let custom = wx.getMenuButtonBoundingClientRect()
  85. self.customBarH = custom.height
  86. }
  87. })
  88. }
  89. }
  90. </script>
  91. <style scoped lang="scss">
  92. @font-face {
  93. font-family: 'iconfont';
  94. src: url('./iconfont.ttf') format('truetype');
  95. }
  96. .iconfont {
  97. font-family: "iconfont" !important;
  98. font-size: 36rpx;
  99. font-style: normal;
  100. -webkit-font-smoothing: antialiased;
  101. -moz-osx-font-smoothing: grayscale;
  102. color: #000;
  103. }
  104. .header {
  105. width: 100vw;
  106. position: fixed;
  107. left: 0;
  108. top: 0;
  109. // background: #fff;
  110. // position: relative;
  111. z-index: 999999;
  112. }
  113. .box {
  114. width: 100vw;
  115. // background: #fff;
  116. }
  117. .flexbox {
  118. display: flex;
  119. justify-content: space-between;
  120. padding: 0 20px;
  121. // background: #fff;
  122. //background: pink;
  123. .title-text {
  124. // flex: 1;
  125. font-size: 36rpx;
  126. font-weight: bold;
  127. font-weight: 600;
  128. // background: #fff;
  129. }
  130. .icon-left {
  131. width: 20px;
  132. height: 20px;
  133. }
  134. }
  135. </style>