Files
shoot-miniprograms/src/pages/point-book.vue

110 lines
2.5 KiB
Vue
Raw Normal View History

2025-09-24 21:05:06 +08:00
<script setup>
2025-09-25 17:07:37 +08:00
import { ref, computed, onMounted, onBeforeUnmount, watch } from "vue";
2025-09-24 21:05:06 +08:00
import Container from "@/components/Container.vue";
2025-10-24 15:16:44 +08:00
import { getHomeData } from "@/apis";
2025-09-25 11:53:47 +08:00
2025-09-24 21:05:06 +08:00
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { updateUser } = store;
const { user } = storeToRefs(store);
2025-10-24 15:16:44 +08:00
const activeTab = ref(0);
2025-09-24 21:05:06 +08:00
const isIOS = computed(() => {
const systemInfo = uni.getDeviceInfo();
return systemInfo.osName === "ios";
});
2025-10-24 15:16:44 +08:00
const onClickTab = (index) => {
if (index > 0 && !user.value.id) {
return uni.navigateTo({
url: "/pages/sign-in",
2025-09-25 17:07:37 +08:00
});
}
2025-10-24 15:16:44 +08:00
activeTab.value = index;
2025-09-24 21:05:06 +08:00
};
2025-09-25 17:07:37 +08:00
watch(
() => user.value.id,
2025-10-24 15:16:44 +08:00
async (id) => {
if (id) {
const data = await getHomeData();
if (data.user) updateUser(data.user);
}
2025-09-24 21:05:06 +08:00
}
2025-09-25 17:07:37 +08:00
);
2025-09-24 21:05:06 +08:00
onMounted(async () => {
const token = uni.getStorageSync(
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
);
if (!user.value.id && token) {
const data = await getHomeData();
if (data.user) updateUser(data.user);
}
});
</script>
<template>
2025-09-25 10:16:23 +08:00
<Container :bgType="4" bgColor="#F5F5F5" :whiteBackArrow="false" title="">
2025-10-24 15:16:44 +08:00
<view class="container"> </view>
<view class="tabbar">
<button hover-class="none" @click="onClickTab(0)">
2025-09-25 10:59:49 +08:00
<image
2025-10-24 15:16:44 +08:00
:src="`../static/tab1${activeTab === 0 ? '-s' : ''}.png`"
2025-09-25 10:59:49 +08:00
mode="widthFix"
/>
2025-10-24 15:16:44 +08:00
<text :style="{ color: activeTab === 0 ? '#333' : '#999' }">Score</text>
</button>
<button hover-class="none" @click="onClickTab(1)">
2025-10-01 11:58:24 +08:00
<image
2025-10-24 15:16:44 +08:00
:src="`../static/tab2${activeTab === 1 ? '-s' : ''}.png`"
mode="widthFix"
2025-10-01 11:58:24 +08:00
/>
2025-10-24 15:16:44 +08:00
<text :style="{ color: activeTab === 1 ? '#333' : '#999' }"
>History</text
>
</button>
<button hover-class="none" @click="onClickTab(2)">
<image
:src="`../static/tab3${activeTab === 2 ? '-s' : ''}.png`"
mode="widthFix"
2025-09-28 18:28:49 +08:00
/>
2025-10-24 15:16:44 +08:00
<text :style="{ color: activeTab === 2 ? '#333' : '#999' }"
>Profile</text
>
</button>
2025-09-24 21:05:06 +08:00
</view>
</Container>
</template>
<style scoped>
.container {
width: calc(100% - 50rpx);
2025-10-24 15:16:44 +08:00
height: 100%;
2025-09-24 21:05:06 +08:00
padding: 25rpx;
}
2025-10-24 15:16:44 +08:00
.tabbar {
width: 100%;
height: 140rpx;
2025-09-24 21:05:06 +08:00
display: flex;
align-items: center;
2025-10-24 15:16:44 +08:00
justify-content: space-around;
background: #fff;
padding-bottom: 20rpx;
2025-09-24 21:05:06 +08:00
}
2025-10-24 15:16:44 +08:00
.tabbar > button {
2025-09-24 21:05:06 +08:00
display: flex;
flex-direction: column;
align-items: center;
2025-09-30 18:29:08 +08:00
font-size: 20rpx;
2025-09-24 21:05:06 +08:00
}
2025-10-24 15:16:44 +08:00
.tabbar > button > image {
margin-bottom: 10rpx;
width: 60rpx;
height: 60rpx;
2025-09-25 14:22:03 +08:00
}
2025-09-24 21:05:06 +08:00
</style>