|
@@ -71,6 +71,7 @@
|
|
|
append-to-body
|
|
|
:with-header="false"
|
|
|
size="35%"
|
|
|
+ :destroy-on-close="true"
|
|
|
:title="detail.title" :visible.sync="detail.open">
|
|
|
<userDetail ref="userDetail" />
|
|
|
</el-drawer>
|
|
@@ -89,6 +90,8 @@ import UserDetail from "@/views/qw/qwChat/userDetail/index.vue";
|
|
|
import {ImSocket} from "@/utils/ImSocket";
|
|
|
import {getToken} from '@/utils/auth'
|
|
|
import {uploadOss} from "@/api/common";
|
|
|
+import {mapState} from "vuex";
|
|
|
+import {generateUUID} from "@/components/LemonUI/utils";
|
|
|
|
|
|
let pages = {};
|
|
|
export default {
|
|
@@ -171,6 +174,9 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapState('qwIm', ['shareCourse'])
|
|
|
+ },
|
|
|
watch: {
|
|
|
showQw(nv, ov) {
|
|
|
if (nv) {
|
|
@@ -178,6 +184,50 @@ export default {
|
|
|
this.$refs.IMUI.messageViewToBottom();
|
|
|
});
|
|
|
}
|
|
|
+ },
|
|
|
+ shareCourse(nv) {
|
|
|
+ if (nv) {
|
|
|
+ console.log('shareCourse', nv)
|
|
|
+ // 发送小程序卡片消息
|
|
|
+ const IMUI = this.$refs.IMUI;
|
|
|
+ const contact = IMUI.currentContact;
|
|
|
+ if (!contact) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建消息对象
|
|
|
+ let message = {
|
|
|
+ id: generateUUID(),
|
|
|
+ status: 'going',
|
|
|
+ type: 'miniprogram',
|
|
|
+ sendTime: Date.now(),
|
|
|
+ content: {
|
|
|
+ appid: nv.miniprogramAppid,
|
|
|
+ pagepath: nv.miniprogramPage,
|
|
|
+ title: nv.miniprogramTitle,
|
|
|
+ thumbnail: nv.miniprogramPicUrl
|
|
|
+ },
|
|
|
+ toContactId: contact.conversationId,
|
|
|
+ fromUser: {
|
|
|
+ id: this.qwUser.id,
|
|
|
+ displayName: this.qwUser.qwUserName,
|
|
|
+ avatar: "https://cos.his.cdwjyyh.com/fs/20241231/22a765a96da247d1b83ea94fef438a41.png"
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ this.detail.open = false
|
|
|
+ this.$store.dispatch('qwIm/shareCourse', null)
|
|
|
+
|
|
|
+ this.appendRemoteMessage(message)
|
|
|
+ // 使用handleSend方法发送消息
|
|
|
+ this.handleSend(
|
|
|
+ message,
|
|
|
+ (replaceMessage = { status: "succeed" }) => {
|
|
|
+ IMUI.updateMessage(Object.assign(message, replaceMessage));
|
|
|
+ },
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
@@ -212,10 +262,11 @@ export default {
|
|
|
const { IMUI } = this.$refs;
|
|
|
let message = JSON.parse(data);
|
|
|
this.appendRemoteMessage(message)
|
|
|
+
|
|
|
let conversation = IMUI.findConversation(message.toContactId);
|
|
|
if (conversation.msgId) {
|
|
|
conversation.lastSendTime = message.sendTime;
|
|
|
- conversation.lastContent = message.content;
|
|
|
+ conversation.lastContent = IMUI.lastContentRender(message)//message.content;
|
|
|
IMUI.topPopConversations(conversation);
|
|
|
}
|
|
|
})
|
|
@@ -358,7 +409,6 @@ export default {
|
|
|
}
|
|
|
// image
|
|
|
else if(message.type === "image"){
|
|
|
- console.log("Event:image-click", message, next, file)
|
|
|
const formData = new FormData();
|
|
|
formData.append("file", file);
|
|
|
uploadOss(formData).then(response => {
|
|
@@ -380,6 +430,28 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+ // 小程序
|
|
|
+ else if(message.type === "miniprogram"){
|
|
|
+ // 小程序消息参数
|
|
|
+ params = {
|
|
|
+ "sessionId": message.toContactId,
|
|
|
+ "appKey": this.qwUser.appKey,
|
|
|
+ "content": JSON.stringify(message.content),
|
|
|
+ "msgType": 5 // 小程序消息类型
|
|
|
+ };
|
|
|
+ sendMsg(params).then(response => {
|
|
|
+ const {code} = response
|
|
|
+ if(code === 200){
|
|
|
+ let conversation = IMUI.findConversation(message.toContactId);
|
|
|
+ conversation.lastSendTime = message.sendTime;
|
|
|
+ conversation.lastContent = "小程序";
|
|
|
+ IMUI.topPopConversations(conversation);
|
|
|
+ next && next();
|
|
|
+ } else {
|
|
|
+ next && next({status:'failed'})
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
// file
|
|
|
else if(message.type === "file"){
|
|
|
console.log("Event:file-click", message, next, file)
|