时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.5 KiB

4 years ago
  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="action">
  10. <slot name="left"></slot>
  11. </view>
  12. <view class="content" :style="[{top:StatusBar + 'px'}]">
  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: 'bg-white'
  45. },
  46. isBack: {
  47. type: [Boolean, String],
  48. default: true
  49. },
  50. bgImage: {
  51. type: String,
  52. default: ''
  53. },
  54. },
  55. methods: {
  56. BackPage() {
  57. // #ifdef H5
  58. window.history.go(-1)
  59. // #endif
  60. // #ifndef H5
  61. uni.navigateBack({
  62. delta: 1
  63. });
  64. // #endif
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. .bg-img{
  71. background-position: initial !important;
  72. }
  73. </style>