This commit is contained in:
haomingming
2023-03-14 14:09:21 +08:00
parent 14bcbf1673
commit 959bfc61b1
79 changed files with 1601 additions and 438 deletions
+19 -44
View File
@@ -1,63 +1,38 @@
// index.js
import TIM from '../../../TUIKit/lib/tim-wx-sdk';
import { genTestUserSig } from '../../../TUIKit/debug/GenerateTestUserSig';
import TIMUploadPlugin from '../../../TUIKit/lib/tim-upload-plugin';
const app = getApp()
Page({
data: {
config: {
userID: "xiaobeibei", //User ID
SDKAPPID: 1400793692, // Your SDKAppID
SECRETKEY: "44d97cf741fc758be98cdad100015582b6ad1dc5a3b6676c1997a57279eecfa9", // Your secretKey
EXPIRETIME: 604800,
},
patient_account: "ayu",
patient_account: "10000",
title: '患者姓名',
height: app.globalData.height,
height: app.globalData.height,
order_inquiry_id: ""
},
onLoad() {
onLoad(option) {
console.log("chat onload");
let sign = genTestUserSig(this.data.config);
console.log("sign: ", sign);
const userSig = sign.userSig;
console.log("userSig: ", userSig);
wx.$TUIKit = TIM.create({
SDKAppID: this.data.config.SDKAPPID
});
wx.$chat_SDKAppID = this.data.config.SDKAPPID;
wx.$chat_userID = this.data.config.userID;
wx.$chat_userSig = userSig;
wx.$TUIKitTIM = TIM;
wx.$TUIKit.registerPlugin({ 'tim-upload-plugin': TIMUploadPlugin });
wx.$TUIKit.login({
userID: this.data.config.userID,
userSig
});
wx.$TUIKit.setLogLevel(3);//设置日志级别
wx.setStorage({
key: 'currentUserID',
data: [],
});
wx.$TUIKit.on(wx.$TUIKitTIM.EVENT.SDK_READY, this.onSDKReady,this);
let from_account = option.from_account;
let order_inquiry_id = option.order_inquiry_id;
this.setData({
patient_account: from_account,
order_inquiry_id: order_inquiry_id,
})
},
onUnload() {
console.log("chat onUnload");
wx.$TUIKit.off(wx.$TUIKitTIM.EVENT.SDK_READY, this.onSDKReady,this);
},
onShow(){
let _this = this;
let interval = setInterval(() => {
console.log("chat init ,");
console.log("app.globalData.chat_sdk_ready: ", app.globalData.chat_sdk_ready);
if(app.globalData.chat_sdk_ready){
_this.onSDKReady();
const TUIChat = _this.selectComponent('#TUIChat');
TUIChat.init();
wx.$TUIKit.on(wx.$TUIKitTIM.EVENT.MESSAGE_RECEIVED, _this.$onMessageReceived, _this);
clearInterval(interval);
}
}, 100);
}, 1000);
},
onSDKReady() {
console.error("chat js: onSDKReady")
const TUIChat = this.selectComponent('#TUIChat');
TUIChat.init();
app.globalData.chat_sdk_ready = true
$onMessageReceived(value) {
const message = value.data[0];
console.log("message from chat: ",message)
}
})
+4 -6
View File
@@ -1,7 +1,5 @@
<!-- 一对一聊天 -->
<!-- 一对一聊天 不带会话列表 -->
<view>
<TUIChat id="TUIChat" currentConversationID="C2C{{patient_account}}"
unreadCount="9" hasCallKit="{{ true }}" bind:handleCall="handleCall"
></TUIChat>
</view>
<TUIChat id="TUIChat" currentConversationID="C2C{{patient_account}}" order_inquiry_id="{{order_inquiry_id}}"
hasCallKit="{{ true }}" bind:handleCall="handleCall"></TUIChat>
</view>