const app = getApp() Page({ data: { patient_account: "", title: '', height: app.globalData.height, order_inquiry_id: "", inquiry_type: "", }, onLoad(option) { console.log("chat onload", option); let from_account = option.from_account; let order_inquiry_id = option.order_inquiry_id; let inquiry_type = option.inquiry_type; this.setData({ patient_account: from_account, order_inquiry_id: order_inquiry_id, inquiry_type: inquiry_type, }) }, onUnload() { console.log("chat onUnload"); }, 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){ const TUIChat = _this.selectComponent('#TUIChat'); TUIChat.init(); wx.$TUIKit.on(wx.$TUIKitTIM.EVENT.MESSAGE_RECEIVED, _this.$onMessageReceived, _this); clearInterval(interval); } }, 1000); }, $onMessageReceived(value) { const message = value.data[0]; console.log("message from chat: ",message) } })