cu-custom.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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" v-if="toTopPage">
  10. <slot name="topPage"></slot>
  11. </view>
  12. <view class="action border-custom" v-if="isBack" :style="'width:'+Custom.width+'px;height:'+Custom.height+'px;margin-left:calc(750rpx - '+Custom.right+'px)'">
  13. <text class="cuIcon-back" @tap="BackPage"></text>
  14. <text class="cuIcon-homefill" @tap="toHome"></text>
  15. </view>
  16. <view class="content" :style="[{top:StatusBar + 'px'}]">
  17. <slot name="content"></slot>
  18. </view>
  19. <slot name="right"></slot>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. StatusBar: this.StatusBar,
  29. CustomBar: this.CustomBar,
  30. Custom: this.Custom
  31. };
  32. },
  33. name: 'cu-custom',
  34. computed: {
  35. style() {
  36. var StatusBar= this.StatusBar;
  37. var CustomBar= this.CustomBar;
  38. var bgImage = this.bgImage;
  39. var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
  40. if (this.bgImage) {
  41. style = `${style}background-image:url(${bgImage});`;
  42. }
  43. return style
  44. }
  45. },
  46. props: {
  47. bgColor: {
  48. type: String,
  49. default: ''
  50. },
  51. isBack: {
  52. type: [Boolean, String],
  53. default: false
  54. },
  55. toTopPage: {
  56. type: [Boolean, String],
  57. default: false
  58. },
  59. bgImage: {
  60. type: String,
  61. default: ''
  62. },
  63. isCustom: {
  64. type: [Boolean, String],
  65. default: false
  66. },
  67. },
  68. methods: {
  69. BackPage() {
  70. uni.navigateBack({
  71. delta: 1
  72. });
  73. },
  74. toHome(){
  75. wx.redirectTo({
  76. url: '/pages/index/index'
  77. });
  78. }
  79. }
  80. }
  81. </script>
  82. <style>
  83. </style>