Files
shoot-miniprograms/src/components/AppBackground.vue

72 lines
1.2 KiB
Vue
Raw Normal View History

2025-05-10 16:57:36 +08:00
<script setup>
2025-08-07 11:04:12 +08:00
import { ref, onMounted } from "vue";
2025-05-10 16:57:36 +08:00
const props = defineProps({
type: {
type: Number,
default: 0,
},
2025-07-29 10:46:37 +08:00
bgColor: {
type: String,
default: "#050b19",
},
2025-05-10 16:57:36 +08:00
});
2025-08-07 11:04:12 +08:00
const capsuleHeight = ref(0);
onMounted(() => {
const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
capsuleHeight.value = menuBtnInfo.top + 50 - 9;
});
2025-05-10 16:57:36 +08:00
</script>
2025-05-01 16:17:51 +08:00
<template>
2025-07-29 10:46:37 +08:00
<view class="background" :style="{ backgroundColor: bgColor }">
2025-07-14 13:39:10 +08:00
<image
class="bg-image"
v-if="type === 0"
src="../static/app-bg.png"
mode="widthFix"
/>
<image
class="bg-image"
v-if="type === 1"
src="../static/app-bg2.png"
mode="widthFix"
/>
2025-07-29 10:46:37 +08:00
<image
class="bg-image"
v-if="type === 2"
src="../static/app-bg3.png"
2025-08-07 11:04:12 +08:00
:style="{ height: capsuleHeight + 'px' }"
2025-07-29 10:46:37 +08:00
/>
2025-05-10 16:57:36 +08:00
<view class="bg-overlay" v-if="type === 0"></view>
2025-05-01 16:17:51 +08:00
</view>
</template>
<style scoped>
.background {
position: fixed;
width: 100%;
height: 100%;
left: 0;
top: 0;
2025-05-01 16:36:24 +08:00
z-index: -1;
2025-05-01 16:17:51 +08:00
}
.bg-image {
width: 100%;
height: 100%;
}
.bg-overlay {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
2025-05-10 16:57:36 +08:00
background: linear-gradient(
to bottom,
2025-05-27 12:38:39 +08:00
rgba(26, 26, 26, 0.2),
rgba(0, 0, 0, 0.2)
2025-05-10 16:57:36 +08:00
);
2025-05-01 16:17:51 +08:00
}
2025-05-10 16:57:36 +08:00
</style>