en-nav.vue 4.9 KB

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