xg
This commit is contained in:
parent
85214ad636
commit
6f24cb91f7
@ -163,6 +163,7 @@
|
||||
scrollTop: 999999,
|
||||
inputboxtop: undefined,
|
||||
bottomVal: 0,
|
||||
automaticreplylist: [],
|
||||
};
|
||||
},
|
||||
onReady() { //更改导航栏文字
|
||||
@ -191,7 +192,6 @@
|
||||
// })
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['scoket']),
|
||||
messagescoket() {
|
||||
const that = this
|
||||
// this.SOCKETURL = socketurl + this.currentItem.patientId
|
||||
@ -371,7 +371,6 @@
|
||||
let query = uni.createSelectorQuery().in(this);
|
||||
//需要给黄色区域设置一个id标识,在这里是demo
|
||||
query.select('.input-box').boundingClientRect(data => {
|
||||
console.log(data)
|
||||
this.inputboxtop = data.height //赋值,待会要用
|
||||
setTimeout(() => {
|
||||
this.scrollTop = this.scrollTop + 1;
|
||||
@ -379,14 +378,141 @@
|
||||
}).exec();
|
||||
}, 300)
|
||||
},
|
||||
...mapMutations(['scoket']),
|
||||
//自动回复
|
||||
automaticreply() {
|
||||
const that = this
|
||||
let currentDate = new Date();
|
||||
let year = currentDate.getFullYear();
|
||||
let month = currentDate.getMonth() + 1;
|
||||
let day = currentDate.getDate();
|
||||
month >= 1 && month <= 9 ? (month = "0" + month) : "";
|
||||
day >= 0 && day <= 9 ? (day = "0" + day) : "";
|
||||
let time = `${year}-${month}-${day}`
|
||||
if (uni.getStorageSync('automaticreplylist') && uni.getStorageSync('automaticreplylist').length > 0) {
|
||||
if (uni.getStorageSync('automaticreplylist')[0].sendtime != time) {
|
||||
uni.removeStorageSync('automaticreplylist');
|
||||
} else {
|
||||
this.automaticreplylist = uni.getStorageSync('automaticreplylist')
|
||||
if (this.automaticreplylist.some(e => e.doctorId == this.currentItem.doctorId)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
let obj = {
|
||||
consultationId: that.currentItem.id,
|
||||
recipientId: that.currentItem.patientId,
|
||||
recipientName: that.currentItem.patientName,
|
||||
senderId: that.currentItem.doctorId,
|
||||
senderName: that.currentItem.doctorName,
|
||||
messageType: 1,
|
||||
sendTime: new Date(),
|
||||
content: '请输入您要询问的问题,咨询人数较多时,可能无法快速回复,请谅解!',
|
||||
sourcePlatform: 'APPLET',
|
||||
autoResponder: 'AUTORESPONDER'
|
||||
}
|
||||
sendMessage(obj).then(res => {
|
||||
if (res.code == 200) {
|
||||
that.newsList.push({
|
||||
senderName: that.currentItem.doctorName,
|
||||
content: '请输入您要询问的问题,咨询人数较多时,可能无法快速回复,请谅解!',
|
||||
messageType: 1,
|
||||
})
|
||||
setTimeout(() => {
|
||||
that.scrollTop = that.scrollTop + 1;
|
||||
}, 100)
|
||||
let automaticreplyitem = {
|
||||
sendtime: time,
|
||||
doctorId: that.currentItem.doctorId
|
||||
}
|
||||
that.automaticreplylist.unshift(automaticreplyitem)
|
||||
uni.setStorageSync('automaticreplylist', that.automaticreplylist);
|
||||
}
|
||||
})
|
||||
},
|
||||
//发送图片
|
||||
chooseImage(sourceType) {
|
||||
var that = this
|
||||
if (this.$store.state.socketOpen == false) {
|
||||
this.$refs.uToast.show({
|
||||
title: '聊天连接异常,正在重连',
|
||||
type: 'warning',
|
||||
})
|
||||
this.scoket()
|
||||
return
|
||||
}
|
||||
uni.chooseImage({
|
||||
sourceType,
|
||||
sizeType: ["compressed"],
|
||||
success: (res) => {
|
||||
that.showFunBtn = false;
|
||||
res.tempFilePaths.forEach(e => {
|
||||
uni.uploadFile({
|
||||
url: baseurl +
|
||||
'/nurseApplet/consultationInfo/uploadConsultationFile',
|
||||
filePath: e,
|
||||
name: 'file',
|
||||
timeout: 5000,
|
||||
success(resp) {
|
||||
var fileurls = JSON.parse(resp.data)
|
||||
let obj = {
|
||||
consultationId: that.currentItem.id,
|
||||
senderId: that.currentItem.patientId,
|
||||
senderName: that.currentItem.patientName,
|
||||
recipientId: that.currentItem.doctorId,
|
||||
recipientName: that.currentItem.doctorName,
|
||||
messageType: 2,
|
||||
sendTime: new Date(),
|
||||
content: fileurls.fileUrl,
|
||||
sourcePlatform: 'APPLET'
|
||||
}
|
||||
sendMessage(obj).then(respp => {
|
||||
if (respp.code == 200) {
|
||||
that.newsList.push({
|
||||
content: fileurls.fileUrl,
|
||||
messageType: 2,
|
||||
senderName: that.currentItem
|
||||
.patientName,
|
||||
})
|
||||
setTimeout(() => {
|
||||
let query = uni
|
||||
.createSelectorQuery().in(
|
||||
that);
|
||||
//需要给黄色区域设置一个id标识,在这里是demo
|
||||
query.select('.input-box')
|
||||
.boundingClientRect(
|
||||
data => {
|
||||
that.inputboxtop =
|
||||
data
|
||||
.height //赋值,待会要用
|
||||
setTimeout(() => {
|
||||
that.scrollTop =
|
||||
that
|
||||
.scrollTop +
|
||||
1;
|
||||
}, 200)
|
||||
}).exec();
|
||||
}, 300)
|
||||
setTimeout(() => {
|
||||
this.automaticreply()
|
||||
}, 1000)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
});
|
||||
},
|
||||
sendout() {
|
||||
const that = this
|
||||
var content = JSON.parse(JSON.stringify(that.formData.content))
|
||||
if (this.$store.state.socketOpen == false) {
|
||||
this.$refs.uToast.show({
|
||||
title: '聊天连接异常',
|
||||
title: '聊天连接异常,正在重连',
|
||||
type: 'warning',
|
||||
})
|
||||
this.scoket();
|
||||
return
|
||||
}
|
||||
let obj = {
|
||||
@ -397,7 +523,8 @@
|
||||
recipientName: that.currentItem.doctorName,
|
||||
messageType: 1,
|
||||
sendTime: new Date(),
|
||||
content: that.formData.content
|
||||
content: that.formData.content,
|
||||
sourcePlatform: 'APPLET'
|
||||
}
|
||||
that.formData.content = '' //清空输入框的文本
|
||||
sendMessage(obj).then(res => {
|
||||
@ -410,6 +537,9 @@
|
||||
setTimeout(() => {
|
||||
that.scrollTop = that.scrollTop + 1;
|
||||
}, 100)
|
||||
setTimeout(() => {
|
||||
this.automaticreply()
|
||||
}, 1000)
|
||||
}
|
||||
})
|
||||
// try {
|
||||
@ -516,75 +646,6 @@
|
||||
});
|
||||
}
|
||||
},
|
||||
//发送图片
|
||||
chooseImage(sourceType) {
|
||||
var that = this
|
||||
if (this.$store.state.socketOpen == false) {
|
||||
this.$refs.uToast.show({
|
||||
title: '聊天连接异常',
|
||||
type: 'warning',
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.chooseImage({
|
||||
sourceType,
|
||||
sizeType: ["compressed"],
|
||||
success: (res) => {
|
||||
that.showFunBtn = false;
|
||||
res.tempFilePaths.forEach(e => {
|
||||
uni.uploadFile({
|
||||
url: baseurl +
|
||||
'/nurseApplet/consultationInfo/uploadConsultationFile',
|
||||
filePath: e,
|
||||
name: 'file',
|
||||
timeout: 5000,
|
||||
success(resp) {
|
||||
var fileurls = JSON.parse(resp.data)
|
||||
let obj = {
|
||||
consultationId: that.currentItem.id,
|
||||
senderId: that.currentItem.patientId,
|
||||
senderName: that.currentItem.patientName,
|
||||
recipientId: that.currentItem.doctorId,
|
||||
recipientName: that.currentItem.doctorName,
|
||||
messageType: 2,
|
||||
sendTime: new Date(),
|
||||
content: fileurls.fileUrl
|
||||
}
|
||||
sendMessage(obj).then(respp => {
|
||||
if (respp.code == 200) {
|
||||
that.newsList.push({
|
||||
content: fileurls.fileUrl,
|
||||
messageType: 2,
|
||||
senderName: that.currentItem
|
||||
.patientName,
|
||||
})
|
||||
setTimeout(() => {
|
||||
let query = uni
|
||||
.createSelectorQuery().in(
|
||||
that);
|
||||
//需要给黄色区域设置一个id标识,在这里是demo
|
||||
query.select('.input-box')
|
||||
.boundingClientRect(
|
||||
data => {
|
||||
that.inputboxtop =
|
||||
data
|
||||
.height //赋值,待会要用
|
||||
setTimeout(() => {
|
||||
that.scrollTop =
|
||||
that
|
||||
.scrollTop +
|
||||
1;
|
||||
}, 200)
|
||||
}).exec();
|
||||
}, 300)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
});
|
||||
},
|
||||
//用户触摸屏幕的时候隐藏键盘
|
||||
touchstart() {
|
||||
uni.hideKeyboard();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user