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

121 lines
2.4 KiB
Vue
Raw Normal View History

2025-04-10 11:11:46 +08:00
<script setup>
2026-01-12 16:21:32 +08:00
import { ref } from "vue";
2025-05-01 16:17:51 +08:00
2026-01-13 11:35:36 +08:00
import useStore from "@/store";
import { storeToRefs } from "pinia";
const { user } = storeToRefs(useStore());
2026-01-12 16:21:32 +08:00
const props = defineProps({
selected: {
type: Number,
default: 0,
},
2026-01-13 11:35:36 +08:00
onSignin: {
type: Function,
default: () => {},
},
2026-01-12 16:21:32 +08:00
onChange: {
type: Function,
default: () => {},
},
});
const isIOS = uni.getDeviceInfo().osName === "ios";
const tabs = {
首页: "home",
智能弓: "mall",
计分本: "tab-point-book",
勋章: "medal",
个人中心: "user",
};
const onTabChange = (index) => {
if (index === 1) {
return uni.navigateTo({
url: "/pages/device-intro",
2025-06-19 01:55:40 +08:00
});
}
2026-01-12 16:21:32 +08:00
if (index === 2) {
return uni.navigateTo({
2025-09-24 21:05:06 +08:00
url: "/pages/point-book",
2025-05-27 12:38:39 +08:00
});
}
2026-01-12 16:21:32 +08:00
if (index === 4) {
2026-01-13 11:35:36 +08:00
if (!user.value.id) {
props.onSignin();
return;
}
2026-01-12 16:21:32 +08:00
return uni.navigateTo({
url: "/pages/user",
2025-06-19 21:03:33 +08:00
});
}
2026-01-12 16:21:32 +08:00
// props.onChange(index);
};
const getTabSrc = (key, index) => {
2026-01-13 11:35:36 +08:00
return `../static/tab-${tabs[key]}${
props.selected === index ? "" : "-o"
}.png`;
2026-01-12 16:21:32 +08:00
};
2025-04-10 11:11:46 +08:00
</script>
<template>
2026-01-12 16:21:32 +08:00
<view class="footer" :style="{ paddingBottom: isIOS ? '30rpx' : '0' }">
<button
hover-class="none"
v-for="(key, index) in Object.keys(tabs)"
:key="key"
@click="onTabChange(index)"
:class="index === 2 ? 'point-book-tab' : ''"
2025-05-01 16:17:51 +08:00
>
2026-01-12 16:21:32 +08:00
<image v-if="index !== 2" :src="getTabSrc(key, index)" mode="widthFix" />
<image v-else src="../static/tab-point-book.png" mode="widthFix" />
<text
v-if="index !== 2"
:style="{ color: index === selected ? '#f7cb74' : '#8E7D5C' }"
>{{ key }}</text
>
</button>
2025-04-10 11:11:46 +08:00
</view>
</template>
2025-05-01 16:17:51 +08:00
<style scoped>
.footer {
2026-01-12 16:21:32 +08:00
height: 140rpx;
2025-07-02 17:21:44 +08:00
width: 100vw;
2025-05-01 16:17:51 +08:00
position: relative;
display: flex;
justify-content: space-around;
align-items: center;
2026-01-12 16:21:32 +08:00
background: linear-gradient(
180deg,
rgba(70, 55, 34, 0.75) 0%,
rgba(5, 11, 25, 0.58) 100%
),
#000000;
box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.06);
2025-04-10 11:11:46 +08:00
}
2026-01-12 16:21:32 +08:00
.footer > button {
2025-09-04 18:06:28 +08:00
display: flex;
2026-01-12 16:21:32 +08:00
flex-direction: column;
align-items: center;
2025-09-04 18:06:28 +08:00
justify-content: center;
2026-01-12 16:21:32 +08:00
width: 20%;
2025-04-10 11:11:46 +08:00
}
2026-01-12 16:21:32 +08:00
.footer > button > image {
width: 44rpx;
height: 44rpx;
2025-07-30 17:38:48 +08:00
}
2026-01-12 16:21:32 +08:00
.footer > button > text {
font-weight: 500;
font-size: 20rpx;
margin-top: 10rpx;
2025-09-04 18:06:28 +08:00
}
2026-01-12 16:21:32 +08:00
.point-book-tab {
overflow: unset;
2025-07-15 18:36:57 +08:00
}
2026-01-12 16:21:32 +08:00
.point-book-tab > image {
width: 144rpx !important;
height: 144rpx !important;
transform: translateY(-10rpx);
2025-07-15 18:36:57 +08:00
}
2025-04-10 11:11:46 +08:00
</style>