123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <template>
- <view :class="fixed?'zp-swiper-container zp-swiper-container-fixed':'zp-swiper-container'" :style="[finalSwiperStyle]">
-
- <view v-if="cssSafeAreaInsetBottom===-1" class="zp-safe-area-inset-bottom"></view>
-
- <slot v-if="zSlots.top" name="top" />
- <view class="zp-swiper-super">
- <view v-if="zSlots.left" :class="{'zp-swiper-left':true,'zp-absoulte':isOldWebView}">
- <slot name="left" />
- </view>
- <view :class="{'zp-swiper':true,'zp-absoulte':isOldWebView}" :style="[swiperContentStyle]">
- <slot />
- </view>
- <view v-if="zSlots.right" :class="{'zp-swiper-right':true,'zp-absoulte zp-right':isOldWebView}">
- <slot name="right" />
- </view>
- </view>
- <slot v-if="zSlots.bottom" name="bottom" />
- </view>
- </template>
- <script>
- import commonLayoutModule from '../z-paging/js/modules/common-layout'
-
- export default {
- name: "z-paging-swiper",
- mixins: [commonLayoutModule],
- data() {
- return {
- swiperContentStyle: {}
- };
- },
- props: {
-
- fixed: {
- type: Boolean,
- default: true
- },
-
- safeAreaInsetBottom: {
- type: Boolean,
- default: false
- },
-
- swiperStyle: {
- type: Object,
- default: function() {
- return {};
- },
- }
- },
- mounted() {
- this.$nextTick(() => {
- this.systemInfo = uni.getSystemInfoSync();
- setTimeout(this.updateFixedLayout, 100)
- })
-
- this._getCssSafeAreaInsetBottom();
-
- this.updateLeftAndRightWidth();
- this.swiperContentStyle = { 'flex': '1' };
-
- this.swiperContentStyle = { width: '100%',height: '100%' };
-
- },
- computed: {
- finalSwiperStyle() {
- const swiperStyle = { ...this.swiperStyle };
- if (!this.systemInfo) return swiperStyle;
- const windowTop = this.windowTop;
- const windowBottom = this.systemInfo.windowBottom;
- if (this.fixed) {
- if (windowTop && !swiperStyle.top) {
- swiperStyle.top = windowTop + 'px';
- }
- if (!swiperStyle.bottom) {
- let bottom = windowBottom || 0;
- bottom += this.safeAreaInsetBottom ? this.safeAreaBottom : 0;
- if (bottom > 0) {
- swiperStyle.bottom = bottom + 'px';
- }
- }
- }
- return swiperStyle;
- }
- },
- methods: {
-
- updateLeftAndRightWidth() {
- if (!this.isOldWebView) return;
- this.$nextTick(() => this._updateLeftAndRightWidth(this.swiperContentStyle, 'zp-swiper'));
- }
- }
- }
- </script>
- <style scoped>
- .zp-swiper-container {
-
- display: flex;
-
- flex-direction: column;
- flex: 1;
- }
- .zp-swiper-container-fixed {
- position: fixed;
-
- height: auto;
- width: auto;
-
- top: 0;
- left: 0;
- bottom: 0;
- right: 0;
- }
-
- .zp-safe-area-inset-bottom {
- position: absolute;
-
- height: env(safe-area-inset-bottom);
-
- }
- .zp-swiper-super {
- flex: 1;
- overflow: hidden;
- position: relative;
-
- display: flex;
-
- flex-direction: row;
- }
-
- .zp-swiper-left,.zp-swiper-right{
-
- height: 100%;
-
- }
- .zp-swiper {
- flex: 1;
-
- height: 100%;
- width: 100%;
-
- }
-
- .zp-absoulte {
-
- position: absolute;
- top: 0;
- width: auto;
-
- }
-
- .zp-swiper-item {
- height: 100%;
- }
- </style>
|