diff --git a/components/chat-message-item/chat-message-item.vue b/components/chat-message-item/chat-message-item.vue index c5cb8b5..4e25c17 100644 --- a/components/chat-message-item/chat-message-item.vue +++ b/components/chat-message-item/chat-message-item.vue @@ -7,8 +7,8 @@ {{ $date.toTimeText(msgInfo.sendTime) }} - + {{ showName }} @@ -119,6 +119,10 @@ export default { type: Object, required: true }, + chatIndex: { + type: Number, + required: true + }, groupMembers: { type: Array } diff --git a/components/head-image/head-image.vue b/components/head-image/head-image.vue index e0ce762..15e57f6 100644 --- a/components/head-image/head-image.vue +++ b/components/head-image/head-image.vue @@ -42,12 +42,16 @@ export default { type: Boolean, default: false }, + chatIndex: { + type: Number, + required: true + }, }, methods: { showUserInfo(e) { if (!this.selfSend && this.id && this.id > 0) { uni.navigateTo({ - url: "/pages/chatbox/im-user-info?id=" + this.id + url: `/pages/chatbox/im-user-info?id=${this.id}&chatIndex=${this.chatIndex}` }) } } diff --git a/pages/book/book.vue b/pages/book/book.vue index 68ce2f0..a9d4771 100644 --- a/pages/book/book.vue +++ b/pages/book/book.vue @@ -1,291 +1,403 @@ diff --git a/pages/chatbox/chat-box.vue b/pages/chatbox/chat-box.vue index 75cac4a..404b91e 100644 --- a/pages/chatbox/chat-box.vue +++ b/pages/chatbox/chat-box.vue @@ -32,7 +32,9 @@ @audioStateChange="onAudioStateChange" :id="'chat-item-' + idx" :msgInfo="msgInfo" - :groupMembers="groupMembers"> + :groupMembers="groupMembers" + :chatIndex="chatIdx" + > @@ -48,7 +50,9 @@ @audioStateChange="onAudioStateChange" :id="'chat-item-' + idx" :msgInfo="msgInfo" - :groupMembers="groupMembers"> + :groupMembers="groupMembers" + :chatIndex="chatIdx" + > @@ -161,6 +165,9 @@ export default { } return title; }, + chatIdx(){ + return this.findChatIdx(this.chat); + }, // 消息发送接口 URL messageAction() { return `/api/message/${this.chat.type.toLowerCase()}/send`; @@ -1077,13 +1084,6 @@ export default { this.isInBottom = true; this.newMessageSize = 0; }, - onShowMore() { - if (this.chat.type === 'GROUP') { - uni.navigateTo({ url: `/pages/group/group-info?id=${this.group.id}` }); - } else { - uni.navigateTo({ url: `/pages/common/user-info?id=${this.userInfo.id}` }); - } - }, onTextInput(e) { this.isEmpty = e.detail.html === '


'; }, diff --git a/pages/chatbox/im-user-info.vue b/pages/chatbox/im-user-info.vue index 9247c88..91f9ebb 100644 --- a/pages/chatbox/im-user-info.vue +++ b/pages/chatbox/im-user-info.vue @@ -41,7 +41,8 @@ export default { userId: '', userInfo: {}, isBlacked: false, - defaultAvatar: '/static/image/kff.png' + defaultAvatar: '/static/image/kff.png', + chatIndex:null } }, computed: { @@ -53,13 +54,15 @@ export default { }, onLoad(options) { this.userId = options.id || '' + this.chatIndex = options.chatIndex || '' + console.log('chatIndex...',this.chatIndex) if (this.userId) { this.loadFriend() this.checkBlack() } }, methods: { - ...mapActions('chatStore', ['openChat']), + ...mapActions('chatStore', ['removeChat','openChat']), async loadFriend() { try { const { data: res } = await uni.$http.get('/api/friend/find/' + this.userId) @@ -130,6 +133,15 @@ export default { let chatIdx = this.findChatIdx(chat) uni.navigateTo({ url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}` }) }, + findChatIdxByUser(){ + let chat = { + type: 'PRIVATE', + targetId: this.userId, + showName: this.displayName, + headImage: this.userInfo.headImage || '' + } + return this.findChatIdx(chat) + }, handleSwitchTap() { // 用户想要切换到的目标状态 const targetStatus = !this.isBlacked @@ -154,12 +166,41 @@ export default { title: this.isBlacked ? '已加入黑名单' : '已取消黑名单', icon: 'none' }) + //聊天框 - 删除 + if (this.isBlacked && this.chatIndex){ + this.removeChat(Number(this.chatIndex)) // 调用 Vuex action + } + const privateChatIdx=this.findChatIdxByUser(); + if (this.isBlacked && privateChatIdx>-1){ + this.removeChat(Number(privateChatIdx)) + } } catch (err) { uni.showToast({ title: '操作失败', icon: 'none' }) } } }) }, + goBackChat() { + uni.reLaunch({ + url: `/pages/chatbox/chat` + }); + } + }, + // 拦截返回 + onBackPress(e) { + // 来源是左上角返回 / 安卓返回键 + if(e.from === 'backbutton'){ + if(this.isBlacked){ + // 拉黑成功,自定义跳转chat + this.goBackChat() + return true // return true 阻止原生默认返回 + }else{ + // 未拉黑,放行,走原来的返回(回到chat-box) + return false + } + } + return false + } } diff --git a/pages/components/member-card-scroll.vue b/pages/components/member-card-scroll.vue new file mode 100644 index 0000000..9a09413 --- /dev/null +++ b/pages/components/member-card-scroll.vue @@ -0,0 +1,302 @@ + + + + + diff --git a/pages/components/member-card.vue b/pages/components/member-card.vue new file mode 100644 index 0000000..027fa19 --- /dev/null +++ b/pages/components/member-card.vue @@ -0,0 +1,280 @@ + + + + + diff --git a/pages/message/contact.vue b/pages/message/contact.vue index 180c94e..331384c 100644 --- a/pages/message/contact.vue +++ b/pages/message/contact.vue @@ -216,10 +216,11 @@ import { mapState, mapActions, mapGetters } from 'vuex' }, // 跳转聊天框 - gotoGroup(item){ - var timestamp = new Date().getTime(); - if(this.tabCurrentIndex==4){ - // 群聊 + // 跳转逻辑修改:私聊跳用户详情页;群聊不变直接进群聊聊天页 + gotoGroup(item){ + var timestamp = new Date().getTime(); + if(this.tabCurrentIndex==4){ + // ========== 群聊:保持原有逻辑不变,直接进入群聊聊天室 ========== let chat = { type: 'GROUP', targetId: item.id, @@ -229,105 +230,16 @@ import { mapState, mapActions, mapGetters } from 'vuex' this.openChat(chat); let chatIdx = this.findChatIdx(chat); uni.navigateTo({ url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}` }); - /** - this.getGroupInfo(item.id); - var chatid="groupchat-" + item.id; - var info={ - chatId: chatid, - groupId: item.id, - chatName: item.name, - chatAvatar: item.headImage?item.headImage:'/static/image/kfr.png', - chatTime: timestamp, - friendId: item.customerService, - teacherId: item.instructor, - minId: "", - sort:"groupchat", // privatechat 私聊 groupchat 群聊 - from:"message", // yh 用户咨询进入聊天框,message 从消息进入聊天框 - notice: item.notice, - remarkNickName: item.remarkNickName, - remarkGroupName: item.remarkGroupName, - showNickName: item.showNickName, - showGroupName: item.showGroupName, - reason: item.reason, - customerService: item.customerService, - instructor: item.instructor, - ownerId: item.ownerId, - productId: item.productId, - productName: item.productName - } - var data=encodeURIComponent(JSON.stringify(info)); - uni.navigateTo({ - url: `/pages/chat/groupchat?data=${data}` - }); - **/ - } - else{ - let chat = { - type: 'PRIVATE', - targetId: item.id, - showName: item.nickName, - headImage: item.headImage, - }; - this.openChat(chat); - let chatIdx = this.findChatIdx(chat); - console.log("chatIdx",chatIdx) - uni.navigateTo({ url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}` }); - // 直接跳转到聊天框 - /** - var info={ - chatId: "privatechat-" + this.userid +"-"+ item.id, - chatType: (this.tabCurrentIndex==0?"coach":(this.tabCurrentIndex==1?"customerService":(this.tabCurrentIndex==2?"adviser": - (this.tabCurrentIndex==3?"storeManager":(this.tabCurrentIndex==4?"groupchat":(this.tabCurrentIndex==5?"consumer":"")))))), - chatName: item.nickName, - chatAvatar: item.headImage, - chatTime: timestamp, - userid: this.userid, - friendId: item.id, // 会话对象 - minId: null, // 已读消息的最大id - sort: this.tabCurrentIndex==4?"groupchat":"privatechat", // privatechat 私聊 groupchat 群聊 - from: "message" // yh 用户咨询进入聊天框,message 从消息进入聊天框 - } - console.log(info); - if(this.tabCurrentIndex==0){ - // 教练 - var data=encodeURIComponent(JSON.stringify(info)); - uni.navigateTo({ - url: `/pages/chat/chat?data=${data}` - }); - } - else if(this.tabCurrentIndex==1){ - // 客服 - var data=encodeURIComponent(JSON.stringify(info)); - uni.navigateTo({ - url: `/pages/chat/chat?data=${data}` - }); - } - else if(this.tabCurrentIndex==2){ - // 顾问 - var data=encodeURIComponent(JSON.stringify(info)); - uni.navigateTo({ - url: `/pages/chat/chat?data=${data}` - }); - } - else if(this.tabCurrentIndex==3){ - // 店长 - var data=encodeURIComponent(JSON.stringify(info)); - uni.navigateTo({ - url: `/pages/chat/chat?data=${data}` - }); - } - else if(this.tabCurrentIndex==5){ - // 学员 - var data=encodeURIComponent(JSON.stringify(info)); - uni.navigateTo({ - url: `/pages/chat/chat?data=${data}` - }); - } - **/ - } + } + else{ + // ========== 私聊联系人:跳转到 用户详情页 user‑info,把用户id传过去 ========== + uni.navigateTo({ + url: `/pages/chatbox/im-user-info?id=${item.id}` + }) + } + }, - }, - loadData(){ + loadData(){ // 底部数据加载 if(this.list[this.tabCurrentIndex].loadStatus=="loadmore") { this.list[this.tabCurrentIndex].loadStatus="loading"; @@ -361,6 +273,7 @@ import { mapState, mapActions, mapGetters } from 'vuex' // 教练列表 if(res.data&&res.data.coach&&res.data.coach.length>0){ this.list[0].grouplist=res.data.coach; + console.log('res.data',res.data) this.$forceUpdate(); } // 客服列表 @@ -525,7 +438,7 @@ import { mapState, mapActions, mapGetters } from 'vuex' } } .wrapcon{ - margin: 420rpx 0 0 0; + margin: 420rpx 0 0 0; padding: 0; width: 100%; position: relative; diff --git a/pages/user/cardDetail.vue b/pages/user/cardDetail.vue new file mode 100644 index 0000000..e9111f4 --- /dev/null +++ b/pages/user/cardDetail.vue @@ -0,0 +1,723 @@ + + + + + diff --git a/pages/user/user.vue b/pages/user/user.vue index 7016634..2716f30 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -13,6 +13,20 @@
+ + + + + + + + + + + + + +