1555 lines
46 KiB
JavaScript
1555 lines
46 KiB
JavaScript
import logger from '../../../../utils/logger';
|
||
import constant from '../../../../utils/constant';
|
||
import { API } from '../../../../../../utils/network/api';
|
||
import dayjs from '../../../../utils/dayjs';
|
||
import { requestSubscribeMessage } from '../../../../../../utils/requestSubscribeUtil';
|
||
import { TUICallKitServer } from "../../../../../../TUICallKit/TUICallService/index";
|
||
const api = new API()
|
||
let app = getApp()
|
||
// eslint-disable-next-line no-undef
|
||
Component({
|
||
/**
|
||
* 组件的属性列表
|
||
*/
|
||
properties: {
|
||
conversation: {
|
||
type: Object,
|
||
value: {},
|
||
observer(newVal) {
|
||
this.setData({
|
||
conversation: newVal,
|
||
});
|
||
},
|
||
},
|
||
order_inquiry_id: {
|
||
type: String,
|
||
value: {},
|
||
},
|
||
from:{
|
||
type: String,
|
||
value: '',
|
||
observer(from) {
|
||
this.setData({
|
||
from: from,
|
||
});
|
||
}
|
||
},
|
||
inquiry_type: {
|
||
type: String,
|
||
value: {},
|
||
},
|
||
isEditTime:{
|
||
type: Boolean,
|
||
value: false,
|
||
observer(isEditTime) {
|
||
console.log(isEditTime)
|
||
this.setData({
|
||
isEditTime
|
||
});
|
||
},
|
||
},
|
||
serviceInfo:{
|
||
type: Object,
|
||
value:{},
|
||
observer(val){
|
||
this.setData({
|
||
serviceInfo:val
|
||
});
|
||
}
|
||
},
|
||
videoInfo:{
|
||
type: Object,
|
||
value:{},
|
||
observer(videoInfo){
|
||
this.setData({
|
||
videoInfo
|
||
});
|
||
}
|
||
|
||
},
|
||
hasCallKit: {
|
||
type: Boolean,
|
||
value: false,
|
||
observer(hasCallKit) {
|
||
this.setData({
|
||
hasCallKit,
|
||
});
|
||
},
|
||
},
|
||
has_audio:{
|
||
type: Boolean,
|
||
value: false,
|
||
},
|
||
has_emoji:{
|
||
type: Boolean,
|
||
value: false,
|
||
},
|
||
baseInfo: {
|
||
type: Object,
|
||
value: {},
|
||
observer(newVal) {
|
||
this.setData({
|
||
baseInfo:newVal,
|
||
patient_user_id: newVal.patient_user_id,
|
||
family_id: newVal.family_id,
|
||
});
|
||
},
|
||
},
|
||
message_rounds:{
|
||
type: Number,
|
||
value: 0,
|
||
observer(newVal) {
|
||
this.setData({
|
||
message_rounds: newVal,
|
||
});
|
||
},
|
||
}
|
||
},
|
||
|
||
/**
|
||
* 组件的初始数据
|
||
*/
|
||
data: {
|
||
conversation: {},
|
||
message: '',
|
||
showRound:false,
|
||
video_dialog_visible:false,
|
||
showTalk:false,
|
||
videoInfo:{},
|
||
serviceInfo:{},
|
||
baseInfo:{},
|
||
family_id:'',
|
||
patient_user_id:'',
|
||
extensionArea: false,
|
||
sendMessageBtn: false,
|
||
displayFlag: '',
|
||
isAudio: false,
|
||
columnsRound:[3,7,15],
|
||
bottomVal: 0,
|
||
startPoint: 0,
|
||
popupToggle: false,
|
||
isRecording: false,
|
||
canSend: true,
|
||
text: '按住说话',
|
||
title: ' ',
|
||
notShow: false,
|
||
isShow: true,
|
||
currentDate: null,
|
||
minDate:new Date().getTime(),
|
||
maxDate:null,
|
||
commonFunction: [
|
||
{ name: '查看完整病历', key: '10' },
|
||
{ name: '在线开处方', key: '11' },
|
||
],
|
||
displayServiceEvaluation: false,
|
||
showErrorImageFlag: 0,
|
||
messageList: [],
|
||
isFirstSendTyping: true,
|
||
time: 0,
|
||
focus: false,
|
||
my_focus: false,
|
||
isEmoji: false,
|
||
fileList: [],
|
||
hasCallKit: false,
|
||
showChangYongYu: false,
|
||
ChangYongYu: [],
|
||
dialog_visible: false,
|
||
sub_visible: false,
|
||
timer:null,
|
||
recordtime:0,
|
||
dialog_message: "在线开处方需先进行多点执业认证",
|
||
message_rounds: 0,
|
||
times_number:2,
|
||
duration:7,
|
||
networkstatus: "wifi",
|
||
defaultRoundIndex:0,
|
||
static_host: api.getStaticHost(),
|
||
formatter(type, value) {
|
||
if (type === 'year') {
|
||
return `${value}年`;
|
||
}
|
||
if (type === 'month') {
|
||
return `${value}月`;
|
||
}
|
||
if (type === 'day') {
|
||
return `${value}日`;
|
||
}
|
||
if (type === 'hour') {
|
||
return `${value}时`;
|
||
}
|
||
if (type === 'minute') {
|
||
return `${value}分`;
|
||
}
|
||
return value;
|
||
},
|
||
},
|
||
|
||
lifetimes: {
|
||
attached() {
|
||
let _this = this;
|
||
// 加载声音录制管理器
|
||
this.recorderManager = wx.getRecorderManager();
|
||
this.recorderManager.onStop(async(resData) => {
|
||
wx.hideLoading();
|
||
if (this.data.canSend) {
|
||
if (resData.duration < 1000) {
|
||
wx.showToast({
|
||
title: '录音时间太短',
|
||
icon: 'none',
|
||
});
|
||
} else {
|
||
if(resData.duration >= 60000){
|
||
wx.showToast({
|
||
title: '录音时间不能超过60s',
|
||
duration:2000,
|
||
icon: 'none',
|
||
});
|
||
}
|
||
let {from}=this.data;
|
||
// res.tempFilePath 存储录音文件的临时路径
|
||
if(from){
|
||
await this.handlegetLastInquiry();
|
||
}
|
||
|
||
let conversationID = this.data.conversation.conversationID
|
||
let promise = wx.$TUIKit.getConversationProfile(conversationID);
|
||
promise.then((imResponse)=> {
|
||
// console.log("getConversationProfile 正在执行")
|
||
// 获取成功
|
||
// console.log(imResponse.data.conversation); // 会话资料
|
||
_this.setData({
|
||
conversation: imResponse.data.conversation
|
||
})
|
||
}).catch(function(imError) {
|
||
console.warn('getConversationProfile error:', imError); // 获取会话资料失败的相关信息
|
||
});
|
||
|
||
Promise.all([promise]).then(res => {
|
||
// 获取最后一条消息
|
||
let last_message = this.data.conversation.lastMessage;
|
||
// console.log("last_message: ", last_message);
|
||
let cloudCustomData = "";
|
||
let cloudCustomDataJson = "";
|
||
if(last_message.cloudCustomData){
|
||
cloudCustomData = last_message.cloudCustomData;
|
||
}
|
||
if(cloudCustomData){
|
||
cloudCustomDataJson = JSON.parse(cloudCustomData);
|
||
}
|
||
let message_rounds = 0;
|
||
let patient_family_data = {};
|
||
patient_family_data.patient_name = this.data.baseInfo.patient_family_name;
|
||
patient_family_data.patient_sex = this.data.baseInfo.patient_family_sex;
|
||
patient_family_data.patient_age = this.data.baseInfo.patient_family_age;
|
||
if(cloudCustomDataJson){
|
||
message_rounds = cloudCustomDataJson.message_rounds;
|
||
}
|
||
|
||
let cach_message_rounds = this.data.message_rounds
|
||
message_rounds = cach_message_rounds>message_rounds?cach_message_rounds:message_rounds
|
||
let {serviceInfo}=this.data;
|
||
const mycloudCustomData = JSON.stringify({
|
||
order_inquiry_id: this.data.order_inquiry_id,
|
||
inquiry_type: this.data.inquiry_type,
|
||
inquiry_mode:this.data.baseInfo.inquiry_mode,
|
||
message_type: 0,
|
||
is_system: 0,
|
||
message_rounds: message_rounds,
|
||
remaining_month_inquiry_count:serviceInfo.remaining_month_inquiry_count,
|
||
month_inquiry_count:serviceInfo.month_inquiry_count,
|
||
service_package_start_time:serviceInfo.start_time,
|
||
service_package_finish_time:serviceInfo.finish_time,
|
||
service_period:serviceInfo.service_period,
|
||
remaining_quantity:serviceInfo.remaining_quantity,
|
||
monthly_frequency:serviceInfo.monthly_frequency,
|
||
patient_family_data: patient_family_data
|
||
});
|
||
|
||
const message = wx.$TUIKit.createAudioMessage({
|
||
to: this.getToAccount(),
|
||
conversationType: this.data.conversation.type,
|
||
payload: {
|
||
file: resData,
|
||
},
|
||
cloudCustomData:mycloudCustomData
|
||
});
|
||
|
||
_this.$sendTIMMessage(message);
|
||
|
||
}).catch(err=>{
|
||
|
||
console.log(err)
|
||
})
|
||
}
|
||
}
|
||
this.setData({
|
||
startPoint: 0,
|
||
popupToggle: false,
|
||
isRecording: false,
|
||
canSend: true,
|
||
title: ' ',
|
||
text: '按住说话',
|
||
});
|
||
});
|
||
wx.onNetworkStatusChange(function (res) {
|
||
// console.log("onNetworkStatusChange from wenzhen: ")
|
||
// console.log(res.isConnected)
|
||
// console.log(res.networkType)
|
||
// wx.showToast({
|
||
// title: '网络类型:'+res.networkType,
|
||
// })
|
||
|
||
_this.setData({
|
||
networkstatus: res.networkType
|
||
})
|
||
})
|
||
console.log("pageLifetimes show")
|
||
wx.getNetworkType({
|
||
success (res) {
|
||
const networkType = res.networkType
|
||
_this.setData({
|
||
networkstatus: networkType
|
||
})
|
||
}
|
||
})
|
||
},
|
||
|
||
},
|
||
pageLifetimes:{
|
||
show(){
|
||
var currentDate = new Date();
|
||
// 在当前日期基础上增加2天
|
||
currentDate.setDate(currentDate.getDate() + 2);
|
||
var twoDaysLaterTimestamp = currentDate.getTime();
|
||
this.setData({
|
||
maxDate:twoDaysLaterTimestamp
|
||
})
|
||
//获得常用语
|
||
let words = wx.getStorageSync('words');
|
||
// console.log("words from chat: ", words);
|
||
if(words){
|
||
this.setData({
|
||
message: words,
|
||
sendMessageBtn: true
|
||
})
|
||
wx.setStorageSync('words', "");
|
||
}
|
||
|
||
// console.log("pageLifetimes show")
|
||
let _this = this
|
||
wx.getNetworkType({
|
||
success (res) {
|
||
const networkType = res.networkType
|
||
_this.setData({
|
||
networkstatus: networkType
|
||
})
|
||
}
|
||
})
|
||
|
||
},
|
||
hide: function () {
|
||
let THIS=this;
|
||
if(THIS.data.isRecording){
|
||
THIS.handleTouchEnd()
|
||
}
|
||
},
|
||
},
|
||
|
||
/**
|
||
* 组件的方法列表
|
||
*/
|
||
methods: {
|
||
onClickHide(){
|
||
this.setData({
|
||
showTalk:false
|
||
})
|
||
},
|
||
noop() {},
|
||
sendTalk(){
|
||
let {order_inquiry_id,duration,times_number}=this.data;
|
||
if(times_number==''){
|
||
wx.showToast({
|
||
title: '回合数不能为空',
|
||
icon:'none'
|
||
})
|
||
return false
|
||
}
|
||
if(!(times_number>=0 && times_number<=300)){
|
||
wx.showToast({
|
||
title: '回合数在0~300之间',
|
||
icon:'none'
|
||
})
|
||
return false
|
||
}
|
||
if(!duration){
|
||
wx.showToast({
|
||
title: '请选择回合周期',
|
||
icon:'none'
|
||
})
|
||
return false
|
||
}
|
||
this.setData({
|
||
showTalk:false
|
||
})
|
||
api.giveRounds({
|
||
order_inquiry_id,
|
||
duration:duration*24*60,
|
||
times_number
|
||
}).then(response => {
|
||
if(response.code==200){
|
||
wx.showToast({
|
||
title: '赠送成功',
|
||
icon:"none"
|
||
})
|
||
}
|
||
|
||
}).catch(errors => {
|
||
console.error(errors);
|
||
})
|
||
},
|
||
changeCustomIpt(event){
|
||
let {value}= event.detail;
|
||
this.setData({
|
||
times_number:value
|
||
})
|
||
},
|
||
openRound(){
|
||
let {duration,columnsRound}=this.data;
|
||
for (let i = 0; i < columnsRound.length; i++) {
|
||
if(columnsRound[i]==duration){
|
||
this.setData({
|
||
defaultRoundIndex:i
|
||
});
|
||
break;
|
||
};
|
||
|
||
}
|
||
|
||
this.setData({
|
||
showRound:true
|
||
})
|
||
},
|
||
onCancelRound(){
|
||
this.setData({
|
||
showRound:false
|
||
})
|
||
},
|
||
onConfirmRound(event){
|
||
const { value} = event.detail;
|
||
this.setData({
|
||
showRound:false,
|
||
duration:value
|
||
})
|
||
|
||
},
|
||
appointmentTime(reservation_time){
|
||
let {order_inquiry_id}=this.data;
|
||
api.appointmentTime({
|
||
order_inquiry_id,
|
||
reservation_time
|
||
}).then(response => {
|
||
if(response.code==200){
|
||
wx.showToast({
|
||
title: '预约成功',
|
||
icon:"none"
|
||
})
|
||
this.triggerEvent("freshVideoInfo");
|
||
}
|
||
|
||
}).catch(errors => {
|
||
console.error(errors);
|
||
})
|
||
},
|
||
openVidaoDialog(){
|
||
this.setData({
|
||
video_dialog_visible:true
|
||
})
|
||
},
|
||
call() {
|
||
let {baseInfo}=this.data;
|
||
|
||
wx.setStorage({
|
||
key:'patientInfo',
|
||
data:{
|
||
order_inquiry_id:baseInfo.order_inquiry_id,
|
||
inquiry_type:baseInfo.inquiry_type,
|
||
inquiry_mode:baseInfo.inquiry_mode,
|
||
message_rounds:0,
|
||
patient_user_id:baseInfo.patient_user_id,
|
||
patient_family_data: {
|
||
patient_name:baseInfo.patient_family_name,
|
||
patient_sex:baseInfo.patient_family_sex,
|
||
patient_age:baseInfo.patient_family_age
|
||
},
|
||
is_system:1
|
||
}
|
||
}
|
||
)
|
||
api.geRoomId({
|
||
order_inquiry_id:baseInfo.order_inquiry_id
|
||
}).then(async(res)=>{
|
||
let result=res.data;
|
||
console.log("本人userID:"+app.globalData.config.userID);
|
||
console.log("呼叫userID:"+this.data.patient_user_id)
|
||
TUICallKitServer.setLogLevel(0);
|
||
await TUICallKitServer.call({
|
||
userID: this.data.patient_user_id,
|
||
type: 2,
|
||
roomID:Number(result)
|
||
});
|
||
this.triggerEvent("freshVideoInfo");
|
||
})
|
||
|
||
},
|
||
// 获取消息列表来判断是否发送正在输入状态
|
||
getMessageList(conversation) {
|
||
wx.$TUIKit.getMessageList({
|
||
conversationID: conversation.conversationID,
|
||
nextReqMessageID: this.data.nextReqMessageID,
|
||
count: 15,
|
||
}).then((res) => {
|
||
const { messageList } = res.data;
|
||
this.setData({
|
||
messageList,
|
||
});
|
||
});
|
||
},
|
||
|
||
// 打开录音开关
|
||
switchAudio() {
|
||
wx.hideKeyboard();
|
||
if(!this.data.isAudio){
|
||
wx.getSetting({
|
||
success(res) {
|
||
if (!res.authSetting['scope.record']) {
|
||
wx.authorize({
|
||
scope: 'scope.record',
|
||
success () {
|
||
|
||
}
|
||
})
|
||
}
|
||
}
|
||
})
|
||
}
|
||
this.setData({
|
||
isAudio: !this.data.isAudio,
|
||
isEmoji: false,
|
||
text: '按住说话',
|
||
focus: false,
|
||
message:'',
|
||
sendMessageBtn:false
|
||
});
|
||
this.setData({
|
||
displayFlag: '',
|
||
});
|
||
},
|
||
openRecord(e,callback){
|
||
let THIS=this;
|
||
return new Promise((resolve, reject) => {
|
||
wx.getSetting({
|
||
success(res) {
|
||
if(!(res.authSetting['scope.record'])) { // 关闭订阅消息主按钮
|
||
return wx.showModal({
|
||
title: '提示',
|
||
content: '您已关闭麦克风权限,请点击“确认”按钮在设置中打开麦克风权限。',
|
||
success: function (res) {
|
||
if (res.confirm) {
|
||
wx.openSetting({
|
||
success(res) {
|
||
|
||
}
|
||
});
|
||
}
|
||
},
|
||
complete(){
|
||
|
||
}
|
||
});
|
||
} else { // 开放订阅消息主按钮
|
||
callback(e,THIS);
|
||
resolve()
|
||
}
|
||
},
|
||
complete(){
|
||
wx.hideLoading();
|
||
|
||
}
|
||
})
|
||
})
|
||
},
|
||
// 长按录音
|
||
handleLongPress(e) {
|
||
this.openRecord(e,this.recording)
|
||
},
|
||
recording(e,THIS){
|
||
wx.aegis.reportEvent({
|
||
name: 'messageType',
|
||
ext1: 'messageType-audio',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
THIS.recorderManager.start({
|
||
duration: 61000, // 录音的时长,单位 ms,最大值 600000(10 分钟)
|
||
sampleRate: 44100, // 采样率
|
||
numberOfChannels: 1, // 录音通道数
|
||
encodeBitRate: 192000, // 编码码率
|
||
format: 'aac', // 音频格式,选择此格式创建的音频消息,可以在即时通信 IM 全平台(Android、iOS、微信小程序和Web)互通
|
||
});
|
||
|
||
THIS.timer=setInterval(()=>{
|
||
if(THIS.data.recordtime>=60){
|
||
THIS.handleTouchEnd();
|
||
clearInterval(THIS.timer);
|
||
|
||
};
|
||
THIS.setData({
|
||
recordtime:THIS.data.recordtime+1
|
||
});
|
||
|
||
},1000)
|
||
console.log("handleLongPress")
|
||
THIS.setData({
|
||
startPoint: e.touches[0],
|
||
title: '正在录音',
|
||
// isRecording : true,
|
||
// canSend: true,
|
||
notShow: true,
|
||
isShow: false,
|
||
isRecording: true,
|
||
popupToggle: true,
|
||
});
|
||
},
|
||
|
||
// 录音时的手势上划移动距离对应文案变化
|
||
handleTouchMove(e) {
|
||
console.log("handleTouchMove")
|
||
if (this.data.isRecording) {
|
||
if (this.data.startPoint.clientY - e.touches[e.touches.length - 1].clientY > 100) {
|
||
this.setData({
|
||
text: '抬起停止',
|
||
title: '松开手指,取消发送',
|
||
canSend: false,
|
||
});
|
||
} else if (this.data.startPoint.clientY - e.touches[e.touches.length - 1].clientY > 20) {
|
||
this.setData({
|
||
text: '抬起停止',
|
||
title: '上划可取消',
|
||
canSend: true,
|
||
});
|
||
} else {
|
||
this.setData({
|
||
text: '抬起停止',
|
||
title: '正在录音',
|
||
canSend: true,
|
||
});
|
||
}
|
||
}
|
||
},
|
||
|
||
// 手指离开页面滑动
|
||
handleTouchEnd() {
|
||
wx.nextTick(() => {
|
||
this.setData({
|
||
isRecording: false,
|
||
popupToggle: false,
|
||
|
||
});
|
||
console.log("handleTouchEnd")
|
||
wx.hideLoading();
|
||
this.recorderManager.stop();
|
||
clearInterval(this.timer);
|
||
this.setData({
|
||
recordtime:0
|
||
})
|
||
})
|
||
|
||
},
|
||
handleTouchCancel(){
|
||
this.setData({
|
||
isRecording: false,
|
||
popupToggle: false,
|
||
|
||
});
|
||
console.log("handleTouchCancel")
|
||
wx.hideLoading();
|
||
this.recorderManager.stop();
|
||
clearInterval(this.timer);
|
||
this.setData({
|
||
recordtime:0
|
||
})
|
||
},
|
||
// 选中表情消息
|
||
handleEmoji() {
|
||
let targetFlag = 'emoji';
|
||
if (this.data.displayFlag === 'emoji') {
|
||
targetFlag = '';
|
||
}
|
||
this.setData({
|
||
isAudio: false,
|
||
isEmoji: true,
|
||
displayFlag: targetFlag,
|
||
focus: false,
|
||
});
|
||
},
|
||
|
||
// 选自定义消息
|
||
handleExtensions() {
|
||
|
||
console.warn("wx.aegis: ", wx.aegis);
|
||
wx.aegis.reportEvent({
|
||
name: 'chooseExtensions',
|
||
ext1: 'chooseExtensions',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
|
||
let targetFlag = 'extension';
|
||
if (this.data.displayFlag === 'extension') {
|
||
targetFlag = '';
|
||
}
|
||
this.setData({
|
||
displayFlag: targetFlag,
|
||
isAudio:false
|
||
});
|
||
var myEventDetail = {} // detail对象,提供给事件监听函数
|
||
myEventDetail.displayFlag = targetFlag;
|
||
var myEventOption = {} // 触发事件的选项
|
||
this.triggerEvent('myhandleExtensions', myEventDetail, myEventOption)
|
||
},
|
||
|
||
error(e) {
|
||
console.log(e.detail);
|
||
},
|
||
|
||
handleSendPicture() {
|
||
this.sendMediaMessage('camera', 'image');
|
||
},
|
||
|
||
handleSendImage() {
|
||
wx.aegis.reportEvent({
|
||
name: 'messageType',
|
||
ext1: 'messageType-image',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
this.sendMediaMessage('album', 'image');
|
||
},
|
||
|
||
sendMediaMessage(type, mediaType) {
|
||
const { fileList } = this.data;
|
||
wx.chooseMedia({
|
||
count: 9,
|
||
sourceType: [type],
|
||
mediaType: [mediaType],
|
||
success: (res) => {
|
||
const mediaInfoList = res.tempFiles;
|
||
mediaInfoList.forEach((mediaInfo) => {
|
||
fileList.push({ type: res.type, tempFiles: [{ tempFilePath: mediaInfo.tempFilePath }] });
|
||
});
|
||
fileList.forEach((file) => {
|
||
if (file.type === 'image') {
|
||
this.handleSendImageMessage(file);
|
||
}
|
||
if (file.type === 'video') {
|
||
this.handleSendVideoMessage(file);
|
||
}
|
||
});
|
||
this.data.fileList = [];
|
||
},
|
||
});
|
||
},
|
||
|
||
// 发送图片消息
|
||
async handleSendImageMessage(file) {
|
||
|
||
let networkstatus = this.data.networkstatus
|
||
let {from}=this.data;
|
||
// console.log("networkstatus: ", networkstatus)
|
||
if(networkstatus === 'none'){
|
||
wx.showToast({
|
||
title: '请检查您的网络',
|
||
icon: 'error'
|
||
})
|
||
return
|
||
}
|
||
if(from){
|
||
await this.handlegetLastInquiry();
|
||
}
|
||
let _this = this;
|
||
let conversationID = this.data.conversation.conversationID
|
||
let promise = wx.$TUIKit.getConversationProfile(conversationID);
|
||
promise.then(function(imResponse) {
|
||
// console.log("getConversationProfile 正在执行")
|
||
// 获取成功
|
||
// console.log(imResponse.data.conversation); // 会话资料
|
||
_this.setData({
|
||
conversation: imResponse.data.conversation
|
||
})
|
||
}).catch(function(imError) {
|
||
console.warn('getConversationProfile error:', imError); // 获取会话资料失败的相关信息
|
||
});
|
||
|
||
Promise.all([promise]).then(res => {
|
||
// 获取最后一条消息
|
||
let last_message = this.data.conversation.lastMessage;
|
||
// console.log("last_message: ", last_message);
|
||
let cloudCustomData = "";
|
||
let cloudCustomDataJson = "";
|
||
if(last_message.cloudCustomData){
|
||
cloudCustomData = last_message.cloudCustomData;
|
||
}
|
||
if(cloudCustomData){
|
||
cloudCustomDataJson = JSON.parse(cloudCustomData);
|
||
}
|
||
let message_rounds = 0;
|
||
let patient_family_data = {};
|
||
patient_family_data.patient_name = this.data.baseInfo.patient_family_name;
|
||
patient_family_data.patient_sex = this.data.baseInfo.patient_family_sex;
|
||
patient_family_data.patient_age = this.data.baseInfo.patient_family_age;
|
||
if(cloudCustomDataJson){
|
||
message_rounds = cloudCustomDataJson.message_rounds;
|
||
}
|
||
|
||
let cach_message_rounds = this.data.message_rounds
|
||
message_rounds = cach_message_rounds>message_rounds?cach_message_rounds:message_rounds
|
||
let {serviceInfo}=this.data;
|
||
const mycloudCustomData = JSON.stringify({
|
||
order_inquiry_id: this.data.order_inquiry_id,
|
||
inquiry_type: this.data.inquiry_type,
|
||
inquiry_mode:this.data.baseInfo.inquiry_mode,
|
||
message_type: 0,
|
||
is_system: 0,
|
||
message_rounds: message_rounds,
|
||
remaining_month_inquiry_count:serviceInfo.remaining_month_inquiry_count,
|
||
month_inquiry_count:serviceInfo.month_inquiry_count,
|
||
service_package_start_time:serviceInfo.start_time,
|
||
service_package_finish_time:serviceInfo.finish_time,
|
||
service_period:serviceInfo.service_period,
|
||
remaining_quantity:serviceInfo.remaining_quantity,
|
||
monthly_frequency:serviceInfo.monthly_frequency,
|
||
patient_family_data: patient_family_data
|
||
});
|
||
|
||
const message = wx.$TUIKit.createImageMessage({
|
||
to: this.getToAccount(),
|
||
conversationType: this.data.conversation.type,
|
||
payload: {
|
||
file,
|
||
},
|
||
cloudCustomData: mycloudCustomData,
|
||
onProgress: (percent) => {
|
||
message.percent = percent;
|
||
},
|
||
});
|
||
this.$sendTIMMessage(message);
|
||
})
|
||
},
|
||
|
||
|
||
// 发送视频消息
|
||
handleSendVideoMessage(file) {
|
||
const message = wx.$TUIKit.createVideoMessage({
|
||
to: this.getToAccount(),
|
||
conversationType: this.data.conversation.type,
|
||
payload: {
|
||
file,
|
||
},
|
||
onProgress: (percent) => {
|
||
message.percent = percent;
|
||
},
|
||
});
|
||
this.$sendTIMMessage(message);
|
||
},
|
||
|
||
handleShootVideo() {
|
||
this.sendMediaMessage('camera', 'video');
|
||
},
|
||
|
||
handleSendVideo() {
|
||
wx.aegis.reportEvent({
|
||
name: 'messageType',
|
||
ext1: 'messageType-video',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
this.sendMediaMessage('album', 'video');
|
||
},
|
||
|
||
handleCommonFunctions(e) {
|
||
// console.log("handleCommonFunctions: ", e)
|
||
switch (e.target.dataset.key) {
|
||
case '0':
|
||
this.setData({
|
||
displayCommonWords: true,
|
||
});
|
||
break;
|
||
case '1':
|
||
this.setData({
|
||
displayOrderList: true,
|
||
});
|
||
break;
|
||
case '2':
|
||
this.setData({
|
||
displayServiceEvaluation: true,
|
||
});
|
||
break;
|
||
case '10'://查看完整病历
|
||
// app.go("/Pages/yishi/case/index?order_inquiry_id="+this.data.order_inquiry_id)
|
||
app.go("/user/pages/yishi/patient_sick/index?order_inquiry_id="+this.data.order_inquiry_id+"&family_id="+this.data.family_id)
|
||
break;
|
||
case '11'://在线开方
|
||
let _this = this;
|
||
console.log("开始订阅消息");
|
||
let tmplIds = ['kUy70xHlr7ADo4aIHiictM4Te7MSec3E5kHsYvFQu40']
|
||
let sub_promise = requestSubscribeMessage(tmplIds)
|
||
sub_promise.then(res => {
|
||
console.log("订阅成功")
|
||
this.goCase()
|
||
}).catch(err => {
|
||
console.log(err)
|
||
let errCode = err.errCode
|
||
if(errCode == 20004){
|
||
_this.setData({
|
||
sub_visible: true,
|
||
})
|
||
}
|
||
})
|
||
break;
|
||
case '12'://预约视频时间
|
||
this.openTimePicker();
|
||
break;
|
||
case '13':
|
||
this.openVidaoDialog();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
},
|
||
openTimePicker(){
|
||
this.setData({
|
||
currentDate:new Date().getTime(),
|
||
minDate:new Date().getTime(),
|
||
showTimepicker:true
|
||
})
|
||
},
|
||
cancelTimepicker(){
|
||
this.setData({
|
||
showTimepicker:false
|
||
})
|
||
},
|
||
confirmTimepicker(event){
|
||
let time=dayjs(event.detail).format('YYYY-MM-DD HH:mm');
|
||
this.setData({
|
||
showTimepicker:false
|
||
})
|
||
this.appointmentTime(time);
|
||
},
|
||
goCase(){
|
||
|
||
let order_inquiry_id = this.data.order_inquiry_id
|
||
api.getDoctorPrescriptionCheck({order_inquiry_id: order_inquiry_id}).then(response => {
|
||
let status = response.data.status
|
||
if(status == 1){
|
||
app.go("/user/pages/yishi/onlinechufang/index?order_inquiry_id="+order_inquiry_id)
|
||
}else{
|
||
this.setData({
|
||
dialog_visible: true,
|
||
dialog_message: response.data.message
|
||
})
|
||
}
|
||
}).catch(errors => {
|
||
console.error(errors);
|
||
})
|
||
},
|
||
cancelDialog(){
|
||
this.setData({
|
||
dialog_visible: false
|
||
})
|
||
},
|
||
cancelDialogVideo(){
|
||
this.setData({
|
||
video_dialog_visible: false
|
||
})
|
||
},
|
||
confirmDialogVideo(){
|
||
this.setData({
|
||
video_dialog_visible: false
|
||
})
|
||
this.call();
|
||
},
|
||
//获取问诊订单状态
|
||
async getInquiryMessageBasic(order_inquiry_id) {
|
||
// console.log("order_inquiry_id: ", this.data.order_inquiry_id);
|
||
await api.getInquiryMessageBasic({order_inquiry_id:order_inquiry_id}).then(response => {
|
||
let result=response.data;
|
||
console.log(result.inquiry_status)
|
||
if(result.inquiry_status==3){
|
||
wx.showToast({
|
||
title: '暂时不能发送消息',
|
||
});
|
||
return false;
|
||
}
|
||
}).then(res => {
|
||
|
||
}).catch(errors => {console.error(errors);})
|
||
},
|
||
//获取最新问诊id;
|
||
async handlegetLastInquiry(){
|
||
let {baseInfo,order_inquiry_id}=this.data;
|
||
const {data} =await api.getLastInquiry({
|
||
patient_id:baseInfo.patient_id,
|
||
doctor_id:baseInfo.doctor_id
|
||
})
|
||
if(data){
|
||
if(data!=order_inquiry_id){
|
||
const result=await api.getInquiryMessageBasic({order_inquiry_id:data});
|
||
if(result.data.inquiry_status==3){
|
||
wx.showToast({
|
||
title: '暂时不能发送消息',
|
||
});
|
||
return false;
|
||
}
|
||
//this.getInquiryMessageBasic(data);
|
||
}
|
||
}
|
||
// .then(data=>{
|
||
|
||
// let result=data.data;
|
||
// console.log(result,order_inquiry_id)
|
||
// if(result){
|
||
// if(result!=order_inquiry_id){
|
||
// this.getInquiryMessageBasic(result);
|
||
// }
|
||
// }
|
||
|
||
// })
|
||
},
|
||
confirmDialog(){
|
||
// app.go("/Pages/yishi/zhiye_identity/index")
|
||
this.setData({
|
||
dialog_visible: false
|
||
})
|
||
},
|
||
subcancelDialog(){
|
||
this.setData({
|
||
sub_visible: false
|
||
})
|
||
this.goCase()
|
||
},
|
||
subconfirmDialog(){
|
||
this.setData({
|
||
sub_visible: false
|
||
})
|
||
wx.openSetting({
|
||
success (res) {
|
||
// console.log(res.authSetting)
|
||
}
|
||
})
|
||
},
|
||
handleSendOrder() {
|
||
this.setData({
|
||
displayOrderList: true,
|
||
});
|
||
},
|
||
|
||
appendMessage(e) {
|
||
this.setData({
|
||
message: this.data.message + e.detail.message,
|
||
sendMessageBtn: true,
|
||
});
|
||
},
|
||
|
||
getToAccount() {
|
||
if (!this.data.conversation || !this.data.conversation.conversationID) {
|
||
return '';
|
||
}
|
||
switch (this.data.conversation.type) {
|
||
case wx.$TUIKitTIM.TYPES.CONV_C2C:
|
||
return this.data.conversation.conversationID.replace(wx.$TUIKitTIM.TYPES.CONV_C2C, '');
|
||
case wx.$TUIKitTIM.TYPES.CONV_GROUP:
|
||
return this.data.conversation.conversationID.replace(wx.$TUIKitTIM.TYPES.CONV_GROUP, '');
|
||
default:
|
||
return this.data.conversation.conversationID;
|
||
}
|
||
},
|
||
async handleCheckAuthorize(e) {
|
||
const type = e.currentTarget.dataset.value;
|
||
wx.getSetting({
|
||
success: async (res) => {
|
||
const isRecord = res.authSetting['scope.record'];
|
||
const isCamera = res.authSetting['scope.camera'];
|
||
if (!isRecord && type === 1) {
|
||
const title = '麦克风权限授权';
|
||
const content = '使用语音通话,需要在设置中对麦克风进行授权允许';
|
||
try {
|
||
await wx.authorize({ scope: 'scope.record' });
|
||
this.handleCalling(e);
|
||
} catch (e) {
|
||
this.handleShowModal(title, content);
|
||
}
|
||
return;
|
||
}
|
||
if ((!isRecord || !isCamera) && type === 2) {
|
||
const title = '麦克风、摄像头权限授权';
|
||
const content = '使用视频通话,需要在设置中对麦克风、摄像头进行授权允许';
|
||
try {
|
||
await wx.authorize({ scope: 'scope.record' });
|
||
await wx.authorize({ scope: 'scope.camera' });
|
||
this.handleCalling(e);
|
||
} catch (e) {
|
||
this.handleShowModal(title, content);
|
||
}
|
||
return;
|
||
}
|
||
this.handleCalling(e);
|
||
},
|
||
});
|
||
},
|
||
handleShowModal(title, content) {
|
||
wx.showModal({
|
||
title,
|
||
content,
|
||
confirmText: '去设置',
|
||
success: (res) => {
|
||
if (res.confirm) {
|
||
wx.openSetting();
|
||
}
|
||
},
|
||
});
|
||
},
|
||
|
||
handleCalling(e) {
|
||
if (!this.data.hasCallKit) {
|
||
wx.showToast({
|
||
title: '请先集成 TUICallKit 组件',
|
||
icon: 'none',
|
||
});
|
||
return;
|
||
}
|
||
const type = e.currentTarget.dataset.value;
|
||
const conversationType = this.data.conversation.type;
|
||
if (conversationType === wx.$TUIKitTIM.TYPES.CONV_GROUP) {
|
||
if (type === 1) {
|
||
wx.aegis.reportEvent({
|
||
name: 'audioCall',
|
||
ext1: 'audioCall-group',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
} else if (type === 2) {
|
||
wx.aegis.reportEvent({
|
||
name: 'videoCall',
|
||
ext1: 'videoCall-group',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
}
|
||
this.triggerEvent('handleCall', {
|
||
type,
|
||
conversationType,
|
||
});
|
||
}
|
||
if (conversationType === wx.$TUIKitTIM.TYPES.CONV_C2C) {
|
||
const { userID } = this.data.conversation.userProfile;
|
||
if (type === 1) {
|
||
wx.aegis.reportEvent({
|
||
name: 'audioCall',
|
||
ext1: 'audioCall-1v1',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
} else if (type === 2) {
|
||
wx.aegis.reportEvent({
|
||
name: 'videoCall',
|
||
ext1: 'videoCall-1v1',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
}
|
||
this.triggerEvent('handleCall', {
|
||
conversationType,
|
||
type,
|
||
userID,
|
||
});
|
||
}
|
||
this.setData({
|
||
displayFlag: '',
|
||
});
|
||
},
|
||
|
||
async sendTextMessage(msg, flag) {
|
||
let networkstatus = this.data.networkstatus
|
||
let {from}=this.data;
|
||
// console.log("networkstatus: ", networkstatus)
|
||
if(networkstatus === 'none'){
|
||
wx.showToast({
|
||
title: '请检查您的网络',
|
||
icon: 'error'
|
||
})
|
||
return
|
||
}
|
||
if(from){
|
||
await this.handlegetLastInquiry();
|
||
};
|
||
wx.aegis.reportEvent({
|
||
name: 'messageType',
|
||
ext1: 'messageType-text',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
let _this = this;
|
||
let conversationID = this.data.conversation.conversationID
|
||
let promise = wx.$TUIKit.getConversationProfile(conversationID);
|
||
promise.then(function(imResponse) {
|
||
// console.log("getConversationProfile 正在执行")
|
||
// 获取成功
|
||
// console.log(imResponse.data.conversation); // 会话资料
|
||
_this.setData({
|
||
conversation: imResponse.data.conversation
|
||
})
|
||
}).catch(function(imError) {
|
||
console.warn('getConversationProfile error:', imError); // 获取会话资料失败的相关信息
|
||
});
|
||
|
||
Promise.all([promise]).then(res => {
|
||
// console.log("getConversationProfile 执行完毕")
|
||
//获取最后一条消息
|
||
let last_message = this.data.conversation.lastMessage;
|
||
// console.log("last_message: ", last_message);
|
||
let cloudCustomData = "";
|
||
let cloudCustomDataJson = "";
|
||
if(last_message.cloudCustomData){
|
||
cloudCustomData = last_message.cloudCustomData;
|
||
}
|
||
if(cloudCustomData){
|
||
cloudCustomDataJson = JSON.parse(cloudCustomData);
|
||
}
|
||
let message_rounds = 0;
|
||
let patient_family_data = {};
|
||
patient_family_data.patient_name = this.data.baseInfo.patient_family_name;
|
||
patient_family_data.patient_sex = this.data.baseInfo.patient_family_sex;
|
||
patient_family_data.patient_age = this.data.baseInfo.patient_family_age;
|
||
if(cloudCustomDataJson){
|
||
message_rounds = cloudCustomDataJson.message_rounds;
|
||
}
|
||
|
||
let cach_message_rounds = this.data.message_rounds
|
||
message_rounds = cach_message_rounds>message_rounds?cach_message_rounds:message_rounds
|
||
|
||
const to = this.getToAccount();
|
||
const text = flag ? msg : this.data.message;
|
||
let {serviceInfo}=this.data;
|
||
const { FEAT_NATIVE_CODE } = constant;
|
||
const mycloudCustomData = JSON.stringify({
|
||
order_inquiry_id: this.data.order_inquiry_id,
|
||
inquiry_type: this.data.inquiry_type,
|
||
inquiry_mode:this.data.baseInfo.inquiry_mode,
|
||
message_type: 0,
|
||
is_system: 0,
|
||
message_rounds: message_rounds,
|
||
remaining_month_inquiry_count:serviceInfo.remaining_month_inquiry_count,
|
||
month_inquiry_count:serviceInfo.month_inquiry_count,
|
||
service_package_start_time:serviceInfo.start_time,
|
||
service_package_finish_time:serviceInfo.finish_time,
|
||
service_period:serviceInfo.service_period,
|
||
remaining_quantity:serviceInfo.remaining_quantity,
|
||
monthly_frequency:serviceInfo.monthly_frequency,
|
||
patient_family_data: patient_family_data
|
||
});
|
||
|
||
// console.log("mycloudCustomData: ", mycloudCustomData);
|
||
// console.log("text: ", text);
|
||
const message = wx.$TUIKit.createTextMessage({
|
||
to,
|
||
conversationType: this.data.conversation.type,
|
||
payload: {
|
||
text,
|
||
},
|
||
cloudCustomData: mycloudCustomData
|
||
});
|
||
this.setData({
|
||
message: '',
|
||
sendMessageBtn: false,
|
||
});
|
||
this.$sendTIMMessage(message);
|
||
})
|
||
},
|
||
|
||
// 监听输入框value值变化
|
||
onInputValueChange(event) {
|
||
if (event.detail.message || event.detail.value) {
|
||
this.setData({
|
||
message: event.detail.message || event.detail.value,
|
||
sendMessageBtn: true,
|
||
});
|
||
} else {
|
||
this.setData({
|
||
sendMessageBtn: false,
|
||
});
|
||
}
|
||
// event.detail.value && this.sendTypingStatusMessage();
|
||
},
|
||
|
||
// 发送正在输入状态消息
|
||
sendTypingStatusMessage() {
|
||
|
||
const { BUSINESS_ID_TEXT, FEAT_NATIVE_CODE } = constant;
|
||
// 创建正在输入状态消息, "typingStatus":1,正在输入中1, 输入结束0, "version": 1 兼容老版本,userAction:0, // 14表示正在输入,actionParam:"EIMAMSG_InputStatus_Ing" //"EIMAMSG_InputStatus_Ing" 表示正在输入, "EIMAMSG_InputStatus_End" 表示输入结束
|
||
const typingMessage = wx.$TUIKit.createCustomMessage({
|
||
to: this.getToAccount(),
|
||
conversationType: this.data.conversation.type,
|
||
payload: {
|
||
data: JSON.stringify({
|
||
businessID: BUSINESS_ID_TEXT.USER_TYPING,
|
||
typingStatus: FEAT_NATIVE_CODE.ISTYPING_STATUS,
|
||
version: FEAT_NATIVE_CODE.NATIVE_VERSION,
|
||
userAction: FEAT_NATIVE_CODE.ISTYPING_ACTION,
|
||
actionParam: constant.TYPE_INPUT_STATUS_ING,
|
||
}),
|
||
description: '',
|
||
extension: '',
|
||
},
|
||
cloudCustomData: JSON.stringify({
|
||
messageFeature: {
|
||
needTyping: FEAT_NATIVE_CODE.FEAT_TYPING,
|
||
version: FEAT_NATIVE_CODE.NATIVE_VERSION,
|
||
},
|
||
}),
|
||
});
|
||
// 在消息列表中过滤出对方的消息,并且获取最新消息的时间。
|
||
const inList = this.data.messageList.filter(item => item.flow === 'in');
|
||
if (inList.length === 0) return;
|
||
const sortList = inList.sort((firstItem, secondItem) => secondItem.time - firstItem.time);
|
||
const newMessageTime = sortList[0].time * 1000;
|
||
// 发送正在输入状态消息的触发条件。
|
||
const isSendTypingMessage = this.data.messageList.every((item) => {
|
||
try {
|
||
const sendTypingMessage = JSON.parse(item.cloudCustomData);
|
||
return sendTypingMessage.messageFeature.needTyping;
|
||
} catch (error) {
|
||
return false;
|
||
}
|
||
});
|
||
// 获取当前编辑时间,与收到对方最新的一条消息时间相比,时间小于30s则发送正在输入状态消息/
|
||
const now = new Date().getTime();
|
||
const timeDifference = (now - newMessageTime);
|
||
|
||
if (isSendTypingMessage && timeDifference > (1000 * 30)) return;
|
||
if (this.data.isFirstSendTyping) {
|
||
this.$sendTypingMessage(typingMessage);
|
||
this.setData({
|
||
isFirstSendTyping: false,
|
||
});
|
||
} else {
|
||
this.data.time = setTimeout(() => {
|
||
this.$sendTypingMessage(typingMessage);
|
||
}, (1000 * 4));
|
||
}
|
||
},
|
||
// 监听是否获取焦点,有焦点则向父级传值,动态改变input组件的高度。
|
||
inputBindFocus(event) {
|
||
this.setData({
|
||
focus: true,
|
||
});
|
||
// this.getMessageList(this.data.conversation);
|
||
this.triggerEvent('pullKeysBoards', {
|
||
event,
|
||
});
|
||
// 有焦点则关闭除键盘之外的操作界面,例如表情组件。
|
||
this.handleClose();
|
||
},
|
||
|
||
// 监听是否失去焦点
|
||
inputBindBlur(event) {
|
||
const { BUSINESS_ID_TEXT, FEAT_NATIVE_CODE } = constant;
|
||
const typingMessage = wx.$TUIKit.createCustomMessage({
|
||
to: this.getToAccount(),
|
||
conversationType: this.data.conversation.type,
|
||
payload: {
|
||
data: JSON.stringify({
|
||
businessID: BUSINESS_ID_TEXT.USER_TYPING,
|
||
typingStatus: FEAT_NATIVE_CODE.NOTTYPING_STATUS,
|
||
version: FEAT_NATIVE_CODE.NATIVE_VERSION,
|
||
userAction: FEAT_NATIVE_CODE.NOTTYPING_ACTION,
|
||
actionParam: constant.TYPE_INPUT_STATUS_END,
|
||
}),
|
||
cloudCustomData: JSON.stringify({ messageFeature:
|
||
{
|
||
needTyping: FEAT_NATIVE_CODE.FEAT_TYPING,
|
||
version: FEAT_NATIVE_CODE.NATIVE_VERSION,
|
||
},
|
||
}),
|
||
description: '',
|
||
extension: '',
|
||
},
|
||
});
|
||
this.$sendTypingMessage(typingMessage);
|
||
this.setData({
|
||
isFirstSendTyping: true,
|
||
});
|
||
clearTimeout(this.data.time);
|
||
this.triggerEvent('downKeysBoards', {
|
||
event,
|
||
});
|
||
},
|
||
inputBindLinechange(event){
|
||
this.triggerEvent('inputBindLinechange', {
|
||
event,
|
||
});
|
||
},
|
||
$handleSendTextMessage(event) {
|
||
this.sendTextMessage(event.detail.message, true);
|
||
this.setData({
|
||
displayCommonWords: false,
|
||
});
|
||
},
|
||
|
||
$handleSendCustomMessage(e) {
|
||
wx.aegis.reportEvent({
|
||
name: 'messageType',
|
||
ext1: 'messageType-custom',
|
||
ext2: wx.$chat_reportType,
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
let {baseInfo}=this.data;
|
||
const message = wx.$TUIKit.createCustomMessage({
|
||
to: this.getToAccount(),
|
||
conversationType: this.data.conversation.type,
|
||
payload: e.detail.payload,
|
||
cloudCustomData:JSON.stringify({
|
||
order_inquiry_id:baseInfo.order_inquiry_id,
|
||
inquiry_type: baseInfo.inquiry_type,
|
||
inquiry_mode:baseInfo.baseInfo.inquiry_mode,
|
||
message_type: 0,
|
||
is_system: 0,
|
||
message_rounds:0,
|
||
patient_family_data: baseInfo.patient_family_data
|
||
})
|
||
});
|
||
this.$sendTIMMessage(message);
|
||
this.setData({
|
||
displayOrderList: false,
|
||
displayCommonWords: false,
|
||
});
|
||
},
|
||
|
||
$handleCloseCards(e) {
|
||
switch (e.detail.key) {
|
||
case '0':
|
||
this.setData({
|
||
displayCommonWords: false,
|
||
});
|
||
break;
|
||
case '1':
|
||
this.setData({
|
||
displayOrderList: false,
|
||
});
|
||
break;
|
||
case '2':
|
||
this.setData({
|
||
displayServiceEvaluation: false,
|
||
});
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
},
|
||
// 发送正在输入消息
|
||
$sendTypingMessage(message) {
|
||
// wx.$TUIKit.sendMessage(message, {
|
||
// onlineUserOnly: true,
|
||
// });
|
||
},
|
||
|
||
$sendTIMMessage(message) {
|
||
console.log("$sendTIMMessage: ",message)
|
||
let networkstatus = this.data.networkstatus
|
||
if(networkstatus === 'none'){
|
||
wx.showToast({
|
||
title: '请检查您的网络',
|
||
icon: 'error'
|
||
})
|
||
return
|
||
}
|
||
this.triggerEvent('sendMessage', {
|
||
message,
|
||
});
|
||
wx.$TUIKit.sendMessage(message, {
|
||
offlinePushInfo: {
|
||
disablePush: true,
|
||
},
|
||
}).then((res) => {
|
||
|
||
console.log("sendMessage:", res)
|
||
if(res.code === 0){
|
||
this.triggerEvent('refreshMessageStatus', {
|
||
message,
|
||
});
|
||
}
|
||
const firstSendMessage = wx.getStorageSync('isFirstSendMessage');
|
||
if (firstSendMessage) {
|
||
wx.aegis.reportEvent({
|
||
name: 'sendMessage',
|
||
ext1: 'sendMessage-success',
|
||
ext2: 'imTuikitExternal',
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
}
|
||
}).catch((error) => {
|
||
logger.log(`| TUI-chat | message-input | sendMessageError: ${error.code} `);
|
||
wx.aegis.reportEvent({
|
||
name: 'sendMessage',
|
||
ext1: `sendMessage-failed#error: ${error}`,
|
||
ext2: 'imTuikitExternal',
|
||
ext3: wx.$chat_SDKAppID,
|
||
});
|
||
this.triggerEvent('showMessageErrorImage', {
|
||
showErrorImageFlag: error.code,
|
||
message,
|
||
});
|
||
});
|
||
this.setData({
|
||
displayFlag: '',
|
||
});
|
||
},
|
||
|
||
handleClose() {
|
||
this.setData({
|
||
displayFlag: '',
|
||
my_focus: false
|
||
});
|
||
},
|
||
|
||
handleServiceEvaluation() {
|
||
this.setData({
|
||
displayServiceEvaluation: true,
|
||
});
|
||
},
|
||
//常用语
|
||
showChangYongYu(){
|
||
app.go("/user/pages/yishi/quickreply/index?from=chat")
|
||
},
|
||
showWenZhenBiao(){
|
||
app.go("/user/pages/yishi/write_sickform/index?order_inquiry_id="+this.data.order_inquiry_id)
|
||
},
|
||
showSendTalk(){
|
||
let {baseInfo,message_rounds}=this.data;
|
||
// console.log(message_rounds);
|
||
// console.log(baseInfo.inquiry_status);
|
||
if(baseInfo.inquiry_status==6 || baseInfo.inquiry_status==5){
|
||
this.setData({
|
||
showTalk:true
|
||
})
|
||
}else{
|
||
wx.showToast({
|
||
title: '结束问诊或患者回合沟通数为0后才可赠送患者沟通回合数',
|
||
icon:'none',
|
||
})
|
||
}
|
||
|
||
}
|
||
|
||
},
|
||
});
|