en-nav.vue 4.0 KB

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