This commit is contained in:
2023-10-10 10:24:50 +08:00
parent 07e186c794
commit 31887d0eee
5 changed files with 141 additions and 88 deletions

View File

@ -3,7 +3,7 @@ import request from "@/api/request.js"
// 发送即使消息 // 发送即使消息
export function sendMessage(data) { export function sendMessage(data) {
return request({ return request({
url: `/jn/fm/message/send`, url: `/nurseApplet/chatRecord/sendMessage`,
method: 'post', method: 'post',
data: data data: data
}) })
@ -11,9 +11,9 @@ export function sendMessage(data) {
// 查询聊天记录 // 查询聊天记录
export function getChatHistory(data) { export function getChatRecord(data) {
return request({ return request({
url: `/jn/fm/message/getChatList`, url: `/nurseApplet/chatRecord/getChatRecord`,
method: 'get', method: 'get',
data: data data: data
}) })
@ -22,8 +22,8 @@ export function getChatHistory(data) {
// 标记为已读 // 标记为已读
export function markRead(data) { export function markRead(data) {
return request({ return request({
url: `/jn/fm/message/markRead`, url: `/nurseApplet/chatRecord/updateReadStatus`,
method: 'get', method: 'PUT',
data: data data: data
}) })
} }

View File

@ -4,20 +4,28 @@
<view class="title"> <view class="title">
<view class="text" v-for='(item,index) in titlelist' :key='index' <view class="text" v-for='(item,index) in titlelist' :key='index'
:class="formdata.status==item.status?'Selectedtext':''" @tap='selecttitltext(item)'> :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> </view>
<view class="list"> <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"> <view class="time">
2023-12-12 12:12 {{item.createTime?item.createTime:''}}
</view> </view>
<image src="../../static/pagesB/Behave.png" mode=""></image> <image src="../../static/pagesB/Behave.png" mode=""></image>
<view class="name"> <view class="name">
张三 {{item.doctorName?item.doctorName:''}}
</view> </view>
<view class="text"> <view class="text">
你好请问今天下午方便吗 {{item.problemDescription?item.problemDescription:''}}
</view>
<view class="messageCount" v-if="item.messageCount>0">
{{item.messageCount}}
</view> </view>
</view> </view>
</view> </view>
@ -76,6 +84,12 @@
url: "/pagesB/createnewconsultation/createnewconsultation" url: "/pagesB/createnewconsultation/createnewconsultation"
}) })
}, },
//
goseekadvicefrom(item) {
uni.navigateTo({
url: `/pagesC/seekadvicefrom/seekadvicefrom?item=${JSON.stringify(item)}`
})
},
}, },
onReachBottom() { // onReachBottom() { //
if (this.listinfo.length >= this.listtotal) {} else { if (this.listinfo.length >= this.listtotal) {} else {
@ -89,7 +103,7 @@
}) })
} }
}, },
onPullDownRefresh() { // onPullDownRefresh() { //
this.formdata.pageNum = 1; this.formdata.pageNum = 1;
this.info(); this.info();
setTimeout(function() { setTimeout(function() {
@ -123,6 +137,21 @@
background: #F6F6F6; background: #F6F6F6;
border-radius: 5rpx; 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 { .text {
position: absolute; position: absolute;
left: 190rpx; left: 190rpx;
@ -187,6 +216,23 @@
border-radius: 5rpx; border-radius: 5rpx;
width: 25%; width: 25%;
color: #26A888; 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 { .Selectedtext {

View File

@ -3,7 +3,7 @@
<view class="userinfo"> <view class="userinfo">
<view class="itemimgs"> <view class="itemimgs">
<image class="picture" :src="img" mode="" v-if="img" @tap='uploadImag'></image> <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 class="text" @tap='uploadImag'>
点击编辑头像 点击编辑头像
</view> </view>

View File

@ -5,25 +5,28 @@
{{currentItem.senderName}} {{currentItem.senderName}}
</view> --> </view> -->
<!-- 聊天渲染列表 --> <!-- 聊天渲染列表 -->
<!-- scroll-y scroll-into-view="placeholder" scroll-top="500" scroll-with-animation --> <!-- scroll-y scroll-into-view="placeholder" scroll-top="500" scroll-with-animation -->
<view style="height: 85vh; padding-top: 200rpx;" @tap='touchend'> <scroll-view scroll-y="true" :scroll-top='scrollTop'>
<view class="snedItem" v-for="(item, index) in newsList" :key="index"> <view style="height: 85vh; padding-top: 200rpx;" @tap='touchend'>
<view class="ifSend" v-if="item.senderName == userName"> <view class="snedItem" v-for="(item, index) in newsList" :key="index">
<view class="sendBox" v-if="item.content">{{item.content}}</view> <view class="ifSend" v-if="item.senderName == userName">
<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>
<view class="sendBox" v-if="item.content">{{item.content}}</view> <view class="sendBox" v-if="item.content">{{item.content}}</view>
<image class="head" src="@/static/headsculpture.png"></image>
</view> </view>
</view> <view class="doctorSend" v-else>
<!-- <image v-if="item.img" :src="item.img" mode="scaleToFill" class="touch-active" /> <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> --> <video v-if="item.video" :src="item.video"></video> -->
</view>
<view class="placeholder" id="placeholder" v-if="showFunBtn"></view>
</view> </view>
<view class="placeholder" id="placeholder"></view> </scroll-view>
</view>
<!-- 底部输入 --> <!-- 底部输入 -->
<view class="input-box" :class="{ 'input-box-mpInputMargin': mpInputMargin }"> <view class="input-box" :class="{ 'input-box-mpInputMargin': mpInputMargin }">
<view class="input-box-flex"> <view class="input-box-flex">
@ -34,7 +37,7 @@
v-model="formData.content" :hold-keyboard="true" :confirm-type="'send'" :confirm-hold="true" v-model="formData.content" :hold-keyboard="true" :confirm-type="'send'" :confirm-hold="true"
placeholder-style="color:#DDDDDD;" :cursor-spacing="10" /> </view> 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" <image class=" icon_btn_add" :src="require('@/static/ico/send.png')" @tap="sendout"
v-if="formData.content!==''" mode=""></image> v-if="formData.content!==''" mode=""></image>
@ -74,23 +77,20 @@
<script> <script>
import { import {
sendMessage, sendMessage,
getChatHistory, getChatRecord,
markRead markRead
} from '@/api/pagesC/seekadvicefrom/seekadvicefrom.js'; } from '@/api/pagesC/seekadvicefrom/seekadvicefrom.js';
export default { export default {
data() { data() {
return { return {
title: '', title: '',
SOCKETURL: 'wss://http://192.168.16.212/fm/webSocket/' + uni.getStorageSync('userInfo').bindingNo, SOCKETURL: 'ws://192.168.16.212:8088/webSocket/1',
// SOCKETURL: 'wss://fdmp.xinelu.cn/fm/webSocket/' + uni.getStorageSync('userInfo').bindingNo,
socketOpen: false, socketOpen: false,
sendInfo: {}, sendInfo: {},
currentItem: '', currentItem: '',
userName: uni.getStorageSync('userInfo').residentName, userName: '',
imgUrl22: this.$imgUrl22,
mpInputMargin: true, // mpInputMargin: true, //
// //
text: '',
formData: { formData: {
content: "", content: "",
limit: 15, limit: 15,
@ -138,6 +138,7 @@
title: "在吗", title: "在吗",
}, },
], ],
scrollTop: 999999,
}; };
}, },
onReady() { // onReady() { //
@ -146,48 +147,41 @@
}); });
}, },
onLoad(options) { onLoad(options) {
if (options.title) { // uni.closeSocket()
this.title = options.title // this.currentItem = JSON.parse(options.item)
} this.title = this.currentItem.doctorName //
this.currentItem = { this.userName = this.currentItem.patientName
senderName: e.userName,
senderNo: e.userNo,
recipientName: uni.getStorageSync('userInfo').residentName,
recipientNo: uni.getStorageSync('userInfo').bindingNo,
// messageCategory: '3'
}
// this.currentItem = JSON.parse(options.currentItem)
this.getPageHistory() this.getPageHistory()
this.scoket() this.scoket()
}, },
mounted() { mounted() {
wx.pageScrollTo({ // wx.pageScrollTo({
scrollTop: 9999999 // scrollTop: 9999999
}) // })
}, },
methods: { methods: {
getPageHistory() { getPageHistory() {
let obj = { let obj = {
bindingNo: this.currentItem.recipientNo, consultationId: this.currentItem.id,
// messageCategory: this.currentItem.messageCategory, senderId: this.currentItem.patientId,
recipientNo: this.currentItem.senderNo, recipientId: this.currentItem.doctorId,
senderNo: this.currentItem.recipientNo
} }
getChatHistory(obj).then(res => { getChatRecord(obj).then(res => {
if (res.data.code == '1') { res.data.forEach(e => {
this.newsList = res.data.data if (e.readStatus == 0) {
if (this.currentItem.unreadCount == 0) { this.Read()
return
} }
this.Read() })
} this.newsList = res.data
setTimeout(() => {
this.scrollTop = this.scrollTop + 1;
}, 100)
}) })
}, },
Read() { Read() {
let markReadData = { let markReadData = {
bindingNo: this.currentItem.recipientNo, consultationId: this.currentItem.id,
// messageCategory: this.currentItem.messageCategory, recipientId: this.currentItem.doctorId,
senderNo: this.currentItem.senderNo
} }
markRead(markReadData) markRead(markReadData)
}, },
@ -195,9 +189,14 @@
this.showFunBtn = false; // this.showFunBtn = false; //
this.showExpre = false; // this.showExpre = false; //
this.showOften = false; // this.showOften = false; //
uni.hideKeyboard();
}, },
goshowFunBtn() { goshowFunBtn() {
this.showFunBtn = true; // this.showFunBtn = true; //
uni.hideKeyboard();
setTimeout(() => {
this.scrollTop = this.scrollTop + 1;
}, 100)
}, },
sendout() { sendout() {
if (this.socketOpen == false) { if (this.socketOpen == false) {
@ -209,26 +208,33 @@
}) })
let message = this.formData.content let message = this.formData.content
try { try {
const _this = this const that = this
uni.sendSocketMessage({ uni.sendSocketMessage({
data: message, data: message,
success(res) { success(res) {
console.log(that.currentItem)
let obj = { let obj = {
content: message, consultationId: that.currentItem.id,
recipientName: _this.currentItem.senderName, senderId: that.currentItem.patientId,
recipientNo: _this.currentItem.senderNo, senderName: that.currentItem.patientName,
senderName: _this.currentItem.recipientName, recipientId: that.currentItem.doctorId,
senderNo: _this.currentItem.recipientNo, recipientName: that.currentItem.doctorName,
messageType: '1' messageType: 1,
sendTime: new Date(),
// messageType: (0 1 2 3 4 5 6 )
content: message
} }
sendMessage(obj).then(res => { sendMessage(obj).then(res => {
console.log(res); console.log(res);
setTimeout(() => {
that.scrollTop = that.scrollTop + 1;
}, 100)
}) })
} }
}) })
} catch (e) { } catch (e) {
console.log(e, '断线了') console.log(e, '断线了')
uni.closeSocket(); // uni.closeSocket();
} }
this.formData.content = '' // this.formData.content = '' //
@ -306,28 +312,26 @@
touchstart() { touchstart() {
uni.hideKeyboard(); uni.hideKeyboard();
}, },
scoket() { scoket() {
const _this = this const that = this
uni.closeSocket()
this.socketOpen = false this.socketOpen = false
try { try {
uni.connectSocket({ uni.connectSocket({
url: _this.SOCKETURL url: that.SOCKETURL
}) })
uni.onSocketOpen(res => { uni.onSocketOpen(res => {
console.log('webScoket连接已打开', res); console.log('webScoket连接已打开', res);
_this.socketOpen = true that.socketOpen = true
_this.reset() that.reset()
}) })
uni.onSocketError(err => { uni.onSocketError(err => {
console.log('webScoket连接打开失败', err); console.log('webScoket连接打开失败', err);
if (err && err.code != 1000) { if (err && err.code != 1000) {
setTimeout(() => { setTimeout(() => {
_this.socketOpen = true that.socketOpen = true
uni.connectSocket({ uni.connectSocket({
url: _this.SOCKETURL url: that.SOCKETURL
}) })
}, 3 * 1000) }, 3 * 1000)
} }
@ -337,9 +341,9 @@
console.log('webScoket连接关闭', err); console.log('webScoket连接关闭', err);
if (err && err.code !== 1000) { if (err && err.code !== 1000) {
setTimeout(() => { setTimeout(() => {
_this.socketOpen = true that.socketOpen = true
uni.connectSocket({ uni.connectSocket({
url: _this.SOCKETURL url: that.SOCKETURL
}) })
}, 3 * 1000) }, 3 * 1000)
} }
@ -347,11 +351,11 @@
uni.onSocketMessage(res => { uni.onSocketMessage(res => {
console.log("webScoket监听收到的信息", res); console.log("webScoket监听收到的信息", res);
_this.newsList.push({ that.newsList.push({
senderName: _this.currentItem.senderName, senderName: that.currentItem.patientName,
content: JSON.parse(res.data).message content: JSON.parse(res.data).message
}) })
_this.Read() that.Read()
}) })
} catch (e) { } catch (e) {
console.log(e); console.log(e);
@ -359,9 +363,9 @@
}, },
// //
reset() { reset() {
let _this = this let that = this
clearInterval(_this.timeoutObj); clearInterval(that.timeoutObj);
_this.timeoutObj = setInterval(() => { that.timeoutObj = setInterval(() => {
uni.sendSocketMessage({ uni.sendSocketMessage({
data: 'ping', data: 'ping',
success(res) { success(res) {
@ -375,7 +379,7 @@
}) })
} }
}) })
}, _this.timeout) }, that.timeout)
}, },
back() { back() {
uni.navigateBack({ uni.navigateBack({
@ -465,8 +469,9 @@
.fun-box { .fun-box {
opacity: 0; opacity: 0;
transition: all 0.1s ease-in-out;
height: 0; height: 0;
transition: all 0.3s ease;
transform: translateY(100%);
.grid-text { .grid-text {
padding-top: 10rpx; padding-top: 10rpx;
@ -539,6 +544,8 @@
.show-fun-box { .show-fun-box {
opacity: 1; opacity: 1;
height: 300rpx; height: 300rpx;
transition: all 0.3s ease;
transform: translateY(0%) !important;
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB