en-nav.vue 4.0 KB

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