435 lines
11 KiB
Vue
435 lines
11 KiB
Vue
<template>
|
|
<!-- :class="['theme-' + sys?.mode, 'main-' + sys?.theme, 'font-' + sys?.fontSize]" -->
|
|
<view class="page-app theme-ai" :style="[bgMain]">
|
|
<!-- :style="[bgMain]" -->
|
|
<view class="page-main">
|
|
<cardNavbar
|
|
v-if="navbar === 'normal'"
|
|
:title="title"
|
|
:showLeftButton="showLeftButton"
|
|
:bg="navBarColors.bg"
|
|
:color="navBarColors.color"
|
|
@clickLeft="onClickLeft"
|
|
:index="props.index"
|
|
>
|
|
<template #left>
|
|
<slot name="navLeft" />
|
|
</template>
|
|
<template #right>
|
|
<slot name="navRight" />
|
|
</template>
|
|
</cardNavbar>
|
|
<innerNavbar
|
|
v-if="navbar === 'inner'"
|
|
:title="title"
|
|
:showLeftButton="showLeftButton"
|
|
:bg="navBarColors.bg"
|
|
:color="navBarColors.color"
|
|
:scrollbg="navBarColors.scrollbg"
|
|
:scrollColor="navBarColors.scrollColor"
|
|
@clickLeft="onClickLeft"
|
|
:index="props.index"
|
|
>
|
|
<template #left>
|
|
<slot name="navLeft" />
|
|
</template>
|
|
<template #right>
|
|
<slot name="navRight" />
|
|
</template>
|
|
</innerNavbar>
|
|
<transparentNavbar
|
|
v-if="navbar === 'transparent'"
|
|
:title="title"
|
|
:showLeftButton="showLeftButton"
|
|
:bg="navBarColors.bg"
|
|
:color="navBarColors.color"
|
|
:scrollbg="navBarColors.scrollbg"
|
|
:scrollColor="navBarColors.scrollColor"
|
|
@clickLeft="onClickLeft"
|
|
:index="props.index"
|
|
>
|
|
<template #left>
|
|
<slot name="navLeft" />
|
|
</template>
|
|
<template #right>
|
|
<slot name="navRight" />
|
|
</template>
|
|
</transparentNavbar>
|
|
|
|
<!-- 页面内容插槽 -->
|
|
<!-- :style="{ paddingTop: paddingTop + 'px' }" -->
|
|
<view class="pageCon" :style="pageConStyle">
|
|
<!-- <view class="transparent_bg" style="z-index: 100;">
|
|
<image src="/static/transparent_bg.png" />
|
|
</view> -->
|
|
<slot />
|
|
</view>
|
|
</view>
|
|
<view class="">
|
|
<!-- 全局授权弹窗 -->
|
|
<s-auth-modal />
|
|
<!-- 全局快捷入口 -->
|
|
<s-menu-tools />
|
|
</view>
|
|
<merchantTabber v-if="props.tabbar && isMerchantMode" :path="tabbarPath" />
|
|
<cardTabber v-else-if="props.tabbar" :path="tabbarPath" />
|
|
|
|
<view v-if="showUpdateProgress" class="update-progress-mask">
|
|
<view class="update-progress-card">
|
|
<view class="update-progress-title">{{ updateProgressText }}</view>
|
|
<view class="update-progress-bar">
|
|
<view class="update-progress-bar__fill" :style="{ width: updateProgress + '%' }"></view>
|
|
</view>
|
|
<view class="update-progress-percent">{{ updateProgress }}%</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { getCurrentInstance, ref, computed, watch, onMounted, onUnmounted } from 'vue';
|
|
import { onShow } from '@dcloudio/uni-app';
|
|
import innerNavbar from '@/components/card_navbar/inner-navbar';
|
|
import cardNavbar from '@/components/card_navbar/card_navbar';
|
|
import transparentNavbar from '@/components/card_navbar/transparent_navbar';
|
|
import cardTabber from '@/components/card_tabber/card_tabber.vue';
|
|
import merchantTabber from '@/components/merchant_tabber/merchant_tabber.vue';
|
|
import sheep from '@/sheep';
|
|
const emits = defineEmits(['onClickLeft']);
|
|
const instance = getCurrentInstance();
|
|
const proxy = instance?.proxy;
|
|
const props = defineProps({
|
|
title: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
navbar: {
|
|
type: String,
|
|
default: 'normal',
|
|
},
|
|
opacityBgUi: {
|
|
type: String,
|
|
default: 'bg-white',
|
|
},
|
|
color: {
|
|
type: String,
|
|
default: '#ffffff',
|
|
},
|
|
tools: {
|
|
type: String,
|
|
default: 'title',
|
|
},
|
|
keyword: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
navbarStyle: {
|
|
type: Object,
|
|
default: () => ({
|
|
styleType: '',
|
|
type: '',
|
|
color: '',
|
|
src: '',
|
|
list: [],
|
|
alwaysShow: 0,
|
|
}),
|
|
},
|
|
bgStyle: {
|
|
type: Object,
|
|
default: () => ({
|
|
src: '',
|
|
color: '#F2F4F7',
|
|
}),
|
|
},
|
|
tabbar: {
|
|
type: [String, Boolean],
|
|
default: '',
|
|
},
|
|
onShareAppMessage: {
|
|
type: [Boolean, Object],
|
|
default: true,
|
|
},
|
|
leftWidth: {
|
|
type: [Number, String],
|
|
default: 100,
|
|
},
|
|
rightWidth: {
|
|
type: [Number, String],
|
|
default: 100,
|
|
},
|
|
defaultSearch: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
//展示返回按钮
|
|
showLeftButton: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
goLeft: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
theme: {
|
|
type: String,
|
|
default: '2',
|
|
},
|
|
navPreset: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
index: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
});
|
|
const sys = computed(() => sysStore);
|
|
const sysStore = sheep.$store('sys');
|
|
const userStore = sheep.$store('user');
|
|
const appStore = sheep.$store('app');
|
|
const modalStore = sheep.$store('modal');
|
|
const isMerchantMode = computed(() => appStore.bizMode === 'merchant');
|
|
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
|
|
let paddingTop = ref();
|
|
paddingTop.value = statusBarHeight + uni.upx2px(88);
|
|
|
|
const tabbarPath = ref('');
|
|
const showUpdateProgress = ref(false);
|
|
const updateProgress = ref(0);
|
|
const updateProgressText = ref('下载中...');
|
|
|
|
const HOT_UPDATE_PROGRESS_EVENT = '__hot_update_progress__';
|
|
|
|
const handleUpdateProgress = (payload) => {
|
|
if (!payload) return;
|
|
const type = String(payload.type || '');
|
|
if (type === 'show') {
|
|
showUpdateProgress.value = true;
|
|
updateProgress.value = 0;
|
|
updateProgressText.value = String(payload.text || '下载中...');
|
|
return;
|
|
}
|
|
if (type === 'set') {
|
|
showUpdateProgress.value = true;
|
|
updateProgress.value = Math.max(0, Math.min(100, Number(payload.percent) || 0));
|
|
if (payload.text) updateProgressText.value = String(payload.text);
|
|
return;
|
|
}
|
|
if (type === 'hide') {
|
|
showUpdateProgress.value = false;
|
|
updateProgress.value = 0;
|
|
updateProgressText.value = '下载中...';
|
|
}
|
|
};
|
|
|
|
const normalizePath = (p) => {
|
|
if (!p) return '';
|
|
return p.startsWith('/') ? p : `/${p}`;
|
|
};
|
|
|
|
const updateTabbarPath = () => {
|
|
if (typeof props.tabbar === 'string' && props.tabbar) {
|
|
tabbarPath.value = normalizePath(props.tabbar);
|
|
return;
|
|
}
|
|
const pages = getCurrentPages?.() || [];
|
|
const current = pages[pages.length - 1];
|
|
tabbarPath.value = normalizePath(current?.route || '');
|
|
};
|
|
|
|
onShow(() => updateTabbarPath());
|
|
watch(() => props.tabbar, () => updateTabbarPath(), { immediate: true });
|
|
|
|
onMounted(() => {
|
|
if (typeof uni !== 'undefined' && typeof uni.$on === 'function') {
|
|
uni.$on(HOT_UPDATE_PROGRESS_EVENT, handleUpdateProgress);
|
|
}
|
|
if (typeof uni !== 'undefined' && uni.__hotUpdatePendingProgress) {
|
|
handleUpdateProgress(uni.__hotUpdatePendingProgress);
|
|
}
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
if (typeof uni !== 'undefined' && typeof uni.$off === 'function') {
|
|
uni.$off(HOT_UPDATE_PROGRESS_EVENT, handleUpdateProgress);
|
|
}
|
|
});
|
|
|
|
const pageConStyle = computed(() => {
|
|
const style = {
|
|
paddingTop: paddingTop.value + 'px',
|
|
};
|
|
if (props.tabbar) {
|
|
style.paddingBottom = `calc(${uni.upx2px(100)}px + env(safe-area-inset-bottom))`;
|
|
}
|
|
return style;
|
|
});
|
|
|
|
const bgMain = computed(() => {
|
|
const bgColor = props.bgStyle.backgroundColor || props.bgStyle.color;
|
|
const bgImg = props.bgStyle.backgroundImage
|
|
? `url(${sheep.$url.cdn(props.bgStyle.backgroundImage)})`
|
|
: 'none';
|
|
return {
|
|
backgroundColor: bgColor,
|
|
backgroundImage: bgImg,
|
|
backgroundRepeat: 'no-repeat',
|
|
backgroundPosition: 'top center',
|
|
backgroundSize: '100% auto',
|
|
};
|
|
});
|
|
|
|
const navBarColors = computed(() => {
|
|
if (props.navPreset === 'float') {
|
|
if (props.navbar === 'normal') {
|
|
return {
|
|
bg: '#ffffff',
|
|
color: '#333333',
|
|
scrollbg: '#ffffff',
|
|
scrollColor: '#333333',
|
|
};
|
|
}
|
|
return {
|
|
bg: 'transparent',
|
|
color: '#ffffff',
|
|
scrollbg: '#ffffff',
|
|
scrollColor: '#333333',
|
|
};
|
|
}
|
|
if (props.navPreset === 'light') {
|
|
return {
|
|
bg: '#ffffff',
|
|
color: '#333333',
|
|
scrollbg: '#ffffff',
|
|
scrollColor: '#333333',
|
|
};
|
|
}
|
|
if (props.navPreset === 'transparent') {
|
|
return {
|
|
bg: 'transparent',
|
|
color: '#333333',
|
|
scrollbg: '#ffffff',
|
|
scrollColor: '#333333',
|
|
};
|
|
}
|
|
if (props.navPreset === 'dark') {
|
|
return {
|
|
bg: '#000000',
|
|
color: '#ffffff',
|
|
scrollbg: '#000000',
|
|
scrollColor: '#ffffff',
|
|
};
|
|
}
|
|
if (props.navPreset === 'blue') {
|
|
return {
|
|
bg: '#2556EC',
|
|
color: '#ffffff',
|
|
scrollbg: '#000000',
|
|
scrollColor: '#ffffff',
|
|
};
|
|
}
|
|
return {
|
|
bg: undefined,
|
|
color: undefined,
|
|
scrollbg: undefined,
|
|
scrollColor: undefined,
|
|
};
|
|
});
|
|
const onClickLeft = () => {
|
|
console.log('返回2');
|
|
emits('onClickLeft');
|
|
};
|
|
</script>
|
|
<style scoped lang="scss">
|
|
.one {
|
|
width: 100%;
|
|
height: 708rpx;
|
|
background-image: linear-gradient(to top, #f2f4f7 0%, rgba(251, 129, 55, 0.459) 36%);
|
|
}
|
|
|
|
.transparent_bg {
|
|
width: 100%;
|
|
height: 708rpx;
|
|
|
|
// position: fixed;
|
|
// top: 0;
|
|
// left: 0;
|
|
image {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
|
|
.page-app {
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
.page-main {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
.pageCon {
|
|
flex: 1;
|
|
box-sizing: border-box;
|
|
}
|
|
}
|
|
}
|
|
|
|
.pageCon {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.update-progress-mask {
|
|
position: fixed;
|
|
left: 0;
|
|
top: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: rgba(0, 0, 0, 0.45);
|
|
z-index: 9999;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 40rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.update-progress-card {
|
|
width: 100%;
|
|
max-width: 560rpx;
|
|
background: #fff;
|
|
border-radius: 16rpx;
|
|
padding: 32rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.update-progress-title {
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
text-align: center;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
|
|
.update-progress-bar {
|
|
height: 18rpx;
|
|
background: rgba(0, 0, 0, 0.08);
|
|
border-radius: 999rpx;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.update-progress-bar__fill {
|
|
height: 100%;
|
|
background: var(--color2);
|
|
border-radius: 999rpx;
|
|
width: 0%;
|
|
transition: width 0.2s linear;
|
|
}
|
|
|
|
.update-progress-percent {
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
text-align: center;
|
|
margin-top: 16rpx;
|
|
}
|
|
</style>
|