优化
This commit is contained in:
@@ -1,50 +1,24 @@
|
||||
// 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,
|
||||
},
|
||||
title: '患者姓名',
|
||||
height: app.globalData.height,
|
||||
},
|
||||
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);
|
||||
console.log("onLoad chat_session")
|
||||
},
|
||||
onUnload() {
|
||||
wx.$TUIKit.off(wx.$TUIKitTIM.EVENT.SDK_READY, this.onSDKReady,this);
|
||||
|
||||
},
|
||||
onSDKReady() {
|
||||
console.warn("chat js: onSDKReady")
|
||||
const TUIKit = this.selectComponent('#TUIKit');
|
||||
TUIKit.init();
|
||||
onShow(){
|
||||
let _this = this;
|
||||
let interval = setInterval(() => {
|
||||
if(app.globalData.chat_sdk_ready){
|
||||
const TUIKit = _this.selectComponent('#TUIKit');
|
||||
TUIKit.init();
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user