用户中心逻辑完善

This commit is contained in:
kron
2025-12-31 11:56:45 +08:00
parent 910530748d
commit 25f51ad53a
2 changed files with 26 additions and 9 deletions

View File

@@ -7,7 +7,7 @@ import Avatar from "@/components/Avatar.vue";
import useStore from "@/store"; import useStore from "@/store";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
const store = useStore(); const store = useStore();
const { user, device } = storeToRefs(store); const { user, device, online } = storeToRefs(store);
const { updateUser } = store; const { updateUser } = store;
const toOrderPage = () => { const toOrderPage = () => {
@@ -16,13 +16,20 @@ const toOrderPage = () => {
}); });
}; };
const toFristTryPage = () => { const toFristTryPage = async () => {
if (!online.value) {
return uni.showToast({
title: "智能弓未连接",
icon: "none",
});
}
if (!device.value.deviceId) { if (!device.value.deviceId) {
return uni.showToast({ return uni.showToast({
title: "请先绑定设备", title: "请先绑定设备",
icon: "none", icon: "none",
}); });
} }
await uni.$checkAudio();
uni.navigateTo({ uni.navigateTo({
url: "/pages/first-try", url: "/pages/first-try",
}); });
@@ -75,9 +82,15 @@ onMounted(() => {
<template> <template>
<Container title="用户信息"> <Container title="用户信息">
<scroll-view :style="{ width: '100%' }"> <view :style="{ width: '100%', height: '100%' }">
<UserHeader /> <UserHeader />
<view class="container"> <scroll-view
scroll-y
:show-scrollbar="false"
:enhanced="true"
class="container"
>
<view :style="{ height: '10px' }"></view>
<UserItem title="用户名">{{ user.nickName }}</UserItem> <UserItem title="用户名">{{ user.nickName }}</UserItem>
<UserItem title="头像"> <UserItem title="头像">
<Avatar :src="user.avatar" :size="35" /> <Avatar :src="user.avatar" :size="35" />
@@ -141,17 +154,17 @@ onMounted(() => {
:onClick="logout" :onClick="logout"
v-if="showLogout" v-if="showLogout"
/> />
</view> <view :style="{ height: '10px' }"></view>
</scroll-view> </scroll-view>
</view>
</Container> </Container>
</template> </template>
<style scoped> <style scoped>
.container { .container {
background-color: #f5f5f5; background-color: #f5f5f5;
height: calc(100vh - 161px); height: calc(100% - 65px);
margin-top: 20px; margin-top: 15px;
padding-top: 10px;
} }
.my-grow { .my-grow {
width: 100%; width: 100%;

View File

@@ -49,6 +49,7 @@ export default defineStore("store", {
rank: [], rank: [],
ringRank: [], ringRank: [],
}, },
online: false,
}), }),
// 计算属性 // 计算属性
@@ -69,6 +70,9 @@ export default defineStore("store", {
updateRank(data = {}) { updateRank(data = {}) {
this.rankData = { ...(data || {}) }; this.rankData = { ...(data || {}) };
}, },
updateOnline(online) {
this.online = online;
},
async updateUser(user = {}) { async updateUser(user = {}) {
this.user = { ...defaultUser, ...user }; this.user = { ...defaultUser, ...user };
if (this.user.rankLvl !== undefined) { if (this.user.rankLvl !== undefined) {