优化
This commit is contained in:
1 parent
76ba02d29b
commit
2c6d011736
4 files changed
+113
-334
No files matched your search
+23
-4
@@ -1,7 +1,26 @@
|
||||
import { get, post, put, dele } from '@/utils/request';
|
||||
/**
|
||||
* @desc 获取产品列表
|
||||
* @desc 上传头像
|
||||
*/
|
||||
export const getProducts = (params) => {
|
||||
return get('/api/products/', params)
|
||||
}
|
||||
export const uploadAvatar = (params) => {
|
||||
return post('/app-api/member/user/upload-avatar', params)
|
||||
}
|
||||
/**
|
||||
* @desc 昵称修改
|
||||
*/
|
||||
export const updateNickname = (params) => {
|
||||
return put('/app-api/member/user/update-nickname', params)
|
||||
}
|
||||
/**
|
||||
* @desc 用户登出
|
||||
*/
|
||||
export const userLogout = (params) => {
|
||||
return post('/app-api/member/auth/logout', params)
|
||||
}
|
||||
/**
|
||||
* @desc 用户个人信息
|
||||
*/
|
||||
export const getUserInfo = (params) => {
|
||||
return get('/app-api/member/user/get', params)
|
||||
}
|
||||
|
||||
+22
-42
@@ -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>
|
||||
Reference in new issue
Block a user