cu-custom.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view class="cu-custom" :style="'height:' + CustomBar + 'px'">
  3. <view :class="'cu-bar fixed ' + (bgImage!=''?'none-bg text-white bg-img':'') + ' ' + bgColor" :style="'height:' + CustomBar + 'px;padding-top:' + StatusBar + 'px;' + (bgImage?'background-image:url(' + bgImage+')':'')">
  4. <view class="action" @tap="BackPage" v-if="isBack">
  5. <text class="cuIcon-back"></text>
  6. <slot name="backText"></slot>
  7. </view>
  8. <view class="action border-custom" v-if="isCustom" :style="'width:' + Custom.width + 'px;height:' + Custom.height + 'px;margin-left:calc(750upx - ' + Custom.right + 'px)'">
  9. <text class="cuIcon-back" @tap="BackPage"></text>
  10. <text class="cuIcon-homefill" @tap="toHome"></text>
  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. </template>
  19. <script>
  20. const app = getApp();
  21. export default {
  22. data() {
  23. return {
  24. StatusBar: app.globalData.StatusBar,
  25. CustomBar: app.globalData.CustomBar,
  26. Custom: app.globalData.Custom
  27. };
  28. },
  29. components: {},
  30. props: {
  31. bgColor: {
  32. type: String,
  33. default: ''
  34. },
  35. isCustom: {
  36. type: [Boolean, String],
  37. default: false
  38. },
  39. isBack: {
  40. type: [Boolean, String],
  41. default: false
  42. },
  43. bgImage: {
  44. type: String,
  45. default: ''
  46. }
  47. },
  48. /**
  49. * 组件的一些选项
  50. */
  51. options: {
  52. addGlobalClass: true,
  53. multipleSlots: true
  54. },
  55. methods: {
  56. BackPage() {
  57. uni.navigateBack({
  58. delta: 1
  59. });
  60. },
  61. toHome() {
  62. uni.reLaunch({
  63. url: '/pages/index/index'
  64. });
  65. }
  66. }
  67. };
  68. </script>
  69. <style>
  70. @import "./cu-custom.css";
  71. </style>