Files
shoot-miniprograms/src/pages/user.vue

163 lines
4.0 KiB
Vue
Raw Normal View History

2025-05-01 16:17:51 +08:00
<script setup>
2025-09-03 16:37:49 +08:00
import { ref, onMounted } from "vue";
2025-07-02 17:21:44 +08:00
import Container from "@/components/Container.vue";
2025-05-01 21:38:35 +08:00
import UserHeader from "@/components/UserHeader.vue";
import UserItem from "@/components/UserItem.vue";
2025-05-28 15:00:31 +08:00
import Avatar from "@/components/Avatar.vue";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
2025-06-16 11:26:57 +08:00
const { user, device } = storeToRefs(store);
2025-06-13 16:36:18 +08:00
const { updateUser } = store;
2025-05-28 15:00:31 +08:00
const toOrderPage = () => {
uni.navigateTo({
url: "/pages/orders",
});
};
2025-05-28 16:03:08 +08:00
const toFristTryPage = () => {
2025-06-16 11:26:57 +08:00
if (!device.value.deviceId) {
return uni.showToast({
title: "请先绑定设备",
icon: "none",
});
}
2025-05-28 16:03:08 +08:00
uni.navigateTo({
url: "/pages/first-try",
});
};
const toBeVipPage = () => {
uni.navigateTo({
url: "/pages/be-vip",
});
};
const toMyGrowthPage = () => {
uni.navigateTo({
url: "/pages/my-growth",
});
};
const toGradeIntroPage = () => {
uni.navigateTo({
url: "/pages/grade-intro",
});
};
const toRankIntroPage = () => {
uni.navigateTo({
url: "/pages/rank-intro",
});
};
2025-09-03 16:37:49 +08:00
const toAboutUsPage = () => {
uni.navigateTo({
url: "/pages/about-us",
});
};
2025-11-06 10:52:08 +08:00
const toAudioTestPage = () => {
uni.navigateTo({
url: "/pages/audio-test",
});
};
2025-09-03 16:37:49 +08:00
const showLogout = ref(false);
2025-06-13 16:36:18 +08:00
const logout = () => {
2025-09-12 17:49:26 +08:00
uni.removeStorageSync(
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
);
2025-06-13 16:36:18 +08:00
uni.navigateBack();
updateUser();
};
2025-09-03 16:37:49 +08:00
onMounted(() => {
const accountInfo = uni.getAccountInfoSync();
const envVersion = accountInfo.miniProgram.envVersion;
if (envVersion !== "release") showLogout.value = true;
});
2025-05-01 16:17:51 +08:00
</script>
<template>
2025-07-02 17:21:44 +08:00
<Container title="用户信息">
2025-12-26 16:16:05 +08:00
<scroll-view :style="{ width: '100%' }">
2025-07-15 14:02:09 +08:00
<UserHeader />
2025-07-02 17:21:44 +08:00
<view class="container">
<UserItem title="用户名">{{ user.nickName }}</UserItem>
<UserItem title="头像">
<Avatar :src="user.avatar" :size="35" />
</UserItem>
<UserItem
title="订单"
:customStyle="{
marginTop: '10px',
}"
:onClick="toOrderPage"
/>
<UserItem
title="新手试炼场"
:onClick="user.trio > 0 ? null : toFristTryPage"
>
<text v-if="user.trio > 0" :style="{ color: '#259249' }">已完成</text>
<text v-else :style="{ color: '#CC311F' }">未完成</text>
</UserItem>
<UserItem title="会员" :onClick="toBeVipPage">
已赠送6个月会员
</UserItem>
2025-07-18 15:15:32 +08:00
<UserItem title="等级介绍" :onClick="toGradeIntroPage">
<text :style="{ color: '#4C76FF' }">Lv{{ user.lvl }}</text>
<text
:style="{
color: '#FF7900',
marginLeft: '5px',
}"
>{{ user.lvlPoints }}</text
>
<text></text>
</UserItem>
2025-07-02 17:21:44 +08:00
<UserItem
title="段位介绍"
:customStyle="{
marginBottom: '10px',
}"
:onClick="toRankIntroPage"
2025-07-18 15:15:32 +08:00
>
<text :style="{ color: '#8E53EA' }">{{ user.lvlName }}</text>
<text
:style="{
color: '#FF7900',
marginLeft: '5px',
}"
>{{ user.scores }}</text
>
<text></text>
</UserItem>
2025-07-02 17:21:44 +08:00
<view class="my-grow" @click="toMyGrowthPage">
<image src="../static/my-grow.png" mode="widthFix" />
</view>
2025-09-03 16:37:49 +08:00
<UserItem title="关于我们" :onClick="toAboutUsPage" />
2025-11-06 10:52:08 +08:00
<UserItem
title="音频测试"
:onClick="toAudioTestPage"
v-if="showLogout"
/>
2025-09-03 16:37:49 +08:00
<UserItem
title="退出登录(仅用于测试)"
:onClick="logout"
v-if="showLogout"
/>
2025-05-28 16:03:08 +08:00
</view>
2025-12-26 16:16:05 +08:00
</scroll-view>
2025-07-02 17:21:44 +08:00
</Container>
2025-05-01 16:17:51 +08:00
</template>
<style scoped>
2025-05-01 21:38:35 +08:00
.container {
2025-07-14 16:40:20 +08:00
background-color: #f5f5f5;
2025-05-01 21:38:35 +08:00
height: calc(100vh - 161px);
margin-top: 20px;
padding-top: 10px;
2025-05-01 16:17:51 +08:00
}
2025-05-01 21:38:35 +08:00
.my-grow {
width: 100%;
}
.my-grow > image {
2025-05-01 16:17:51 +08:00
width: 100%;
}
2025-05-01 16:36:24 +08:00
</style>