cu-custom.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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" @click="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. // 不要使用本地路径,需要使用base64或网络路径,否则微信小程序不显示
  48. bgImage: {
  49. type: String,
  50. default: ''
  51. },
  52. },
  53. methods: {
  54. BackPage() {
  55. // 修改Colorui原代码
  56. // uni.navigateBack({
  57. // delta: 1
  58. // });
  59. // 修改后,考虑了分享过来的退回按钮
  60. this.$squni.navigateBack(this.$parent)
  61. }
  62. }
  63. }
  64. </script>
  65. <style>
  66. </style>