Files
kangyuan-mobile/sheep/components/s-pages/s-pages.vue
T

139 lines
2.8 KiB
Vue

<template>
<s-layout
:navbar="props.navbar"
color="#333333"
:title="props.title"
:bgStyle="{ color: props.color }"
:showLeftButton="props.showLeftButton"
:goLeft="props.goLeft"
:tabbar="props.tabbar"
@onClickLeft="onClickLeft"
>
<template #navRight>
<slot name="navRight" />
</template>
<!-- <Agreement /> -->
<view class="theme-ai pages">
<view class="card1 w100">
<image v-if="pink_bg" class="w100" :src="$ygUrl + 'transparent_bg.png'" mode="" />
</view>
<view class="scon" :style="{ height: height + 'px' }">
<slot />
</view>
<!-- pages内容 -->
<!-- <view class="s-con" :style="{ top: height + 'px', height: windowHeight - height + 'px',zIndex:1 }">
<slot />
</view> -->
</view>
</s-layout>
</template>
<script setup>
// import Agreement from '@/components/agreement.vue';
import {
ref,
reactive,
onMounted,
onUnmounted,
getCurrentInstance,
watch,
nextTick,
defineProps,
} from 'vue';
let { proxy } = getCurrentInstance();
const props = defineProps({
title: {
type: String,
default: '',
},
showLeftButton: {
type: Boolean,
default: true,
},
goLeft: {
type: Boolean,
default: true,
},
height: {
type: Number,
default: 0,
},
heightShow: {
type: Boolean,
default: false,
},
color: {
type: String,
default: '#F2F4F7',
},
leftUrl: {
//返回上一页地址
type: String,
default: '',
},
navbar: {
type: String,
default: 'inner',
},
tabbar: {
type: [String, Boolean],
default: '',
},
pink_bg: {
type: Boolean,
default: true,
},
});
let height = ref(0);
let sysInfo = uni.getSystemInfoSync();
const windowHeight = sysInfo.windowHeight;
const safeBottom = sysInfo.safeAreaInsets?.bottom || 0;
watch(
() => [props.height, props.heightShow],
(val) => {
if (!props.height) {
if (!props.heightShow) {
const tabbarHeight = props.tabbar ? uni.upx2px(100) + safeBottom : 0;
height.value = windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) - tabbarHeight;
}
} else {
height.value = props.height;
}
},
{
deep: true,
immediate: true,
},
);
const onClickLeft = () => {
if (props.leftUrl) {
proxy.utils.go(props.leftUrl);
} else {
proxy.$emit('onClickLeft');
}
};
</script>
<style lang="scss" scoped>
.pages {
position: relative;
overflow: hidden;
}
.card1 {
position: fixed;
top: 0;
left: 0;
}
.scon {
position: relative;
overflow-y: auto;
}
.s-con {
position: sticky;
overflow: auto;
box-sizing: border-box;
}
</style>