diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 93b1467..a4b9443 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -14,7 +14,7 @@ diff --git a/manifest.json b/manifest.json index 15b01c3..38b8f1e 100644 --- a/manifest.json +++ b/manifest.json @@ -77,18 +77,18 @@ "optimization" : { "subPackages" : true }, - "permission": { - "scope.userLocation": { - "desc": "你的位置信息将用于获取附近服务" + "permission" : { + "scope.userLocation" : { + "desc" : "你的位置信息将用于获取附近服务" }, - "scope.record": { - "desc": "需要录音功能发送语音消息" + "scope.record" : { + "desc" : "需要录音功能发送语音消息" }, - "scope.camera": { - "desc": "需要摄像头拍照和视频通话" + "scope.camera" : { + "desc" : "需要摄像头拍照和视频通话" }, - "scope.writePhotosAlbum": { - "desc": "需要访问您的相册以选择图片" + "scope.writePhotosAlbum" : { + "desc" : "需要访问您的相册以选择图片" } } }, @@ -105,5 +105,5 @@ "enable" : false }, "vueVersion" : "2", - "sassImplementationName": "node-sass" + "sassImplementationName" : "node-sass" } diff --git a/pages/home/home.vue b/pages/home/home.vue index cb458b5..4229bd6 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -41,7 +41,7 @@ - 到店挂号 + 挂号咨询 @@ -64,55 +64,49 @@ - - - - - - - - - - {{item.name}} - {{item.title}} - - - - {{item.store}}   {{item.depart}} - - - + + + + - - - - - - - 擅长:{{item.good_at}} - + + + + + {{item.name}} + {{item.title}} + - - - 问诊量 {{item.inquiry_num }} - 接诊率 {{item.accept_percent}} - - + + + + {{item.depart}} | {{item.store}} + + + + 擅长: + {{item.good_at}} + - - - - - - + + + + {{item.inquiry_num}} + 问诊量 + + + {{item.accept_percent}} + 接诊率 + + + + 咨询 + + + + + @@ -165,9 +159,11 @@ } this.isShow_envVersion = uni.getStorageSync('isShow_envVersion') if (this.isShow_envVersion === false) { - if (this.doctorList.length === 0) { - this.getList(); - } + + this.getList(); + // if (this.doctorList.length === 0) { + // this.getList(); + // } } }, created() { @@ -418,19 +414,18 @@ // 医生列表 getList() { - if (this.doctorList?.length <= 0) { - doctorList({ - method: "post", - data: { - store_id: uni.getStorageSync('stores_id') || uni.getStorageSync('store_id') || '11001', - } - }).then((res) => { - // console.log(res, 'list'); - if (res.data.errcode === 0) { - this.doctorList = (res.data.data.list).slice(0, 3) - } - }) - } + this.doctorList = []; + doctorList({ + method: "post", + data: { + store_id: uni.getStorageSync('stores_id') || uni.getStorageSync('store_id') || '11001', + } + }).then((res) => { + // console.log(res, 'list'); + if (res.data.errcode === 0) { + this.doctorList = (res.data.data.list).slice(0, 3) + } + }) }, // 切换门店 @@ -444,6 +439,7 @@ }).then((res) => { if (res.data.errcode == 0) { this.getStore() + this.getList(); uni.showToast({ title: '切换成功', duration: 2000, @@ -510,6 +506,7 @@ onShow() { this.infoList = "" this.goNewlist() + this.getList(); }, // onUnload() { @@ -668,195 +665,153 @@ } } - .list { - width: 710rpx; - background: linear-gradient(180deg, #E2F1FF 0%, #FBFDFF 54%, #FFFFFF 100%); - border-radius: 24rpx; - padding: 12rpx 30rpx 22rpx; - margin: 32rpx auto 52rpx; - box-shadow: 0px 0px 16px 0px rgba(0, 0, 0, 0.08); + /* 医生卡片样式 */ + .doctor-card { + background: #FFFFFF; + border-radius: 16rpx; + box-shadow: 0 4rpx 12rpx rgba(65, 117, 238, 0.08); + margin-bottom: 24rpx; + overflow: hidden; + transition: all 0.25s ease; - .list_info { - display: flex; - justify-content: space-between; + &:active { + transform: translateY(2rpx); + box-shadow: 0 2rpx 6rpx rgba(65, 117, 238, 0.1); + } + } - .list_left { - height: 96rpx; - display: flex; - align-items: center; - justify-content: space-around; + .card-content { + display: flex; + padding: 24rpx; + } - image { - width: 96rpx; - height: 96rpx; - border-radius: 50%; - margin: 0 16rpx 0 0; - vertical-align: middle; - } + .doctor-avatar { + width: 100rpx; + height: 100rpx; + border-radius: 50%; + border: 2rpx solid #f0f5ff; + flex-shrink: 0; + margin-right: 20rpx; + } - .list_title { - display: flex; - flex-direction: column; + .doctor-info { + flex: 1; + min-width: 0; + } - .titles_name { - margin: 16rpx 0; + .name-section { + display: flex; + align-items: center; + margin-bottom: 12rpx; + } - .doctor_name { - height: 40rpx; - font-size: 32rpx; - font-family: PingFang SC-Bold, PingFang SC; - font-weight: bold; - color: #232323; - line-height: 40rpx; - margin-right: 16rpx; - } + .doctor-name { + font-size: 32rpx; + font-weight: bold; + color: #232323; + margin-right: 16rpx; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } - .doctors { - height: 40rpx; - font-size: 20rpx; - font-family: PingFang SC-Regular, PingFang SC; - font-weight: 400; - color: #232323; - line-height: 40rpx; - } - } + .title-badge { + font-size: 22rpx; + color: #4175EE; + background: #eef4ff; + border-radius: 8rpx; + padding: 4rpx 12rpx; + flex-shrink: 0; + } - .list_yard { - font-size: 24rpx; - font-family: PingFang SC-Regular, PingFang SC; - font-weight: 400; - color: #666666; - } - } - } + .department-section { + display: flex; + align-items: center; + margin-bottom: 16rpx; - .list_right { - width: 88rpx; - height: 50rpx; - line-height: 50rpx; - text-align: center; - background: #4175EE; - border-radius: 26rpx 26rpx 26rpx 26rpx; - font-size: 24rpx; - font-family: PingFang SC-Bold, PingFang SC; - font-weight: bold; - color: #FFFFFF; + .iconfont { + font-size: 24rpx; + color: #888; + margin-right: 6rpx; + } - } - } + .department { + font-size: 24rpx; + color: #666; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + } - .card { + .expertise { + display: flex; + font-size: 26rpx; + color: #444; + line-height: 1.4; + margin-bottom: 16rpx; - .list_nums { - height: 34rpx; - font-size: 28rpx; - font-family: PingFang SC-Regular, PingFang SC; - font-weight: 500; - color: #666666; - margin: 18rpx 0 24rpx; - display: flex; - align-items: center; + .expertise-label { + color: #666; + flex-shrink: 0; + } - .txt { - margin-right: 30rpx; + .expertise-content { + flex: 1; + min-width: 0; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; + text-overflow: ellipsis; + } + } - text { - font-size: 28rpx; - color: #FEA54C; - margin: 0 10rpx; - } - } - } + .stats { + display: flex; + align-items: center; + justify-content: space-between; + padding-top: 12rpx; + border-top: 1rpx dashed #e0e7ff; + } - .list_going { - font-size: 24rpx; - font-family: PingFang SC-Regular, PingFang SC; - font-weight: 400; - color: #232323; - line-height: 44rpx; - display: -webkit-box; - -webkit-line-clamp: 2; - -webkit-box-orient: vertical; - text-overflow: ellipsis; - overflow: hidden; - margin: 16rpx auto; - } + .stat-item { + flex: 1; + text-align: center; + } - .list_price { - display: flex; - align-items: center; + .stat-value { + font-size: 32rpx; + font-weight: bold; + color: #4175EE; + display: block; + line-height: 1.2; + } - .picture { - width: 140rpx; - height: 60rpx; - line-height: 58rpx; - text-align: center; - border-radius: 4rpx 4rpx 4rpx 4rpx; - border: 2rpx solid #4175EE; - font-size: 24rpx; - font-family: PingFang SC-Bold, PingFang SC; - font-weight: bold; - color: #4175EE; - margin: 0 30rpx 0 0; - } - } - } - } + .stat-label { + font-size: 24rpx; + color: #888; + display: block; + } - .list_lefts { - display: flex; - justify-content: space-around; - margin: 32rpx 12rpx; + .consult-btn { + background: #4175EE; + color: white; + border-radius: 40rpx; + padding: 10rpx 24rpx; + font-size: 26rpx; + display: flex; + align-items: center; - image { - width: 200rpx; - height: 200rpx; - margin-right: 20rpx; - } + .iconfont { + font-size: 24rpx; + margin-right: 6rpx; + } - .its { - width: 450rpx; - font-family: PingFang SC-Regular, PingFang SC; - - .it_names { - height: 80rpx; - font-size: 28rpx; - font-weight: bold; - color: #232323; - } - - .it_infos { - display: -webkit-box; - -webkit-line-clamp: 1; - -webkit-box-orient: vertical; - text-overflow: ellipsis; - overflow: hidden; - - font-size: 24rpx; - font-weight: 400; - color: #999999; - margin: 12rpx 0 34rpx 0; - } - - .it_prices { - display: flex; - justify-content: space-between; - align-items: center; - - text { - font-size: 28rpx; - font-weight: bold; - color: #232323; - } - - .nums { - font-size: 28rpx; - font-weight: 400; - color: #232323; - } - } - } - } + &:active { + background: #3366d1; + } + } .lists { diff --git a/pages/home/index.vue b/pages/home/index.vue index 2f9e669..a2f04c0 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -34,7 +34,7 @@ - 到店挂号 + 挂号咨询 diff --git a/pages/index/index.vue b/pages/index/index.vue index b1ddbe7..3434ae3 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -82,31 +82,6 @@ - - - - - - - - - - - - - 在线问诊 - {{ doctor.time }} - - - 您有{{ doctor.num }}条新的消息 - - - 暂无新消息 - - - - diff --git a/request/api/im.js b/request/api/im.js index d16ef5f..e736d62 100644 --- a/request/api/im.js +++ b/request/api/im.js @@ -26,6 +26,15 @@ export async function getMessagesByRoomIdApi(params) { return await post('/chat-friends/messages-by-room-id', params, 3) } +/** + * 创建房间 - 根据医生id + * @param params + * @returns {Promise<*>} + */ +export async function createRoomByDoctorIdApi(params) { + return await post('/chat-friends/create-room-by-doctor-id', params, 3) +} + /** * 获取聊天好友列表 * @param params @@ -34,6 +43,14 @@ export async function getMessagesByRoomIdApi(params) { export async function getChatFriendsListApi(params) { return await get('/chat-friends/list', params, 3) } +/** + * 获取聊天注册信息 + * @param params + * @returns {Promise<*>} + */ +export async function getChatRegisterInfoApi(params) { + return await get('/chat-friends/chat-register-info', params, 3) +} /** * 上传聊天文件 diff --git a/request/api/request.js b/request/api/request.js index 45c9a75..08c5057 100644 --- a/request/api/request.js +++ b/request/api/request.js @@ -18,18 +18,20 @@ const sensitiveData = [ 'idcard' ] +const isDev = true; + function request(url, params, method = 0) { - // let baseURL = "https://app.xiaokang88.com/member" - let baseURL = "http://127.0.0.1:18000/member" + let baseURL = isDev === true? 'http://127.0.0.1:18000/member': "https://app.xiaokang88.com/member" + // let baseURL = "http://127.0.0.1:18000/member" if (url.split('/').indexOf('imApi') !== -1) { baseURL = "http://127.0.0.1:12080/api" } if (url.split('/').indexOf('newApi') !== -1) { - baseURL = "https://shop.xiaokang88.com/member" + baseURL = isDev === true? 'https://shop.xiaokang88.com/member': "https://shop.xiaokang88.com/member" } if (url.split('/').indexOf('xkApi') !== -1) { - // baseURL = "https://api.xiaokang88.com/member" - baseURL = "http://127.0.0.1:18001/api/mobile" + baseURL = isDev === true? 'http://127.0.0.1:18001/api/mobile': "https://api.xiaokang88.com/api/mobile" + // baseURL = "http://127.0.0.1:18001/api/mobile" } url = url.replace('/oldApi', ''); url = url.replace('/newApi', ''); diff --git a/store/chat/chat.js b/store/chat/chat.js index f8ebf24..402e97a 100644 --- a/store/chat/chat.js +++ b/store/chat/chat.js @@ -1,4 +1,4 @@ -import {getMessagesByRoomIdApi} from "@/request/api/im"; +import {getChatRegisterInfoApi, getMessagesByRoomIdApi} from "@/request/api/im"; /** * 聊天消息管理器 @@ -112,21 +112,28 @@ const ChatManager = { sender: message.sender_user_id, type: this.getMessageType(message.message_type), // type: message.type, - content: message.message_type === 4 ? JSON.parse(message.content) : message.content, + content: + item.message_type === 4 || item.message_type === 10 + ? JSON.parse(item.message_content) + : item.message_content, duration: message.duration, time: this.formatTime(message.send_time), timestamp: message.send_time }; } - return message.map(item => { + return message.map((item, index) => { + let msg = item.message_type === 4 || item.message_type === 10 + ? JSON.parse(item.message_content) + : item.message_content; + + if (item.message_type === 10) { + this.getChatRegisterInfo(msg, index) + } return { id: item.id, sender: item.sender_user_id, type: this.getMessageType(item.message_type), - content: - item.message_type === 4 - ? JSON.parse(item.message_content) - : item.message_content, + content: msg, duration: item.duration, time: item?.created_at_text || item.send_time, timestamp: item?.created_at || item.send_time @@ -142,11 +149,33 @@ const ChatManager = { 2: 'audio', 3: 'video', 4: 'prescription', - 5: 'file' + 5: 'file', + 10: 'register', }; return types[typeId]; }, + /** + * 获取挂号信息卡片 + * @param item + * @param index + * @returns {*} + */ + getChatRegisterInfo(item, index) { + let that = this; + getChatRegisterInfoApi({ + id: item.id + }).then((res) => { + console.log(that.roomMessages, 'ssssssssssss1') + console.log(that.currentRoomId, 'ssssssssssss2') + console.log(index, 'ssssssssssss3') + console.log(that.roomMessages[that.currentRoomId][index], 'ssssssssssss4') + that.roomMessages[that.currentRoomId][index].content = res.data.result; + console.log('getChatRegisterInfo', that.roomMessages[that.currentRoomId][index].content) + // return res.data.result + }) + }, + // 格式化时间 formatTime(timestamp) { let date; diff --git a/subPackages/chat/chat.vue b/subPackages/chat/chat.vue index 35d42d3..9c089c3 100644 --- a/subPackages/chat/chat.vue +++ b/subPackages/chat/chat.vue @@ -7,11 +7,11 @@ {{ doctorUserInfo.nick_name }} 在线 · 心血管内科 - + {{ showDoctorDetail ? '▲' : '▼' }} - - + + @@ -62,7 +62,7 @@ class="video-player" > - + {{ msg.duration }}'' + + + + + 挂号信息 + + {{ getRegisterStatusText(msg.content.status) }} + + + + + + {{ msg.content.order_no }} + + + + 第{{ msg.content.order_number }}号 + + + + + + 患者信息 + + {{ getPayStatusText(msg.content.is_pay) }} + + + + + + {{ msg.content.user_patient && msg.content.user_patient.name || '未知' }} + + + + {{ msg.content.user_patient && msg.content.user_patient.age || 0 }}岁 + + + + {{ getSexText(msg.content.user_patient && msg.content.user_patient.sex) }} + + + + + 挂号费: ¥{{ msg.content.price }} + 查看详情 + + + 创建时间: {{ msg.content.created_at }} + + - + 电子处方 {{ getStatusText(msg.content.status) }} @@ -84,7 +134,7 @@ - + {{ msg.content.order_no }} @@ -130,12 +180,62 @@ > {{ msg.duration }}'' - + + + + + + + 挂号信息 + + {{ getRegisterStatusText(msg.content.status) }} + + + + + + {{ msg.content.order_no }} + + + + 第{{ msg.content.order_number }}号 + + + + + + 患者信息 + + {{ getPayStatusText(msg.content.is_pay) }} + + + + + + {{ msg.content.user_patient && msg.content.user_patient.name || '未知' }} + + + + {{ msg.content.user_patient && msg.content.user_patient.age || 0 }}岁 + + + + {{ getSexText(msg.content.user_patient && msg.content.user_patient.sex) }} + + + + + 挂号费: ¥{{ msg.content.price }} + 查看详情 + + + 创建时间: {{ msg.content.created_at }} + - + 电子处方 {{ getStatusText(msg.content.status) }} @@ -143,7 +243,7 @@ - + {{ msg.content.order_no }} @@ -166,36 +266,40 @@ - + 加载中... - + - + 图片 - + 拍照 - - - 文件 - - - - 处方 - + + + + + + + + + + + + - + @@ -214,7 +318,7 @@ @touchstart="startVoiceRecording" @touchend="stopVoiceRecording" @touchcancel="stopVoiceRecording"> - + {{ recording ? '松开结束' : '按住说话' }} @@ -228,7 +332,7 @@ class="send-btn" @click="sendTextMessage" > - + @@ -237,32 +341,22 @@ - + 录音中... {{ recordingTime }}秒 上划取消发送 - - - + .infos { + width: 686rpx; + height: 90rpx; + line-height: 90rpx; + display: flex; + justify-content: space-around; + align-items: center; + margin: 16rpx 0; + font-size: 32rpx; + font-family: PingFang SC-Medium, PingFang SC; + font-weight: 500; + text-align: center; + height: 86rpx; + background: #4175EE; + border-radius: 198rpx; + color: #FFFFFF; + margin-left: 32rpx; + } + } +} + \ No newline at end of file diff --git a/subPackages/my/myrecord-detail.vue b/subPackages/my/myrecord-detail.vue index e8ff7e6..30ca408 100644 --- a/subPackages/my/myrecord-detail.vue +++ b/subPackages/my/myrecord-detail.vue @@ -155,26 +155,26 @@ 医师 - - + + 审核药师 - + 发药人 - + 核对人 - + 调配人 - + @@ -127,6 +135,7 @@ registePay, service } from '../../request/api/api'; + import {createRoomByDoctorIdApi, sendToUserApi} from "@/request/api/im"; export default { data() { return { @@ -136,29 +145,43 @@ check: false }, register_id: "", + currentUserId: "", + currentDoctorId: "", registList: [], content: `预约挂号须知`, - flag: true + flag: true, + registerType: '线下就诊', + registerMap: { + 0: '线下就诊', + 1: '线上咨询' + } } }, onLoad(e) { // console.log(e, 'role'); this.register_id = e.id + this.currentUserId = 'user-' + uni.getStorageSync('user_id') || 'user-2512'; + this.currentDoctorId = 'doctor-' + e.doctor_id; + // if (this.currentDoctorId == null) { + // + // } uni.setStorageSync('register_id', this.register_id) }, methods: { // 挂号信息 getInfo() { + let that = this; registeInfo({ method: "post", data: { store_id: uni.getStorageSync('store_id') || '11001', - register_id: this.register_id + register_id: that.register_id } }).then((res) => { // console.log(res, 'gh'); if (res.data.errcode == 0) { - this.registList = res.data.data.list[0] + that.registList = res.data.data.list[0] + that.registerType = that.registerMap[that.registList.register_type]; } }) }, @@ -180,6 +203,22 @@ title: "加载中" }); + + createRoomByDoctorIdApi({ + doctor_id: that.currentDoctorId + }).then(result => { + sendToUserApi({ + room_id: result.data.result.room_id, + sender_user_id: that.currentUserId, + receiver_user_id: that.currentDoctorId, + message_type: 10, + message_content: JSON.stringify({ + id: that.register_id, + }), + duration: 0 + }) + }) + if (res.data.data.is_paid == 1) { setTimeout(() => { uni.navigateTo({ @@ -203,6 +242,7 @@ // console.log('success:' + JSON.stringify(res)); setTimeout(() => { that.flag = false + uni.navigateTo({ url: '/subPackages/register/register-success?id=' + this.register_id diff --git a/utils/utils.js b/utils/utils.js new file mode 100644 index 0000000..e42c224 --- /dev/null +++ b/utils/utils.js @@ -0,0 +1,4 @@ +export function checkImageUrl(url) { + // 如果url包含http,则返回url,反之加上 data:image/jpeg;base64, + return url.includes('http') ? url : 'data:image/jpeg;base64,' + url +}; \ No newline at end of file diff --git a/utils/ws/websocket.js b/utils/ws/websocket.js index 6e363d0..e7eddcd 100644 --- a/utils/ws/websocket.js +++ b/utils/ws/websocket.js @@ -104,10 +104,14 @@ export class WebSocketManager { } } - handleMessage(data) { - // 如果对象中有clientId则给websocket发送 - if (data.clientId) { - const userId = uni.getStorageSync('user_id'); // 实际项目中从存储获取 + getUserIdAndBindClientId() { + const userId = uni.getStorageSync('user_id'); // 实际项目中从存储获取 + if (userId == null || userId === 'user-' || userId === '') { + // 等待10秒后获取 + setTimeout(() => { + this.getUserIdAndBindClientId(); + }, 10000) + } else { const bindMessage = { request_type: 'bind', user_type: 'user', @@ -115,6 +119,28 @@ export class WebSocketManager { }; this.send(bindMessage); } + return userId; + } + + handleMessage(data) { + // 如果对象中有clientId则给websocket发送 + if (data.clientId) { + + this.getUserIdAndBindClientId(data.clientId); + // const userId = uni.getStorageSync('user_id'); // 实际项目中从存储获取 + // if (userId == null) { + // setTimeout(() => { + // }, 10000) + // } else { + // const bindMessage = { + // request_type: 'bind', + // user_type: 'user', + // sender_user_id: `user-${userId}`, + // }; + // this.send(bindMessage); + // } + + } // 处理聊天消息 if (data.message_type !== undefined) {