en-nav.vue 4.1 KB

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