优化
This commit is contained in:
@@ -247,6 +247,7 @@ Component({
|
||||
ext2: wx.$chat_reportType,
|
||||
ext3: wx.$chat_SDKAppID,
|
||||
});
|
||||
|
||||
let targetFlag = 'extension';
|
||||
if (this.data.displayFlag === 'extension') {
|
||||
targetFlag = '';
|
||||
@@ -305,47 +306,63 @@ Component({
|
||||
// 发送图片消息
|
||||
handleSendImageMessage(file) {
|
||||
|
||||
// 获取最后一条消息
|
||||
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 _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); // 获取会话资料失败的相关信息
|
||||
});
|
||||
|
||||
const mycloudCustomData = JSON.stringify({
|
||||
order_inquiry_id: this.data.order_inquiry_id,
|
||||
inquiry_type: this.data.inquiry_type,
|
||||
message_type: 0,
|
||||
is_system: 0,
|
||||
message_rounds: message_rounds,
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
const mycloudCustomData = JSON.stringify({
|
||||
order_inquiry_id: this.data.order_inquiry_id,
|
||||
inquiry_type: this.data.inquiry_type,
|
||||
message_type: 0,
|
||||
is_system: 0,
|
||||
message_rounds: message_rounds,
|
||||
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);
|
||||
})
|
||||
},
|
||||
|
||||
// 发送视频消息
|
||||
@@ -562,55 +579,71 @@ Component({
|
||||
ext2: wx.$chat_reportType,
|
||||
ext3: wx.$chat_SDKAppID,
|
||||
});
|
||||
|
||||
//获取最后一条消息
|
||||
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;
|
||||
}
|
||||
|
||||
const to = this.getToAccount();
|
||||
const text = flag ? msg : this.data.message;
|
||||
|
||||
const { FEAT_NATIVE_CODE } = constant;
|
||||
const mycloudCustomData = JSON.stringify({
|
||||
order_inquiry_id: this.data.order_inquiry_id,
|
||||
inquiry_type: this.data.inquiry_type,
|
||||
message_type: 0,
|
||||
is_system: 0,
|
||||
message_rounds: message_rounds,
|
||||
patient_family_data: patient_family_data
|
||||
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); // 获取会话资料失败的相关信息
|
||||
});
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
const to = this.getToAccount();
|
||||
const text = flag ? msg : this.data.message;
|
||||
|
||||
const { FEAT_NATIVE_CODE } = constant;
|
||||
const mycloudCustomData = JSON.stringify({
|
||||
order_inquiry_id: this.data.order_inquiry_id,
|
||||
inquiry_type: this.data.inquiry_type,
|
||||
message_type: 0,
|
||||
is_system: 0,
|
||||
message_rounds: message_rounds,
|
||||
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值变化
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<image class="TUI-icon" bindtap="switchAudio" wx:if="{{has_audio}}"
|
||||
src="{{isAudio ? '../../../../static/assets/keyboard.svg' : '../../../../static/assets/audio.svg'}}" />
|
||||
<view wx:if="{{!isAudio || isEmoji}}" class="TUI-message-input-main {{ focus && 'TUI-message-input-main-focus'}}" >
|
||||
<textarea class="TUI-message-input-area" adjust-position="{{false}}" cursor-spacing="20"
|
||||
<textarea id="mytextarea" class="TUI-message-input-area" adjust-position="{{false}}" cursor-spacing="20"
|
||||
value="{{message}}" bindinput="onInputValueChange" maxlength="-1" type="text" auto-height="{{true}}"
|
||||
placeholder="请输入文字" placeholder-class="input-placeholder" confirm-type="send" show-confirm-bar="{{false}}"
|
||||
bindfocus="inputBindFocus"
|
||||
|
||||
@@ -342,7 +342,11 @@ Component({
|
||||
|
||||
let jumpAim = `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - 1].ID)}`;
|
||||
console.log("jumpAim:", jumpAim);
|
||||
if(autoToButtom){
|
||||
|
||||
console.log("message.from: ", message.from)
|
||||
console.log("conversation: ", this.data.conversation)
|
||||
console.log("conversation: ", this.data.conversation.lastMessage.from)
|
||||
if(autoToButtom && message.conversationID === this.data.conversation.conversationID){
|
||||
this.setData({
|
||||
jumpAim: jumpAim
|
||||
})
|
||||
|
||||
@@ -131,7 +131,7 @@ Component({
|
||||
},
|
||||
navbar_height: 0,
|
||||
dialog_visible: false,
|
||||
|
||||
KeysBoardsStatus: "down"
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -275,39 +275,48 @@ Component({
|
||||
myhandleExtensions(e){
|
||||
console.log("myhandleExtensionsmyhandleExtensions: ", e);
|
||||
let displayFlag = e.detail.displayFlag;
|
||||
if(displayFlag){
|
||||
this.setData({
|
||||
input_area_style: "position: absolute; bottom: 30px;"
|
||||
})
|
||||
this.getNavbarHeight(100);
|
||||
this.selectComponent('#MessageList').handleJumpNewMessage();
|
||||
}else{
|
||||
this.setData({
|
||||
input_area_style: "",
|
||||
})
|
||||
this.getNavbarHeight();
|
||||
}
|
||||
setTimeout(() => {
|
||||
if(displayFlag){
|
||||
this.setData({
|
||||
input_area_style: "position: absolute; bottom: 30px;"
|
||||
})
|
||||
this.getNavbarHeight(100);
|
||||
this.selectComponent('#MessageList').handleJumpNewMessage();
|
||||
}else{
|
||||
this.setData({
|
||||
input_area_style: "",
|
||||
})
|
||||
this.getNavbarHeight();
|
||||
}
|
||||
|
||||
}, 10);
|
||||
},
|
||||
// 监听键盘,获取焦点时将输入框推到键盘上方
|
||||
pullKeysBoards(event) {
|
||||
console.log("pullKeysBoardspullKeysBoards")
|
||||
setNewInputStyle(event.detail.event.detail.height);
|
||||
this.getNavbarHeight();
|
||||
this.setData({
|
||||
'viewData.style': newInputStyle,
|
||||
input_area_style: "position: absolute; bottom: 45rpx;"
|
||||
input_area_style: "position: absolute; bottom: 45rpx;",
|
||||
KeysBoardsStatus: "pull"
|
||||
});
|
||||
},
|
||||
// 监听键盘,失去焦点时收起键盘
|
||||
downKeysBoards(event) {
|
||||
console.log("downKeysBoardsdownKeysBoards")
|
||||
console.log(event)
|
||||
let value = event.detail.event.detail.value;
|
||||
if(value){
|
||||
this.setData({
|
||||
'viewData.style': inputStyle,
|
||||
KeysBoardsStatus: "down"
|
||||
});
|
||||
}else{
|
||||
this.setData({
|
||||
'viewData.style': inputStyle,
|
||||
input_area_style: ""
|
||||
input_area_style: "",
|
||||
KeysBoardsStatus: "down"
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user