This commit is contained in:
yzy committed 2026-01-20 17:24:14 +08:00
1 parent c431afac2b
commit a5f3947188
1 file changed
+33 -63
+33 -63
View File
@@ -13,17 +13,10 @@
onPullDownRefresh
} from '@dcloudio/uni-app';
import CustomTabBar from '@/components/CustomTabBar.vue'
import {
getSystemSafeArea,
getSystemInfo,
isEmpty,
showToast,
showLoadingToast,
closeToast
} from '@/common/common.js';
import LoginPopup from '@/components/login.vue';
import {
getUserInfo
getUserInfo,updateNickname
} from './api.js';
import {
useUserStore
@@ -32,6 +25,7 @@
import {
useI18n
} from 'vue-i18n';
const {
t,
locale
@@ -44,21 +38,6 @@
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 = () => {
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 getUserInformation = async () => {
@@ -123,23 +86,21 @@
userName.value = userData.value.nickname;
}
onLoad(() => {
getUserInformation();
});
// 模拟数据
/**
* @desc 处理预订事件
*/
const handleBook = (productId) => {
// 这里可以添加预订逻辑,比如跳转到详情页
uni.navigateTo({
url: `/pages/product/detail?id=${productId}`,
});
};
//更改用户名
const changeName = async(userName) =>{
const res = await updateNickname(userName);
if (res.data){
uni.showToast({
title:'success',
duration:2000
})
}else {
uni.showToast({
title:'fail',
duration:2000
})
}
}
/**
* @desc 跳转至登录页面
@@ -153,10 +114,9 @@
onMounted(() => {
getUserInformation();
// 示例:在页面加载完成后自动显示登录弹窗
// setTimeout(() => {
// showLogin.value = true;
// }, 1000);
});
onLoad(() => {
getUserInformation();
});
// 测试缓存中的数据
@@ -164,6 +124,12 @@
const test = () => {
console.log('登录数据', userStore.token);
}
//弹窗控制
const show = ref(false)
const showPopup = () =>{
show.value = true
}
</script>
<template>
@@ -180,7 +146,7 @@
</view>
<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="border-round-theme rounded-lg flex justify-center p-1 items-center">
@@ -352,6 +318,10 @@
</view>
<u-popup v-model="show" mode="center" border-radius="10" closeable>
hello
</u-popup>
<CustomTabBar />
</view>
</template>