修改
This commit is contained in:
parent
07e186c794
commit
31887d0eee
@ -3,7 +3,7 @@ import request from "@/api/request.js"
|
||||
// 发送即使消息
|
||||
export function sendMessage(data) {
|
||||
return request({
|
||||
url: `/jn/fm/message/send`,
|
||||
url: `/nurseApplet/chatRecord/sendMessage`,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
@ -11,9 +11,9 @@ export function sendMessage(data) {
|
||||
|
||||
|
||||
// 查询聊天记录
|
||||
export function getChatHistory(data) {
|
||||
export function getChatRecord(data) {
|
||||
return request({
|
||||
url: `/jn/fm/message/getChatList`,
|
||||
url: `/nurseApplet/chatRecord/getChatRecord`,
|
||||
method: 'get',
|
||||
data: data
|
||||
})
|
||||
@ -22,8 +22,8 @@ export function getChatHistory(data) {
|
||||
// 标记为已读
|
||||
export function markRead(data) {
|
||||
return request({
|
||||
url: `/jn/fm/message/markRead`,
|
||||
method: 'get',
|
||||
url: `/nurseApplet/chatRecord/updateReadStatus`,
|
||||
method: 'PUT',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
@ -4,20 +4,28 @@
|
||||
<view class="title">
|
||||
<view class="text" v-for='(item,index) in titlelist' :key='index'
|
||||
:class="formdata.status==item.status?'Selectedtext':''" @tap='selecttitltext(item)'>
|
||||
{{item.text}}
|
||||
<!-- <view class="topright" v-if="index==0">
|
||||
{{listinfo?listinfo.length:''}}
|
||||
</view> -->
|
||||
<view class="">
|
||||
{{item.text}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="list">
|
||||
<view class="item" v-for='item in listinfo' :key="item.id">
|
||||
<view class="item" v-for='item in listinfo' :key="item.id" @tap='goseekadvicefrom(item)'>
|
||||
<view class="time">
|
||||
2023-12-12 12:12
|
||||
{{item.createTime?item.createTime:''}}
|
||||
</view>
|
||||
<image src="../../static/pagesB/Behave.png" mode=""></image>
|
||||
<view class="name">
|
||||
张三
|
||||
{{item.doctorName?item.doctorName:''}}
|
||||
</view>
|
||||
<view class="text">
|
||||
你好,请问今天下午方便吗
|
||||
{{item.problemDescription?item.problemDescription:''}}
|
||||
</view>
|
||||
<view class="messageCount" v-if="item.messageCount>0">
|
||||
{{item.messageCount}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -76,6 +84,12 @@
|
||||
url: "/pagesB/createnewconsultation/createnewconsultation"
|
||||
})
|
||||
},
|
||||
//前往聊天
|
||||
goseekadvicefrom(item) {
|
||||
uni.navigateTo({
|
||||
url: `/pagesC/seekadvicefrom/seekadvicefrom?item=${JSON.stringify(item)}`
|
||||
})
|
||||
},
|
||||
},
|
||||
onReachBottom() { //下滑加载
|
||||
if (this.listinfo.length >= this.listtotal) {} else {
|
||||
@ -89,7 +103,7 @@
|
||||
})
|
||||
}
|
||||
},
|
||||
onPullDownRefresh() { //下拉刷新
|
||||
onPullDownRefresh() { //上拉刷新
|
||||
this.formdata.pageNum = 1;
|
||||
this.info();
|
||||
setTimeout(function() {
|
||||
@ -123,6 +137,21 @@
|
||||
background: #F6F6F6;
|
||||
border-radius: 5rpx;
|
||||
|
||||
.messageCount {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 5%;
|
||||
width: 33rpx;
|
||||
height: 33rpx;
|
||||
background: #F44B2F;
|
||||
border-radius: 50%;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
color: #FFFFFF;
|
||||
line-height: 33rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.text {
|
||||
position: absolute;
|
||||
left: 190rpx;
|
||||
@ -187,6 +216,23 @@
|
||||
border-radius: 5rpx;
|
||||
width: 25%;
|
||||
color: #26A888;
|
||||
position: relative;
|
||||
|
||||
.topright {
|
||||
width: 33rpx;
|
||||
height: 33rpx;
|
||||
background: #FFA115;
|
||||
border-radius: 50%;
|
||||
text-align: center;
|
||||
line-height: 33rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
color: #FFFFFF;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
transform: translate(50%, -50%);
|
||||
}
|
||||
}
|
||||
|
||||
.Selectedtext {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<view class="userinfo">
|
||||
<view class="itemimgs">
|
||||
<image class="picture" :src="img" mode="" v-if="img" @tap='uploadImag'></image>
|
||||
<image class="picture" src="../../static/pagesB/userl.png" mode="" v-else @tap='uploadImag'></image>
|
||||
<image class="picture" src="../../static/headsculpture.png" mode="" v-else @tap='uploadImag'></image>
|
||||
<view class="text" @tap='uploadImag'>
|
||||
点击编辑头像
|
||||
</view>
|
||||
|
||||
@ -5,25 +5,28 @@
|
||||
{{currentItem.senderName}}
|
||||
</view> -->
|
||||
<!-- 聊天渲染列表 -->
|
||||
<!-- scroll-y scroll-into-view="placeholder" scroll-top="500" scroll-with-animation -->
|
||||
<view style="height: 85vh; padding-top: 200rpx;" @tap='touchend'>
|
||||
<view class="snedItem" v-for="(item, index) in newsList" :key="index">
|
||||
<view class="ifSend" v-if="item.senderName == userName">
|
||||
<view class="sendBox" v-if="item.content">{{item.content}}</view>
|
||||
<image class="head" src="../../static//myHead.png"></image>
|
||||
</view>
|
||||
<view class="doctorSend" v-else>
|
||||
<image class="head" src="../../static/docHead.png"></image>
|
||||
<view class="">
|
||||
<text>{{item.senderName}}</text>
|
||||
<!-- scroll-y scroll-into-view="placeholder" scroll-top="500" scroll-with-animation -->
|
||||
<scroll-view scroll-y="true" :scroll-top='scrollTop'>
|
||||
<view style="height: 85vh; padding-top: 200rpx;" @tap='touchend'>
|
||||
<view class="snedItem" v-for="(item, index) in newsList" :key="index">
|
||||
<view class="ifSend" v-if="item.senderName == userName">
|
||||
<view class="sendBox" v-if="item.content">{{item.content}}</view>
|
||||
<image class="head" src="@/static/headsculpture.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <image v-if="item.img" :src="item.img" mode="scaleToFill" class="touch-active" />
|
||||
<view class="doctorSend" v-else>
|
||||
<image class="head" src="@/static/docHead.png"></image>
|
||||
<view class="">
|
||||
<text>{{item.senderName}}</text>
|
||||
<view class="sendBox" v-if="item.content">{{item.content}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <image v-if="item.img" :src="item.img" mode="scaleToFill" class="touch-active" />
|
||||
<video v-if="item.video" :src="item.video"></video> -->
|
||||
</view>
|
||||
<view class="placeholder" id="placeholder" v-if="showFunBtn"></view>
|
||||
</view>
|
||||
<view class="placeholder" id="placeholder"></view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 底部输入 -->
|
||||
<view class="input-box" :class="{ 'input-box-mpInputMargin': mpInputMargin }">
|
||||
<view class="input-box-flex">
|
||||
@ -34,7 +37,7 @@
|
||||
v-model="formData.content" :hold-keyboard="true" :confirm-type="'send'" :confirm-hold="true"
|
||||
placeholder-style="color:#DDDDDD;" :cursor-spacing="10" /> </view>
|
||||
<!-- 选择表情包 -->
|
||||
<image class=" icon_btn_add" :src="require('@/static/ico/emoji.png')" @tap="exprec"></image>
|
||||
<!-- <image class=" icon_btn_add" :src="require('@/static/ico/emoji.png')" @tap="exprec"></image> -->
|
||||
<!-- 发送消息按钮 -->
|
||||
<image class=" icon_btn_add" :src="require('@/static/ico/send.png')" @tap="sendout"
|
||||
v-if="formData.content!==''" mode=""></image>
|
||||
@ -74,23 +77,20 @@
|
||||
<script>
|
||||
import {
|
||||
sendMessage,
|
||||
getChatHistory,
|
||||
getChatRecord,
|
||||
markRead
|
||||
} from '@/api/pagesC/seekadvicefrom/seekadvicefrom.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
title: '',
|
||||
SOCKETURL: 'wss://http://192.168.16.212/fm/webSocket/' + uni.getStorageSync('userInfo').bindingNo,
|
||||
// SOCKETURL: 'wss://fdmp.xinelu.cn/fm/webSocket/' + uni.getStorageSync('userInfo').bindingNo,
|
||||
SOCKETURL: 'ws://192.168.16.212:8088/webSocket/1',
|
||||
socketOpen: false,
|
||||
sendInfo: {},
|
||||
currentItem: '',
|
||||
userName: uni.getStorageSync('userInfo').residentName,
|
||||
imgUrl22: this.$imgUrl22,
|
||||
userName: '',
|
||||
mpInputMargin: true, //适配微信小程序 底部输入框高度被顶起的问题
|
||||
//发送的聊天消息
|
||||
text: '',
|
||||
formData: {
|
||||
content: "",
|
||||
limit: 15,
|
||||
@ -138,6 +138,7 @@
|
||||
title: "在吗",
|
||||
},
|
||||
],
|
||||
scrollTop: 999999,
|
||||
};
|
||||
},
|
||||
onReady() { //更改导航栏文字
|
||||
@ -146,48 +147,41 @@
|
||||
});
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.title) {
|
||||
this.title = options.title //导航栏标题
|
||||
}
|
||||
this.currentItem = {
|
||||
senderName: e.userName,
|
||||
senderNo: e.userNo,
|
||||
recipientName: uni.getStorageSync('userInfo').residentName,
|
||||
recipientNo: uni.getStorageSync('userInfo').bindingNo,
|
||||
// messageCategory: '3'
|
||||
}
|
||||
// this.currentItem = JSON.parse(options.currentItem)
|
||||
// uni.closeSocket()
|
||||
this.currentItem = JSON.parse(options.item)
|
||||
this.title = this.currentItem.doctorName //导航栏标题
|
||||
this.userName = this.currentItem.patientName
|
||||
this.getPageHistory()
|
||||
this.scoket()
|
||||
},
|
||||
mounted() {
|
||||
wx.pageScrollTo({
|
||||
scrollTop: 9999999
|
||||
})
|
||||
// wx.pageScrollTo({
|
||||
// scrollTop: 9999999
|
||||
// })
|
||||
},
|
||||
methods: {
|
||||
getPageHistory() {
|
||||
let obj = {
|
||||
bindingNo: this.currentItem.recipientNo,
|
||||
// messageCategory: this.currentItem.messageCategory,
|
||||
recipientNo: this.currentItem.senderNo,
|
||||
senderNo: this.currentItem.recipientNo
|
||||
consultationId: this.currentItem.id,
|
||||
senderId: this.currentItem.patientId,
|
||||
recipientId: this.currentItem.doctorId,
|
||||
}
|
||||
getChatHistory(obj).then(res => {
|
||||
if (res.data.code == '1') {
|
||||
this.newsList = res.data.data
|
||||
if (this.currentItem.unreadCount == 0) {
|
||||
return
|
||||
getChatRecord(obj).then(res => {
|
||||
res.data.forEach(e => {
|
||||
if (e.readStatus == 0) {
|
||||
this.Read()
|
||||
}
|
||||
this.Read()
|
||||
}
|
||||
})
|
||||
this.newsList = res.data
|
||||
setTimeout(() => {
|
||||
this.scrollTop = this.scrollTop + 1;
|
||||
}, 100)
|
||||
})
|
||||
},
|
||||
Read() {
|
||||
let markReadData = {
|
||||
bindingNo: this.currentItem.recipientNo,
|
||||
// messageCategory: this.currentItem.messageCategory,
|
||||
senderNo: this.currentItem.senderNo
|
||||
consultationId: this.currentItem.id,
|
||||
recipientId: this.currentItem.doctorId,
|
||||
}
|
||||
markRead(markReadData)
|
||||
},
|
||||
@ -195,9 +189,14 @@
|
||||
this.showFunBtn = false; //隐藏功能
|
||||
this.showExpre = false; //隐藏表情
|
||||
this.showOften = false; //隐藏常用
|
||||
uni.hideKeyboard();
|
||||
},
|
||||
goshowFunBtn() {
|
||||
this.showFunBtn = true; //隐藏功能
|
||||
uni.hideKeyboard();
|
||||
setTimeout(() => {
|
||||
this.scrollTop = this.scrollTop + 1;
|
||||
}, 100)
|
||||
},
|
||||
sendout() {
|
||||
if (this.socketOpen == false) {
|
||||
@ -209,26 +208,33 @@
|
||||
})
|
||||
let message = this.formData.content
|
||||
try {
|
||||
const _this = this
|
||||
const that = this
|
||||
uni.sendSocketMessage({
|
||||
data: message,
|
||||
success(res) {
|
||||
console.log(that.currentItem)
|
||||
let obj = {
|
||||
content: message,
|
||||
recipientName: _this.currentItem.senderName,
|
||||
recipientNo: _this.currentItem.senderNo,
|
||||
senderName: _this.currentItem.recipientName,
|
||||
senderNo: _this.currentItem.recipientNo,
|
||||
messageType: '1'
|
||||
consultationId: that.currentItem.id,
|
||||
senderId: that.currentItem.patientId,
|
||||
senderName: that.currentItem.patientName,
|
||||
recipientId: that.currentItem.doctorId,
|
||||
recipientName: that.currentItem.doctorName,
|
||||
messageType: 1,
|
||||
sendTime: new Date(),
|
||||
// messageType: 消息类型(0: 其他 1: 文字, 2: 图片 3: 表情 4: 视频 5: 文件 6: 链接)
|
||||
content: message
|
||||
}
|
||||
sendMessage(obj).then(res => {
|
||||
console.log(res);
|
||||
setTimeout(() => {
|
||||
that.scrollTop = that.scrollTop + 1;
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e, '断线了')
|
||||
uni.closeSocket();
|
||||
// uni.closeSocket();
|
||||
}
|
||||
this.formData.content = '' //清空输入框的文本
|
||||
|
||||
@ -306,28 +312,26 @@
|
||||
touchstart() {
|
||||
uni.hideKeyboard();
|
||||
},
|
||||
|
||||
scoket() {
|
||||
const _this = this
|
||||
uni.closeSocket()
|
||||
const that = this
|
||||
this.socketOpen = false
|
||||
try {
|
||||
uni.connectSocket({
|
||||
url: _this.SOCKETURL
|
||||
url: that.SOCKETURL
|
||||
})
|
||||
uni.onSocketOpen(res => {
|
||||
console.log('webScoket连接已打开', res);
|
||||
_this.socketOpen = true
|
||||
_this.reset()
|
||||
that.socketOpen = true
|
||||
that.reset()
|
||||
})
|
||||
|
||||
uni.onSocketError(err => {
|
||||
console.log('webScoket连接打开失败', err);
|
||||
if (err && err.code != 1000) {
|
||||
setTimeout(() => {
|
||||
_this.socketOpen = true
|
||||
that.socketOpen = true
|
||||
uni.connectSocket({
|
||||
url: _this.SOCKETURL
|
||||
url: that.SOCKETURL
|
||||
})
|
||||
}, 3 * 1000)
|
||||
}
|
||||
@ -337,9 +341,9 @@
|
||||
console.log('webScoket连接关闭', err);
|
||||
if (err && err.code !== 1000) {
|
||||
setTimeout(() => {
|
||||
_this.socketOpen = true
|
||||
that.socketOpen = true
|
||||
uni.connectSocket({
|
||||
url: _this.SOCKETURL
|
||||
url: that.SOCKETURL
|
||||
})
|
||||
}, 3 * 1000)
|
||||
}
|
||||
@ -347,11 +351,11 @@
|
||||
|
||||
uni.onSocketMessage(res => {
|
||||
console.log("webScoket监听收到的信息", res);
|
||||
_this.newsList.push({
|
||||
senderName: _this.currentItem.senderName,
|
||||
that.newsList.push({
|
||||
senderName: that.currentItem.patientName,
|
||||
content: JSON.parse(res.data).message
|
||||
})
|
||||
_this.Read()
|
||||
that.Read()
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@ -359,9 +363,9 @@
|
||||
},
|
||||
// 心跳响应
|
||||
reset() {
|
||||
let _this = this
|
||||
clearInterval(_this.timeoutObj);
|
||||
_this.timeoutObj = setInterval(() => {
|
||||
let that = this
|
||||
clearInterval(that.timeoutObj);
|
||||
that.timeoutObj = setInterval(() => {
|
||||
uni.sendSocketMessage({
|
||||
data: 'ping',
|
||||
success(res) {
|
||||
@ -375,7 +379,7 @@
|
||||
})
|
||||
}
|
||||
})
|
||||
}, _this.timeout)
|
||||
}, that.timeout)
|
||||
},
|
||||
back() {
|
||||
uni.navigateBack({
|
||||
@ -465,8 +469,9 @@
|
||||
|
||||
.fun-box {
|
||||
opacity: 0;
|
||||
transition: all 0.1s ease-in-out;
|
||||
height: 0;
|
||||
transition: all 0.3s ease;
|
||||
transform: translateY(100%);
|
||||
|
||||
.grid-text {
|
||||
padding-top: 10rpx;
|
||||
@ -539,6 +544,8 @@
|
||||
.show-fun-box {
|
||||
opacity: 1;
|
||||
height: 300rpx;
|
||||
transition: all 0.3s ease;
|
||||
transform: translateY(0%) !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
Loading…
Reference in New Issue
Block a user