This commit is contained in:
yzy committed 2026-01-16 19:14:26 +08:00
1 parent 76ba02d29b
commit 2c6d011736
4 files changed
+113 -334

No files matched your search

+22 -42
View File
@@ -4,7 +4,7 @@ import { onLoad, onShow, onReady, onHide, onPullDownRefresh } from '@dcloudio/un
import CustomTabBar from '@/components/CustomTabBar.vue'
import { getSystemSafeArea, getSystemInfo, isEmpty, showToast, showLoadingToast, closeToast } from '@/common/common.js';
import LoginPopup from '@/components/login.vue';
import { getProducts } from './api.js';
import { getUserInfo } from './api.js';
import { useUserStore } from '@/store/user.js';
import { useI18n } from 'vue-i18n';
@@ -35,20 +35,7 @@ const toggleLoginPopup = () => {
showLogin.value = !showLogin.value;
};
// 关闭登录弹窗
const closeLoginPopup = () => {
showLogin.value = false;
};
// 登录成功回调
const onLoginSuccess = () => {
closeLoginPopup();
// 可以在这里执行登录成功后的操作
uni.showToast({
title: '登录成功',
icon: 'success'
});
};
/**
* @desc 获取可视内容高度
@@ -66,16 +53,20 @@ const toDetailPage = (productId) => {
});
};
const userData = ref();
//获取首页数据
const getProductList = async()=>{
const res = await getProducts();
const getUserInformation = async()=>{
const res = await getUserInfo();
userData.value = res.data;
console.log('data',userData.value);
productData.value=res.data;
console.log("商品数据",productData.value);
}
onLoad(()=>{
// getProductList();
getUserInformation();
});
@@ -95,6 +86,7 @@ const handleBook = (productId) => {
* @desc 跳转至登录页面
*/
const toLoginPage = (productId) => {
userStore.logout()
uni.navigateTo({
url: '/pages/login/index',
});
@@ -106,10 +98,17 @@ onMounted(() => {
// showLogin.value = true;
// }, 1000);
});
// 测试缓存中的数据
const test = () =>{
console.log('登录数据',userStore.token);
}
</script>
<template>
<view class="h-[100vh] bg-[#fff]">
<view class="bg-[#fff]">
<!-- 页面内容区域 -->
<view class="flex flex-col">
<!-- 个人页头部区域 -->
@@ -119,6 +118,7 @@ onMounted(() => {
src="/static/images/avatar.png"
class="w-16 h-16 rounded-full border-2 border-white mr-4"
style="background-color: #ddd;"
@click="test()"
/>
<view class="flex-1">
<view class="font-bold text-lg">用户昵称</view>
@@ -194,23 +194,7 @@ onMounted(() => {
</view>
</view>
<!-- 登录弹窗 - 优化版 -->
<u-popup
v-model:show="showLogin"
mode="center"
:border-radius="20"
:safe-area-inset-bottom="false"
width="80%"
:closeable="true"
@close="closeLoginPopup"
>
<view class="popup-content">
<LoginPopup
@close="closeLoginPopup"
@success="onLoginSuccess"
/>
</view>
</u-popup>
<CustomTabBar />
</view>
@@ -247,9 +231,5 @@ onMounted(() => {
align-items: center;
}
.popup-content {
padding: 20rpx;
max-height: 80vh;
overflow-y: auto;
}
</style>