cu-navbar.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. backUrl: {
  48. type: String,
  49. default: ''
  50. },
  51. bgImage: {
  52. type: String,
  53. default: ''
  54. },
  55. },
  56. methods: {
  57. BackPage() {
  58. if(this.backUrl){
  59. uni.navigateTo({
  60. url: this.backUrl
  61. })
  62. }else{
  63. uni.navigateBack({
  64. delta: 1
  65. });
  66. }
  67. }
  68. }
  69. }
  70. </script>
  71. <style>
  72. </style>