en-nav.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="top-nav-bg" :style="{'background-image':`url(${bgList[genre].bg_path})`}">
  3. <view class="header" style="z-index: 3;" :style="[{color},{height},{paddingTop},{justifyContent:justify}]">
  4. <view class="left" :style="[{color},{paddingTop}]" v-if="back" @click="onBack">
  5. <image class="back" src="/static/img/tabBar/nav-back.png"></image>
  6. </view>
  7. <view class="title" :style="[{marginLeft:justify == 'left'?'30rpx':0},{fontSize}]">
  8. <uni-icons class="m-r10" type="calendar" size="22" color="#fff" v-if="is_icons"></uni-icons>
  9. <text>{{title}}</text>
  10. </view>
  11. </view>
  12. <view :style="[{height:is_fixed? `${$tools.topHeight()+bgHeight}px`:`${$tools.topHeight()+fixedHeight}px`}]">
  13. </view>
  14. <!-- 带背景插槽 start-->
  15. <slot></slot>
  16. <!-- 带背景插槽 end-->
  17. <image class="header" style="width: 100%;z-index: 2;"
  18. :style="[{height:is_fixed?`${$tools.topHeight()+navsHeight}px` :`${$tools.topHeight()+fixedHeight}px`},{opacity:is_fixed?navOpacity:1},]"
  19. :src="bgList[genre].nav_path" mode="">
  20. </image>
  21. <!-- :src="genre == 0?'/static/img/index/top-nav.png':'/static/img/enNav/tab.png'" mode=""> -->
  22. </view>
  23. </template>
  24. <script>
  25. // 获取系统状态栏的高度
  26. let systemInfo = uni.getSystemInfoSync();
  27. let menuButtonInfo = {};
  28. // #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
  29. menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  30. // #endif
  31. export default {
  32. data() {
  33. return {
  34. height: 0,
  35. paddingTop: 0,
  36. navOpacity: 0,
  37. navHeight: 0,
  38. bgList: [{
  39. bg_path: 'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-bg.png?imageMogr2/quality/20',
  40. nav_path: '/static/img/index/top-nav.png '
  41. }, {
  42. bg_path: 'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/task-nav-bg.png',
  43. nav_path: '/static/img/enNav/tab.png'
  44. }, {
  45. bg_path: '',
  46. nav_path: ''
  47. }, {
  48. bg_path: '',
  49. nav_path: ''
  50. }],
  51. }
  52. },
  53. props: {
  54. genre: {
  55. type: Number,
  56. default: 0
  57. },
  58. type: {
  59. type: Number,
  60. default: 0
  61. },
  62. fontSize: {
  63. type: String,
  64. default: '32rpx'
  65. },
  66. title: {
  67. type: String,
  68. default: ''
  69. },
  70. justify: {
  71. type: String,
  72. default: 'center'
  73. },
  74. color: {
  75. type: String,
  76. default: '#333'
  77. },
  78. opacity: {
  79. type: Number,
  80. default: 0
  81. },
  82. back: {
  83. type: Boolean,
  84. default: true
  85. },
  86. is_fixed: {
  87. type: Boolean,
  88. default: false
  89. },
  90. is_filter: {
  91. type: Boolean,
  92. default: false
  93. },
  94. is_icons: {
  95. type: Boolean,
  96. default: false
  97. },
  98. fixedHeight: {
  99. type: Number,
  100. default: 0
  101. },
  102. bgHeight: {
  103. type: Number,
  104. default: 0
  105. },
  106. navsHeight: {
  107. type: Number,
  108. default: 0
  109. },
  110. },
  111. created() {
  112. const navTop = uni.getMenuButtonBoundingClientRect()
  113. this.height = navTop.height + 'px'
  114. this.paddingTop = navTop.top + 'px'
  115. this.navHeight = `${navTop.height+navTop.top}px`
  116. },
  117. watch: {
  118. opacity(newValue, oldValue) {
  119. this.navOpacity = newValue;
  120. }
  121. },
  122. methods: {
  123. // 左侧返回按钮调用
  124. onBack() {
  125. uni.navigateBack()
  126. this.$emit('onBack')
  127. },
  128. getTopBg(type) {
  129. switch (type) {
  130. case 0:
  131. return 'nav-bg1'
  132. case 0:
  133. return 'nav-bg1'
  134. case 0:
  135. return 'nav-bg1'
  136. default:
  137. break;
  138. }
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .header {
  145. position: fixed;
  146. width: 100%;
  147. display: flex;
  148. align-items: center;
  149. font-size: 26rpx;
  150. z-index: 1;
  151. padding-bottom: 10rpx;
  152. top: 0;
  153. .left {
  154. float: left;
  155. position: absolute;
  156. width: 100rpx;
  157. height: 42rpx;
  158. top: 0;
  159. bottom: 0;
  160. left: 30rpx;
  161. color: #fff;
  162. margin: auto;
  163. .back {
  164. width: 25rpx;
  165. height: 35rpx;
  166. }
  167. }
  168. .title {
  169. font-size: 32rpx;
  170. font-weight: bold;
  171. font-family: Source Han Sans CN;
  172. }
  173. }
  174. .top-nav-bg {
  175. background-repeat: no-repeat;
  176. background-size: 100% auto;
  177. }
  178. .nav-bg2 {
  179. background-image: url("https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-bg.png?imageMogr2/quality/20");
  180. }
  181. </style>