en-nav.vue 3.7 KB

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