en-nav.vue 4.5 KB

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