Ver código fonte

修改聊天记录显示

zs 1 ano atrás
pai
commit
c68092f4a6

+ 1 - 1
pages/home/index.vue

@@ -23,7 +23,7 @@
 						</view>
 					</view>
 				</uni-collapse-item>
-				<uni-collapse-item title="好友" :thumb="config.friend_url[0].url">
+				<uni-collapse-item title="好友" :thumb="config.friend_url[0].url" :open="true">
 					<view class="content" v-if="friendList.length>0">
 						<view class="two_1">
 							<input type="text" v-model="searchfriend.name" @input="toInputFriend" placeholder="搜索">

+ 28 - 16
pagesHome/friend/index.vue

@@ -8,8 +8,11 @@
 						<view class="time" v-if="index == 0 || item.time - list[index-1].time >= 300000">
 							<text>{{formatDate(item.time)}}</text>
 						</view>
-						<view class="list" :id="item.speaker._id != userId ? 'left' : 'right'">
-							<image class="avatar"
+						<view class="list" :id="item.speaker._id != user._id ? 'left' : 'right'">
+							<image class="avatar" v-if="item.speaker_type=='Nurse'"
+								:src="doctorInfo.icon&&doctorInfo.icon.length>0?doctorInfo.icon[0].url:config.user_url[0].url"
+								mode=""></image>
+							<image class="avatar" v-else
 								:src="item.speaker&&item.speaker.icon.length>0?item.speaker.icon[0].url:config.user_url[0].url"
 								mode=""></image>
 							<text class="record" v-if="item.type == 'text'">{{item.content}}</text>
@@ -17,11 +20,11 @@
 								mode="widthFix">
 							</image>
 							<view class="record" v-if="item.type == 'record'" @tap="onPlay(item.content,index)">
-								<uni-icons v-if="item.speaker._id != userId" custom-prefix="iconfont"
+								<uni-icons v-if="item.speaker._id != user._id" custom-prefix="iconfont"
 									type="icon-zuobofang" size="15" color="#333333">
 								</uni-icons>
 								<text class="voice">{{item.voice}}</text>"
-								<uni-icons v-if="item.speaker._id == userId" custom-prefix="iconfont"
+								<uni-icons v-if="item.speaker._id == user._id" custom-prefix="iconfont"
 									type="icon-youbofang" size="15" color="#ffffff">
 								</uni-icons>
 							</view>
@@ -64,6 +67,8 @@
 				userId: '',
 				user: {},
 				config: {},
+				// 医生信息
+				doctorInfo: {},
 				// 聊天列表数据
 				list: [],
 				total: 0,
@@ -79,6 +84,8 @@
 				is_bottom: true,
 				// 判断是否下拉刷新复位
 				triggered: false,
+				// 是否发送消息
+				is_send: true,
 				//实时通信
 				client: null,
 				subscription: null
@@ -121,8 +128,6 @@
 					if (res) {
 						const user = that.$jwt(res);
 						that.$set(that, `user`, user);
-						if (user.role == 'Nurse') that.$set(that, `userId`, user.doctor);
-						else that.$set(that, `userId`, user._id);
 					}
 				} catch (e) {}
 			},
@@ -147,9 +152,12 @@
 					...info
 				})
 				if (res.errcode == '0') {
-					let list = [...res.data.reverse(), ...that.list];
+					let list;
+					if (that.is_send) list = [...res.data.reverse(), ...that.list];
+					else list = [...res.data.reverse()];
 					that.$set(that, `list`, list)
 					that.$set(that, `total`, res.total)
+					that.$set(that, `is_send`, true);
 				} else {
 					uni.showToast({
 						title: res.errmsg,
@@ -247,14 +255,6 @@
 							console.log('uploadImage fail', err);
 						},
 					});
-					let mess = {
-						type: 'record',
-						voice: Math.round(res.duration / 1000), // 时长
-						content: res.tempFilePath,
-						time: new Date() - 0
-					}
-					// 写在上传回调内
-					that.toSend(mess)
 				})
 				that.record.onError(err => {
 					that.global.toast('获取录音失败')
@@ -326,6 +326,7 @@
 				}
 				let res = await that.$api(`/chat`, 'POST', data)
 				if (res.errcode == '0') {
+					that.$set(that, `is_send`, false);
 					that.search()
 					that.$set(that, `isRecorder`, false);
 					that.poalast() // 定位消息最后一行
@@ -375,8 +376,19 @@
 				})
 			},
 			// 处理已读未读
-			searchOther() {
+			async searchOther() {
 				const that = this
+				let res;
+				// 医生信息
+				res = await that.$api(`/doctor/${that.doctorId}`, 'GET', {})
+				if (res.errcode == '0') {
+					that.$set(that, `doctorInfo`, res.data)
+				} else {
+					uni.showToast({
+						title: res.errmsg,
+						icon: 'none'
+					});
+				}
 			},
 		}
 	}

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/home/index.js.map


Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/friend/common/submit_1.js.map


Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/friend/index.js.map


Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
unpackage/dist/dev/mp-weixin/pages/home/index.wxml


+ 42 - 13
unpackage/dist/dev/mp-weixin/pagesHome/friend/index.js

@@ -163,11 +163,18 @@ var render = function () {
       index == 0 || item.time - _vm.list[index - 1].time >= 300000
         ? _vm.formatDate(item.time)
         : null
-    var g0 = item.speaker && item.speaker.icon.length > 0
+    var g0 =
+      item.speaker_type == "Nurse"
+        ? _vm.doctorInfo.icon && _vm.doctorInfo.icon.length > 0
+        : null
+    var g1 = !(item.speaker_type == "Nurse")
+      ? item.speaker && item.speaker.icon.length > 0
+      : null
     return {
       $orig: $orig,
       m0: m0,
       g0: g0,
+      g1: g1,
     }
   })
   _vm.$mp.data = Object.assign(
@@ -247,6 +254,8 @@ var _default = {
       userId: '',
       user: {},
       config: {},
+      // 医生信息
+      doctorInfo: {},
       // 聊天列表数据
       list: [],
       total: 0,
@@ -267,6 +276,8 @@ var _default = {
       is_bottom: true,
       // 判断是否下拉刷新复位
       triggered: false,
+      // 是否发送消息
+      is_send: true,
       //实时通信
       client: null,
       subscription: null
@@ -349,7 +360,6 @@ var _default = {
         if (res) {
           var user = that.$jwt(res);
           that.$set(that, "user", user);
-          if (user.role == 'Nurse') that.$set(that, "userId", user.doctor);else that.$set(that, "userId", user._id);
         }
       } catch (e) {}
     },
@@ -381,9 +391,10 @@ var _default = {
               case 4:
                 res = _context3.sent;
                 if (res.errcode == '0') {
-                  list = [].concat((0, _toConsumableArray2.default)(res.data.reverse()), (0, _toConsumableArray2.default)(that.list));
+                  if (that.is_send) list = [].concat((0, _toConsumableArray2.default)(res.data.reverse()), (0, _toConsumableArray2.default)(that.list));else list = (0, _toConsumableArray2.default)(res.data.reverse());
                   that.$set(that, "list", list);
                   that.$set(that, "total", res.total);
+                  that.$set(that, "is_send", true);
                 } else {
                   uni.showToast({
                     title: res.errmsg,
@@ -489,15 +500,6 @@ var _default = {
             console.log('uploadImage fail', err);
           }
         });
-        var mess = {
-          type: 'record',
-          voice: Math.round(res.duration / 1000),
-          // 时长
-          content: res.tempFilePath,
-          time: new Date() - 0
-        };
-        // 写在上传回调内
-        that.toSend(mess);
       });
       that.record.onError(function (err) {
         that.global.toast('获取录音失败');
@@ -572,6 +574,7 @@ var _default = {
               case 5:
                 res = _context4.sent;
                 if (res.errcode == '0') {
+                  that.$set(that, "is_send", false);
                   that.search();
                   that.$set(that, "isRecorder", false);
                   that.poalast(); // 定位消息最后一行
@@ -629,7 +632,33 @@ var _default = {
     },
     // 处理已读未读
     searchOther: function searchOther() {
-      var that = this;
+      var _this3 = this;
+      return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
+        var that, res;
+        return _regenerator.default.wrap(function _callee5$(_context5) {
+          while (1) {
+            switch (_context5.prev = _context5.next) {
+              case 0:
+                that = _this3;
+                _context5.next = 3;
+                return that.$api("/doctor/".concat(that.doctorId), 'GET', {});
+              case 3:
+                res = _context5.sent;
+                if (res.errcode == '0') {
+                  that.$set(that, "doctorInfo", res.data);
+                } else {
+                  uni.showToast({
+                    title: res.errmsg,
+                    icon: 'none'
+                  });
+                }
+              case 5:
+              case "end":
+                return _context5.stop();
+            }
+          }
+        }, _callee5);
+      }))();
     }
   }
 };

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/friend/index.wxml