|
@@ -17,8 +17,9 @@
|
|
<view class="msg-text">{{item.content}}</view>
|
|
<view class="msg-text">{{item.content}}</view>
|
|
</view>
|
|
</view>
|
|
<!-- 图像 -->
|
|
<!-- 图像 -->
|
|
- <view class="message" v-else @tap="previewImg(item.content)">
|
|
|
|
- <image :src="item.content" class="msg-img" mode="widthFix"></image>
|
|
|
|
|
|
+ <view class="message img" v-else @tap="previewImg(item.content)">
|
|
|
|
+ <image :src="item.content&&item.content.length>0?item.content[0].url:''"
|
|
|
|
+ class="msg-img" mode="widthFix"></image>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="msg-m msg-right" v-if="item.speaker == friendName">
|
|
<view class="msg-m msg-right" v-if="item.speaker == friendName">
|
|
@@ -29,8 +30,9 @@
|
|
<view class="msg-text">{{item.content}}</view>
|
|
<view class="msg-text">{{item.content}}</view>
|
|
</view>
|
|
</view>
|
|
<!-- 图像 -->
|
|
<!-- 图像 -->
|
|
- <view class="message" v-else @tap="previewImg(item.content)">
|
|
|
|
- <image :src="item.content" class="msg-img" mode="widthFix"></image>
|
|
|
|
|
|
+ <view class="message img" v-else @tap="previewImg(item.content)">
|
|
|
|
+ <image :src="item.content&&item.content.length>0?item.content[0].url:''"
|
|
|
|
+ class="msg-img" mode="widthFix"></image>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -158,17 +160,11 @@
|
|
// 进行图片的预览
|
|
// 进行图片的预览
|
|
previewImg(e) {
|
|
previewImg(e) {
|
|
const that = this;
|
|
const that = this;
|
|
- let index = 0;
|
|
|
|
- for (let i = 0; i < that.imgMsg.length; i++) {
|
|
|
|
- if (that.imgMsg[i] == e) {
|
|
|
|
- index = i;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- console.log("index", index)
|
|
|
|
|
|
+ let urls = e && e[0] && e[0].url;
|
|
// 预览图片
|
|
// 预览图片
|
|
uni.previewImage({
|
|
uni.previewImage({
|
|
- current: index,
|
|
|
|
- urls: that.imgMsg,
|
|
|
|
|
|
+ current: 0,
|
|
|
|
+ urls: [urls],
|
|
longPressActions: {
|
|
longPressActions: {
|
|
itemList: ['发送给朋友', '保存图片', '收藏'],
|
|
itemList: ['发送给朋友', '保存图片', '收藏'],
|
|
success: function(data) {
|
|
success: function(data) {
|
|
@@ -194,7 +190,7 @@
|
|
// 发送给服务器消息
|
|
// 发送给服务器消息
|
|
// onSendWS(JSON.stringify(data));
|
|
// onSendWS(JSON.stringify(data));
|
|
|
|
|
|
- thatthat.unshiftmsg.push(data);
|
|
|
|
|
|
+ that.unshiftmsg.push(data);
|
|
// 跳转到最后一条数据 与前面的:id进行对照
|
|
// 跳转到最后一条数据 与前面的:id进行对照
|
|
that.$nextTick(function() {
|
|
that.$nextTick(function() {
|
|
that.scrollToView = 'msg' + (that.unshiftmsg.length - 1)
|
|
that.scrollToView = 'msg' + (that.unshiftmsg.length - 1)
|
|
@@ -267,6 +263,10 @@
|
|
max-width: 480rpx;
|
|
max-width: 480rpx;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ .img {
|
|
|
|
+ margin: 0 20rpx 0 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
.msg-text {
|
|
.msg-text {
|
|
font-size: 32rpx;
|
|
font-size: 32rpx;
|
|
color: rgba(39, 40, 50, 1);
|
|
color: rgba(39, 40, 50, 1);
|