| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <template>
- <view>
- <view class="cu-custom" :style="[{ height: CustomBar + 'px' }]">
- <view
- class="cu-bar fixed"
- :style="style"
- :class="[bgImage != '' ? 'none-bg text-white bg-img' : '', bgColor]"
- >
- <view class="action" @tap="BackPage" v-if="isBack">
- <u-icon name="arrow-left" color="#020305" size="32rpx" />
- <slot name="backText"></slot>
- </view>
- <view class="content" :style="[{ top: StatusBar + 'px' }]">
- <slot name="content"></slot>
- </view>
- <view class="cu-bar-right">
- <slot name="right"></slot>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- StatusBar: this.StatusBar,
- CustomBar: this.CustomBar,
- };
- },
- name: "cu-custom",
- computed: {
- style() {
- var StatusBar = this.StatusBar;
- var CustomBar = this.CustomBar;
- var bgImage = this.bgImage;
- var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
- if (this.bgImage) {
- style = `${style}background-image:url(${bgImage});`;
- }
- if (this.textColor) {
- style = `${style}color: ${this.textColor}`;
- }
- return style;
- },
- },
- props: {
- bgColor: {
- type: String,
- default: "",
- },
- isBack: {
- type: [Boolean, String],
- default: false,
- },
- bgImage: {
- type: String,
- default: "",
- },
- textColor: {
- type: String,
- default: "",
- },
- isGoWater: {
- type: Boolean,
- default: false,
- },
- },
- methods: {
- BackPage() {
- if (this.isGoWater) {
- uni.switchTab({
- url: "/waterPages/index",
- });
- } else {
- if (getCurrentPages().length < 2 && "undefined" !== typeof __wxConfig) {
- let url = "/" + __wxConfig.pages[0];
- return uni.redirectTo({ url });
- }
- // uni.navigateBack({
- // delta: 1
- // })
- if (getCurrentPages().length === 1) {
- uni.switchTab({
- url: "/pages/index",
- });
- } else {
- uni.navigateBack({
- delta: 1,
- });
- }
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .cu-bar {
- display: flex;
- align-items: center;
- position: relative;
- &.bg-transparent {
- background-color: transparent;
- }
- &.bg-gray {
- background-color: #f7f7f7;
- }
- .cu-bar-right {
- position: relative;
- z-index: 10;
- right: 32rpx;
- }
- .content {
- position: absolute;
- left: 50%;
- transform: translateX(-50%);
- color: #020305;
- font-family: "Source Han Sans CN VF";
- font-weight: 700;
- font-size: 32rpx;
- }
- }
- </style>
|