diff --git a/pages/mine/index.vue b/pages/mine/index.vue index 676705a..7b3c7c2 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -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 + }