diff --git a/App.vue b/App.vue index 0ec01bd..11ff243 100644 --- a/App.vue +++ b/App.vue @@ -2,7 +2,8 @@ // #ifdef APP-PLUS || H5 import { TUIChatKit } from './TUIKit'; - +import { useCounterStore } from '@/stores/counter' +const counter = useCounterStore() TUIChatKit.init(); // #endif // Required information @@ -19,6 +20,15 @@ export default { }; }, onLoad(option) { + uni.getStorage({ + key: "userinfo", + success: (res) => { + this.info = res.data; + counter.$patch({ myitem:this.info}) + }, + fail: () => { + }, + }) }, provide() { return { diff --git a/TUIKit/components/TUIChat/index.vue b/TUIKit/components/TUIChat/index.vue index 52df043..29e74c6 100644 --- a/TUIKit/components/TUIChat/index.vue +++ b/TUIKit/components/TUIChat/index.vue @@ -133,22 +133,22 @@ import { initChat, logout } from "./entry-chat-only.ts"; import { isEnabledMessageReadReceiptGlobal } from "./utils/utils"; import OfflinePushInfoManager from "./offlinePushInfoManager/index"; import { TUIChatService } from "@tencentcloud/chat-uikit-engine"; -import { useCounterStore } from '@/stores/counter' -const counter = useCounterStore() +import { useCounterStore } from "@/stores/counter"; +import request from "@/components/request"; +import generateMsgId from "../../../components/generateMsgId.js"; +const counter = useCounterStore(); let myitem = ref(); let youritem = ref(); +let MessageListinfo = ref(); onLoad((options) => { initChat(options); - if (options.myitem) { - myitem.value = JSON.parse(options.myitem); - counter.$patch({ myitem:myitem.value }) - youritem.value = JSON.parse(options.youritem); - counter.$patch({ youritem:youritem.value }) - setTimeout(() => { - sendCustomMessage(myitem, youritem); - }, 1000); - } + myitem.value = JSON.parse(options.myitem); + youritem.value = JSON.parse(options.youritem); + counter.$patch({ youritem: youritem.value }); + setTimeout(() => { + sendCustomMessage(myitem.value, youritem.value); + }, 1000); }); onUnload(() => { @@ -200,12 +200,17 @@ TUIStore.watch(StoreName.CONV, { }); function sendCustomMessage(myitem, youritem) { + const keyid = generateMsgId(); const payload = { data: JSON.stringify({ businessID: "pk", title: "PK邀请", buttonText1: "接受邀请", buttonText2: "拒绝邀请", + keyid: keyid, + myitem: counter.myitem.id, + btnDisplay: true, + mytitle: "等待对方接受邀请", }), description: "邀请参加PK", extension: "邀请参加PK", @@ -218,7 +223,6 @@ function sendCustomMessage(myitem, youritem) { payload, needReadReceipt: isEnabledMessageReadReceiptGlobal(), }; - const offlinePushInfoCreateParams = { conversation: currentConversation.value, payload: options.payload, @@ -227,15 +231,36 @@ function sendCustomMessage(myitem, youritem) { const sendMessageOptions = { offlinePushInfo: OfflinePushInfoManager.create(offlinePushInfoCreateParams), }; - TUIChatService.sendCustomMessage(options, sendMessageOptions); - TUIChatService.getMessageList().then((res) => { - console.log("消息列表···································",res); + TUIChatService.sendCustomMessage(options, sendMessageOptions).then((res) => { + const messagein = request({ + url: "chat/add", + method: "POST", + data: { + messageInfo: JSON.stringify(res.data.message), + keyId: keyid, + }, + userInfo: false, + }); + }); + + const messageList = request({ + url: "pk/createPkRecord", + method: "POST", + data: { + pkIdA: youritem.id, + pkIdB: myitem.id, + userIdA: youritem.senderId, + userIdB: myitem.senderId, + pkTime: youritem.pkTime, + status: 0, + }, + userInfo: false, }); myitem.value = null; youritem.value = null; currentConversation.value = null; } -//````````````````````````````````````````````````````````````````````` +//`````````````````````````````````````````````````````````````````````标记 const isInputToolbarShow = computed(() => { return isUniFrameWork ? inputToolbarDisplayType.value !== "none" : true; }); diff --git a/TUIKit/components/TUIChat/message-list/message-elements/message-custom.vue b/TUIKit/components/TUIChat/message-list/message-elements/message-custom.vue index 174a4dd..79c5a7c 100644 --- a/TUIKit/components/TUIChat/message-list/message-elements/message-custom.vue +++ b/TUIKit/components/TUIChat/message-list/message-elements/message-custom.vue @@ -1,6 +1,6 @@