cu-custom.vue 1.5 KB

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