diff --git a/common/env.js b/common/env.js index 76a9eb4..95811de 100644 --- a/common/env.js +++ b/common/env.js @@ -9,6 +9,8 @@ const development = { // baseUrl: 'https://ydsapi.zpc-xy.com', baseUrl: 'http://1.15.21.245:2401', host: ['http://1.15.21.245:2401'], + // baseUrl: 'http://localhost:2015', + // host: ['http://localhost:2015'], imageUrl: 'https://guyu-1308826010.cos.ap-shanghai.myqcloud.com', }; diff --git a/common/server/interface/user.js b/common/server/interface/user.js index 401b023..fd1cde8 100644 --- a/common/server/interface/user.js +++ b/common/server/interface/user.js @@ -51,4 +51,26 @@ export const getUserInfo = async () => { return res.data; } return null; +} + +/** + * 修改用户信息 + * @param {*} nickName + * @param {*} avatar + * @param {*} sex + * @param {*} birthday + * @returns + */ +export const editUserInfo = async (nickName, avatar, sex, birthday) => { + + const res = await request.post("user/EditUserInfo", { + nickName, + avatar, + sex, + birthday + }); + if (res.code == 0) { + return true; + } + return false; } \ No newline at end of file diff --git a/common/server/user.js b/common/server/user.js index cdea6c1..1aeafbb 100644 --- a/common/server/user.js +++ b/common/server/user.js @@ -1,4 +1,4 @@ -import { getUserInfo } from '@/common/server/interface/user' +import { getUserInfo, editUserInfo } from '@/common/server/interface/user' import { ref } from 'vue' export var userInfo = ref(null); @@ -6,7 +6,7 @@ export var userInfo = ref(null); export const loadUserInfo = async () => { const res = await getUserInfo(); if (res == null) { - + userInfo.value = null; uni.removeStorageSync('tokenInfo'); uni.removeStorageSync('userInfo'); @@ -16,3 +16,10 @@ export const loadUserInfo = async () => { uni.setStorageSync('userInfo', res); } +export const updateUserInfo = async (nickName, avatar, sex, birthday) => { + const res = await editUserInfo(nickName, avatar, sex, birthday); + if (!res) { + return; + } + loadUserInfo(); +} \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index 67ea24d..4f24cf2 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -9,9 +9,9 @@ - - + + @@ -174,189 +174,195 @@ \ No newline at end of file diff --git a/pages/me/edit-info.vue b/pages/me/edit-info.vue index 1b98192..c4a7986 100644 --- a/pages/me/edit-info.vue +++ b/pages/me/edit-info.vue @@ -1,182 +1,347 @@ \ No newline at end of file diff --git a/pages/me/me-page.vue b/pages/me/me-page.vue index 35bd4ce..345cb51 100644 --- a/pages/me/me-page.vue +++ b/pages/me/me-page.vue @@ -314,17 +314,9 @@ const clasePop = () => { } const toAppointment = () => { - // 未登录状态,提示登录 - if (!userInfo.uid) { - uni.showModal({ - title: '提示', - content: '请先登录查看预约记录', - showCancel: false, - success: () => { - uni.navigateTo({ - url: '/pages/me/login' - }); - } + if (userInfo.value == null) { + uni.navigateTo({ + url: '/pages/me/login' }); return; } @@ -336,7 +328,7 @@ const toAppointment = () => { const toEditInfo = () => { // 未登录状态,跳转到登录页面 - if (userInfo == null) { + if (userInfo.value == null) { uni.navigateTo({ url: '/pages/me/login' }); @@ -348,21 +340,12 @@ const toEditInfo = () => { } const toBlacklist = () => { - // 未登录状态,提示登录 - if (!userInfo.uid) { - uni.showModal({ - title: '提示', - content: '请先登录查看黑名单', - showCancel: false, - success: () => { - uni.navigateTo({ - url: '/pages/me/login' - }); - } + if (userInfo.value == null) { + uni.navigateTo({ + url: '/pages/me/login' }); return; } - uni.navigateTo({ url: '/pages/me/blacklist-page' }); @@ -379,31 +362,6 @@ const toLogin = () => { }); } -// 加载用户数据 - 未登录状态 -const loadUserData = async () => { - loading.value = true - try { - // 未登录状态,不加载用户数据 - // 保持默认的未登录状态 - userInfo.nickname = '未登录' - userInfo.uid = '' - userInfo.rating = 0 - userInfo.reputation = 0 - userInfo.cardQuality = 0 - userInfo.cardSkill = 0 - userInfo.pigeonCount = 0 - - } catch (error) { - console.error('加载用户数据失败:', error) - uni.showToast({ - title: '加载失败', - icon: 'error' - }) - } finally { - loading.value = false - } -} - // 加载当前预约信息 - 未登录状态 const loadCurrentAppointment = async () => { try { @@ -418,7 +376,6 @@ const loadCurrentAppointment = async () => { // 组件挂载时加载数据 onMounted(() => { - loadUserData() loadCurrentAppointment() }) @@ -428,9 +385,8 @@ onShow(() => { // getUserInfoData(); }) onLoad(async () => { - console.log('kiad'); await loadUserInfo(); -}) +});