en-nav.vue 4.8 KB

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