cu-custom.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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'}]" v-if="isBack">
  10. <slot name="content"></slot>
  11. </view>
  12. <view class="content-left" :style="[{top:StatusBar + 'px'}]" v-else>
  13. <slot name="content"></slot>
  14. </view>
  15. <slot name="right"></slot>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. StatusBar: this.StatusBar,
  25. CustomBar: this.CustomBar
  26. };
  27. },
  28. name: 'cu-custom',
  29. computed: {
  30. style() {
  31. var StatusBar= this.StatusBar;
  32. var CustomBar= this.CustomBar;
  33. var bgImage = this.bgImage;
  34. var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
  35. if (this.bgImage) {
  36. style = `${style}background-image:url(${bgImage});`;
  37. }
  38. return style
  39. }
  40. },
  41. props: {
  42. bgColor: {
  43. type: String,
  44. default: ''
  45. },
  46. isBack: {
  47. type: [Boolean, String],
  48. default: false
  49. },
  50. bgImage: {
  51. type: String,
  52. default: ''
  53. },
  54. },
  55. methods: {
  56. BackPage() {
  57. if (getCurrentPages().length < 2 && 'undefined' !== typeof __wxConfig) {
  58. let url = '/' + __wxConfig.pages[0]
  59. return uni.redirectTo({url})
  60. }
  61. uni.navigateBack({
  62. delta: 1
  63. });
  64. }
  65. }
  66. }
  67. </script>
  68. <style>
  69. .content-left{font-family: "bluevBold";font-size: 44rpx;font-weight: 800;padding-left: 20rpx;}
  70. </style>