cu-custom.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view>
  3. <view class="cu-custom" :style="[{height:CustomBar + 'px'}]">
  4. <view class="cu-bar fixed" :style="style" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor]">
  5. <view class="action" @tap="BackPage" v-if="isBack">
  6. <text class="cuIcon-back"></text>
  7. <slot name="backText"></slot>
  8. </view>
  9. <view class="content" :style="[{top:StatusBar + 'px'}]">
  10. <slot name="content"></slot>
  11. </view>
  12. <slot name="right"></slot>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. StatusBar: this.StatusBar,
  22. CustomBar: this.CustomBar
  23. };
  24. },
  25. name: 'cu-custom',
  26. computed: {
  27. style() {
  28. var StatusBar= this.StatusBar;
  29. var CustomBar= this.CustomBar;
  30. var bgImage = this.bgImage;
  31. var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
  32. if (this.bgImage) {
  33. style = `${style}background-image:url(${bgImage});`;
  34. }
  35. return style
  36. }
  37. },
  38. props: {
  39. bgColor: {
  40. type: String,
  41. default: ''
  42. },
  43. isBack: {
  44. type: [Boolean, String],
  45. default: false
  46. },
  47. bgImage: {
  48. type: String,
  49. default: ''
  50. },
  51. },
  52. methods: {
  53. BackPage() {
  54. uni.navigateBack({
  55. delta: 1
  56. });
  57. }
  58. }
  59. }
  60. </script>
  61. <style>
  62. </style>