cu-custom.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. // backIndex: {
  52. // type: bool,
  53. // default: false
  54. // }
  55. },
  56. methods: {
  57. BackPage() {
  58. // if (this.backIndex) {
  59. // uni.switchTab({
  60. // url: 'pages/user/index'
  61. // });
  62. // }else {
  63. uni.navigateBack({
  64. delta: 1
  65. });
  66. // }
  67. }
  68. }
  69. }
  70. </script>
  71. <style>
  72. </style>