This commit is contained in:
yzy committed 2026-01-20 17:24:14 +08:00
1 parent c431afac2b
commit a5f3947188
1 file changed
+34 -64
+34 -64
View File
@@ -13,17 +13,10 @@
onPullDownRefresh onPullDownRefresh
} from '@dcloudio/uni-app'; } from '@dcloudio/uni-app';
import CustomTabBar from '@/components/CustomTabBar.vue' import CustomTabBar from '@/components/CustomTabBar.vue'
import { import {
getSystemSafeArea, getUserInfo,updateNickname
getSystemInfo,
isEmpty,
showToast,
showLoadingToast,
closeToast
} from '@/common/common.js';
import LoginPopup from '@/components/login.vue';
import {
getUserInfo
} from './api.js'; } from './api.js';
import { import {
useUserStore useUserStore
@@ -32,6 +25,7 @@
import { import {
useI18n useI18n
} from 'vue-i18n'; } from 'vue-i18n';
const { const {
t, t,
locale locale
@@ -44,21 +38,6 @@
const userStore = useUserStore(); const userStore = useUserStore();
const tabList = ref([]); //tab列表
const tabsIndex = ref(0); //当前选中的tab索引
// const modelTypeList = ref([]);
const tabsLeft = ref(0); //下划线移动的距离
const finished = ref(false); //数据是否全部加载完成
const windowWidth = ref(0); //tab元素的宽度
const orderRows = ref([]); //订单列表
const showLogin = ref(false); //显示登录
const triggered = ref(false); //是否下拉刷新状态,true为是
const loading = ref(false); // 添加loading状态
const productData = ref();
const scrollHeight = ref(0); //scroll-view滚动高度
const pageView = ref({});
// 控制登录弹窗显示 // 控制登录弹窗显示
const toggleLoginPopup = () => { const toggleLoginPopup = () => {
showLogin.value = !showLogin.value; showLogin.value = !showLogin.value;
@@ -96,22 +75,6 @@
}); });
}; };
/**
* @desc 获取可视内容高度
*/
const getContentHeight = (e) => {
pageView.value = e;
};
/**
* @desc 跳转至详情页面
*/
const toDetailPage = (productId) => {
uni.navigateTo({
url: '/pages/product/detail',
});
};
const userData = ref(); const userData = ref();
//获取首页数据 //获取首页数据
const getUserInformation = async () => { const getUserInformation = async () => {
@@ -123,23 +86,21 @@
userName.value = userData.value.nickname; userName.value = userData.value.nickname;
} }
//更改用户名
onLoad(() => { const changeName = async(userName) =>{
getUserInformation(); const res = await updateNickname(userName);
if (res.data){
}); uni.showToast({
title:'success',
// 模拟数据 duration:2000
})
/** }else {
* @desc 处理预订事件 uni.showToast({
*/ title:'fail',
const handleBook = (productId) => { duration:2000
// 这里可以添加预订逻辑,比如跳转到详情页 })
uni.navigateTo({ }
url: `/pages/product/detail?id=${productId}`, }
});
};
/** /**
* @desc 跳转至登录页面 * @desc 跳转至登录页面
@@ -153,10 +114,9 @@
onMounted(() => { onMounted(() => {
getUserInformation(); getUserInformation();
// 示例:在页面加载完成后自动显示登录弹窗 });
// setTimeout(() => { onLoad(() => {
// showLogin.value = true; getUserInformation();
// }, 1000);
}); });
// 测试缓存中的数据 // 测试缓存中的数据
@@ -164,6 +124,12 @@
const test = () => { const test = () => {
console.log('登录数据', userStore.token); console.log('登录数据', userStore.token);
} }
//弹窗控制
const show = ref(false)
const showPopup = () =>{
show.value = true
}
</script> </script>
<template> <template>
@@ -180,7 +146,7 @@
</view> </view>
<view class="flex flex-col justify-center items-start gap-1"> <view class="flex flex-col justify-center items-start gap-1">
<view class="font-bold text-lg text-black">{{userName}}</view> <view class="font-bold text-lg text-black" @click="showPopup">{{userName}}</view>
<view class="text-sm opacity-80 text-black">Sweekar Guardian since 2023</view> <view class="text-sm opacity-80 text-black">Sweekar Guardian since 2023</view>
<!-- 在线状态 --> <!-- 在线状态 -->
<view class="border-round-theme rounded-lg flex justify-center p-1 items-center"> <view class="border-round-theme rounded-lg flex justify-center p-1 items-center">
@@ -351,7 +317,11 @@
</view> </view>
<u-popup v-model="show" mode="center" border-radius="10" closeable>
hello
</u-popup>
<CustomTabBar /> <CustomTabBar />
</view> </view>
</template> </template>