cu-custom.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="cu-custom" :style="[{ height: CustomBar + 'px' }]">
  3. <view v-if="linear" class="fixed-bg liner-ground liner-height"></view>
  4. <view class="cu-bar fixed" :style="style" :class="[bgImage != '' ? 'none-bg text-white bg-img' : '', bgColor]">
  5. <view class="action" v-if="isBack">
  6. <text class="cuIcon-back cu-back text-white" @tap="BackPage" v-if="showBackIcon"></text>
  7. <slot name="backText"></slot>
  8. </view>
  9. <view class="content text-white" style="font-weight: 600;" :style="[{ top: StatusBar + 'px' }]"><slot name="content"></slot></view>
  10. <view style="margin-left: auto;margin-right: 15rpx;color: #fff;font-size: 14px;font-weight: 500;"><slot name="right"></slot></view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. data() {
  17. return {
  18. StatusBar: this.StatusBar,
  19. CustomBar: this.CustomBar
  20. };
  21. },
  22. name: 'cu-custom',
  23. computed: {
  24. style() {
  25. var StatusBar = this.StatusBar;
  26. var CustomBar = this.CustomBar;
  27. var bgImage = this.bgImage;
  28. var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
  29. if (this.bgImage) {
  30. style = `${style}background-image:url(${bgImage});`;
  31. }
  32. return style;
  33. }
  34. },
  35. props: {
  36. bgColor: {
  37. type: String,
  38. default: ''
  39. },
  40. linear: {
  41. type: Boolean,
  42. default: false
  43. },
  44. isBack: {
  45. type: [Boolean, String],
  46. default: false
  47. },
  48. showBackIcon: {
  49. type: Boolean,
  50. default: true
  51. },
  52. bgImage: {
  53. type: String,
  54. default: ''
  55. }
  56. },
  57. methods: {
  58. BackPage() {
  59. uni.navigateBack({
  60. delta: 1
  61. });
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="scss">
  67. .liner-height{
  68. height: 20vh;
  69. }
  70. .fixed-bg{
  71. position: absolute;
  72. top: 0;
  73. left: 0;
  74. right: 0;
  75. z-index: 0;
  76. transform: translateZ(-100px);
  77. mix-blend-mode: screen;
  78. pointer-events: none;
  79. }
  80. .liner-ground{
  81. background: linear-gradient(180deg, #2cc8a6 44px, transparent);
  82. }
  83. </style>