en-nav.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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-title">
  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. bgckgroundBox: {
  42. type: String,
  43. default: '#fff'
  44. },
  45. // titleColor: {
  46. // type: String,
  47. // default: '#fff'
  48. // },
  49. // bgColor: {
  50. // type: String,
  51. // default: '#707'
  52. // },
  53. },
  54. computed: {
  55. style() {
  56. let _style = `height: ${this.customBarH}px;`
  57. return _style
  58. }
  59. },
  60. watch: {
  61. leftShow(e) {
  62. if (e == true) {
  63. this.left = 0
  64. }
  65. }
  66. },
  67. methods: {
  68. goBack() {
  69. if(!this.leftShow){
  70. return ;
  71. }
  72. this.$emit('leftClick')
  73. }
  74. },
  75. created() {
  76. let self = this;
  77. uni.getSystemInfo({
  78. success: function(e) {
  79. self.statusBarH = e.statusBarHeight + 10
  80. let custom = wx.getMenuButtonBoundingClientRect()
  81. self.customBarH = custom.height
  82. }
  83. })
  84. }
  85. }
  86. </script>
  87. <style scoped lang="scss">
  88. @import url("../../static/css/en-common.css") ;
  89. .header {
  90. width: 100vw;
  91. position: fixed;
  92. left: 0;
  93. top: 0;
  94. z-index: 999999;
  95. }
  96. .box-title {
  97. width: 100vw;
  98. }
  99. .flexbox {
  100. display: flex;
  101. justify-content: space-between;
  102. padding: 0 20px;
  103. .iconfont{
  104. color: #fff;
  105. }
  106. .title-text {
  107. font-size: 36rpx;
  108. font-weight: 600;
  109. }
  110. .icon-left {
  111. width: 20px;
  112. height: 20px;
  113. }
  114. }
  115. </style>