en-nav.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="" :style="[{ 'background':bgckgroundBox}]">
  3. <view class="header" :style="[{'height': customBarH + 'px','background':bgckgroundBox, 'padding-top': statusBarH + 'px'}]">
  4. <view class="flexbox" :style="[{'height': customBarH + 'px'}]">
  5. <view class="left-button" @tap="goBack">
  6. <image class="back-img" :src="'/static/img/common/back'+(titleColor==='#fff'?'-white':'')+'.png'" mode="aspectFill"></image>
  7. </view>
  8. <view class="title-text sys-height-44" :style="[{'marginLeft':left +'px','color':titleColor}]">{{title}}</view>
  9. <view class="right-button button" @click="rightClick">
  10. <view class="right-data" v-if="rightShow">
  11. <text class="rightName sys-weight-600" :style="[{'color':titleColor}]" v-if="rightType===1">{{rightText}}</text>
  12. <slot name="right" v-else> </slot>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="box-title">
  18. <view class="" :style="[{'height': (customBarH+statusBarH) + 'px', 'padding-top': statusBarH + 'px'}]">
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import tools from "@/service/tools";
  25. export default {
  26. name: "en-nav",
  27. data() {
  28. return {
  29. statusBarH: 0,
  30. customBarH: 0,
  31. left: 35,
  32. isXcx:false
  33. }
  34. },
  35. props: {
  36. title: {
  37. type: String,
  38. default: ''
  39. },
  40. leftShow: {
  41. type: Boolean,
  42. default: true
  43. },
  44. bgckgroundBox: {
  45. type: String,
  46. default: '#fff'
  47. },
  48. titleColor: {
  49. type: String,
  50. default: '#fff'
  51. },
  52. rightText: {
  53. type: String,
  54. default: ''
  55. },
  56. rightShow: {
  57. type: Boolean,
  58. default: false
  59. },
  60. rightType: {
  61. default: 1
  62. },
  63. },
  64. computed: {
  65. },
  66. watch: {
  67. leftShow(e) {
  68. if (e == true) {
  69. this.left = 0
  70. }
  71. }
  72. },
  73. methods: {
  74. rightClick() {
  75. this.$emit('rightClick')
  76. },
  77. goBack() {
  78. if(!this.leftShow){
  79. return ;
  80. }
  81. // this.$emit('leftClick')
  82. tools.leftClick()
  83. }
  84. },
  85. created() {
  86. uni.getSystemInfo({
  87. success: (e) =>{
  88. this.statusBarH = e.statusBarHeight + 10
  89. let custom=0;
  90. //#ifdef MP-WEIXIN
  91. custom = wx.getMenuButtonBoundingClientRect()
  92. this.customBarH = custom.height
  93. //#endif
  94. //#ifdef H5
  95. this.customBarH = 30
  96. this.left=0
  97. //#endif
  98. // #ifdef APP-PLUS
  99. // this.customBarH = 34
  100. this.left=0
  101. //#endif
  102. console.log('self.customBarH---------'+this.customBarH)
  103. this.$emit('navHeight', this.customBarH+this.statusBarH)
  104. }
  105. })
  106. //#ifdef MP-WEIXIN
  107. this.isXcx=true
  108. //#endif
  109. }
  110. }
  111. </script>
  112. <style scoped lang="scss">
  113. @import url("../../../static/css/en-common.css") ;
  114. .header {
  115. width: 100%;
  116. position: fixed;
  117. left: 0;
  118. top: 0;
  119. z-index: 99999;
  120. .flexbox {
  121. display: flex;
  122. justify-content: space-between;
  123. align-items: center;
  124. padding: 0 12px;
  125. position: relative;
  126. .left-button{
  127. position: absolute;
  128. left: 16rpx;
  129. top: 10rpx;
  130. .back-img{
  131. width: 40rpx;
  132. height: 40rpx;
  133. }
  134. }
  135. .iconfont{
  136. color: #333333;
  137. }
  138. .title-text {
  139. width: 100%;
  140. text-align: center;
  141. font-size: 36rpx;
  142. font-weight: 600;
  143. }
  144. .icon-left {
  145. width: 20px;
  146. height: 20px;
  147. }
  148. .button {
  149. position: absolute;
  150. right: 16rpx;
  151. // z-index: 5;
  152. // width: 21px;
  153. .rightName {
  154. font-size: 32rpx;
  155. }
  156. .r-but{
  157. color: #fff;
  158. font-size: 12px;
  159. padding: 5px;
  160. border-radius: 3px;
  161. }
  162. }
  163. }
  164. .flexbox-xcx{
  165. justify-content:left;
  166. position: relative;
  167. .right-button{
  168. position: absolute;
  169. right: 220rpx;
  170. }
  171. }
  172. }
  173. .box-title {
  174. //background-color:#FF0000 ;
  175. }
  176. </style>