From ce16eaf82eaaac0c1b5778e141b93a4e09bec151 Mon Sep 17 00:00:00 2001 From: ctw Date: Fri, 28 Nov 2025 17:41:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:app=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages.json | 7 ++ src/pages/home/detail.vue | 66 ++++++++++++++++- src/pages/profile/profile.vue | 34 ++------- src/pages/profile/setting.vue | 78 ++++++++++++++++++++ src/sheep/api/member/recent.ts | 23 ++++++ src/sheep/components/user-card/user-card.vue | 2 +- 6 files changed, 176 insertions(+), 34 deletions(-) create mode 100644 src/pages/profile/setting.vue diff --git a/src/pages.json b/src/pages.json index c053f989..8ca71979 100644 --- a/src/pages.json +++ b/src/pages.json @@ -240,6 +240,13 @@ "navigationStyle": "custom" } }, + { + "path": "setting", + "style": { + "navigationBarTitleText": "设置", + "navigationStyle": "custom" + } + }, { "path": "about", "style": { diff --git a/src/pages/home/detail.vue b/src/pages/home/detail.vue index 15440503..d4141daf 100644 --- a/src/pages/home/detail.vue +++ b/src/pages/home/detail.vue @@ -32,7 +32,7 @@ - {{ getGender(userDetail.member.memberSex) }}·{{ userDetail.member.memberAge }}岁 + {{ getGender(userDetail.member?.memberSex) }}·{{ userDetail.member?.memberAge }}岁 {{ userDetail.member?.memberHeight || '' }}cm @@ -141,6 +141,14 @@ import { getGender } from '@/sheep/util/index'; // @ts-ignore import sheep from '@/sheep'; + // @ts-ignore + import useConfigStore from '@/chat-store/configStore.js'; + // @ts-ignore + import useChatStore from '@/chat-store/chatStore.js'; + // @ts-ignore + import useFriendStore from '@/chat-store/friendStore.js'; + // @ts-ignore + import request from '@/common/request'; const userCity = computed(() => sheep.$store('user').userCity); const params = reactive({ @@ -208,8 +216,58 @@ }; // 私聊 - const goChat = () => { - uni.showToast({ title: '功能开发中...' }); + const goChat = async () => { + if (!userDetail.value.memberId) return uni.showToast({ title: '用户不存在' }); + const { code } = await RecentApi.chatAddFriend({ + friendUserId: userDetail.value.memberId, + }); + if (code !== 0) return uni.showToast({ title: '好友添加失败', icon: 'error' }); + + const friendStore = useFriendStore(); + const configStore = useConfigStore(); + const chatStore = useChatStore(); + let friendInfo: any = {}; + + request({ + url: '/user/find/' + userDetail.value.memberId, + method: 'GET', + }).then((user: any) => { + console.log(user); + friendInfo = user; + + const friend = { + id: user.id, + nickName: user.nickName, + headImage: user.headImageThumb, + online: user.online, + deleted: false, + }; + friendStore.addFriend(friend); + }); + + let chat: any = { + type: 'PRIVATE', + targetId: friendInfo.id, + showName: friendInfo.nickName, + headImage: friendInfo.headImageThumb, + }; + // if (this.isFriend) { + // chat.isDnd = this.friendInfo.isDnd; + // } + chatStore.openChat(chat); + let chatIdx = chatStore.findChatIdx(chat); + uni.navigateTo({ + url: '/pages/message/chat-box?chatIdx=' + chatIdx, + }); + + // 初始化期间进入会话会导致消息不刷新 + // if (!configStore.appInit || chatStore.loading) { + // uni.showToast({ + // title: '正在初始化页面,请稍后...', + // icon: 'none', + // }); + // return; + // } }; // 喜欢 diff --git a/src/pages/profile/profile.vue b/src/pages/profile/profile.vue index db099444..97374569 100644 --- a/src/pages/profile/profile.vue +++ b/src/pages/profile/profile.vue @@ -91,16 +91,9 @@ /> - - 退 出 登 录 - - { - message - .confirm({ - msg: '', - title: '确定退出登录吗?', - }) - .then(() => { - sheep.$store('user').logout(); - uni.redirectTo({ url: '/pages/login/login' }); - }) - .catch(() => {}); - }; - // cell菜单 const MenuCellList = [ { title: '我的收益', value: '', icon: 'wallet', to: '' }, - { title: '访客记录√', value: '', icon: 'dong', to: '/pages/profile/view-record' }, + { title: '访客记录', value: '', icon: 'dong', to: '/pages/profile/view-record' }, { title: '认证中心', value: '', icon: 'user', to: '' }, - { title: '我的动态√', value: '', icon: 'star', to: '/pages/profile/my-moment' }, - { title: '我的评价√', value: '', icon: 'view-module', to: '', click: lookMyEvaluation }, - { title: '问题反馈√', value: '', icon: 'backtop-rectangle', to: '', click: goFeedback }, + { title: '我的动态', value: '', icon: 'star', to: '/pages/profile/my-moment' }, + { title: '我的评价', value: '', icon: 'view-module', to: '', click: lookMyEvaluation }, + { title: '问题反馈', value: '', icon: 'backtop-rectangle', to: '', click: goFeedback }, { title: '客服助手', value: '', icon: 'service', to: '' }, { title: '关注公众号√', value: '获取最新消息', icon: 'qrcode', to: '', click: subOfficial }, - { title: '设置', value: '', icon: 'setting1', to: '' }, - { title: '关于√', value: '', icon: 'info-circle', to: '/pages/profile/about' }, + { title: '设置√', value: '', icon: 'setting1', to: '/pages/profile/setting' }, ]; diff --git a/src/pages/profile/setting.vue b/src/pages/profile/setting.vue new file mode 100644 index 00000000..8193eee2 --- /dev/null +++ b/src/pages/profile/setting.vue @@ -0,0 +1,78 @@ + + + diff --git a/src/sheep/api/member/recent.ts b/src/sheep/api/member/recent.ts index 56543fd7..83609b29 100644 --- a/src/sheep/api/member/recent.ts +++ b/src/sheep/api/member/recent.ts @@ -267,6 +267,29 @@ const RecentApi = { }, }); }, + // 查询用户设置 + getSetting: () => { + return request({ + url: '/member/recent-cfg/get-or-create', + method: 'GET', + custom: { + showLoading: true, + loadingMsg: '加载中', + }, + }); + }, + // 更新用户设置 + updateSetting: (data: any) => { + return request({ + url: '/member/recent-cfg/create-or-update', + method: 'POST', + data, + custom: { + showLoading: true, + loadingMsg: '加载中', + }, + }); + }, }; export default RecentApi; diff --git a/src/sheep/components/user-card/user-card.vue b/src/sheep/components/user-card/user-card.vue index 01bb5288..8b7dea8f 100644 --- a/src/sheep/components/user-card/user-card.vue +++ b/src/sheep/components/user-card/user-card.vue @@ -34,7 +34,7 @@ {{ member.memberOcc }} - {{ data.location.distance }} + {{ data.location?.distance }} {{ member.memberCity || data.issueCity }}