瀏覽代碼

开发优化

bayi 1 年之前
父節點
當前提交
73f39bcc7e
共有 3 個文件被更改,包括 13 次插入4 次删除
  1. 7 1
      pages/chat/index.js
  2. 4 2
      pages/chat/index.wxml
  3. 2 1
      pages/reading/index.js

+ 7 - 1
pages/chat/index.js

@@ -31,7 +31,7 @@ Page({
     })
     this.setData({
       targetUid: options.uid,
-      uid:wx.getStorageSync('uid')
+      uid: wx.getStorageSync('uid')
     })
     this.storeBindings = createStoreBindings(this, {
       store,
@@ -99,6 +99,12 @@ Page({
     })
     this.getNewMsgDet()
   },
+  previewImage(e) {
+    var imageUrl = e.currentTarget.dataset.src;
+    wx.previewImage({
+      urls: [imageUrl]
+    })
+  },
   chooseImage() {
     wx.chooseImage({
       count: 1, // 可选择的图片数量

+ 4 - 2
pages/chat/index.wxml

@@ -5,11 +5,13 @@
       <view class="base someone" wx:if="{{uid!=item.senderUid}}">
         <image src="{{item.user.avatar}}" class="avatar" bindtap="jumpUserInfo" data-uid='{{item.senderUid}}' />
         <view class="message" wx:if="{{item.type==1}}">{{item.content}}</view>
-        <image src="{{item.content}}" wx:else class="msgImg" mode="widthFix" />
+        <image src="{{item.content}}" wx:else class="msgImg" mode="widthFix" bindtap="previewImage"
+          data-src="{{item.content}}" />
       </view>
       <view class="base self" wx:else>
         <view class="message" wx:if="{{item.type==1}}">{{item.content}}</view>
-        <image src="{{item.content}}" wx:else class="msgImg" mode="widthFix" />
+        <image src="{{item.content}}" wx:else class="msgImg" mode="widthFix" bindtap="previewImage"
+          data-src="{{item.content}}" />
         <image src="{{userInfo.avatar}}" class="avatar" bindtap="jumpUserInfo" data-uid='{{item.senderUid}}' />
       </view>
     </block>

+ 2 - 1
pages/reading/index.js

@@ -557,7 +557,6 @@ Page({
   resetReading() {
     clearTimeout(this.setTimeoutObj)
     clearInterval(this.stl)
-    wsEngine.reset()
     // 重置视频
     if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
       this.videoContext.stop()
@@ -608,9 +607,11 @@ Page({
     }, 300)
   },
   onHide() {
+    wsEngine.reset()
     this.resetReading()
   },
   onUnload() {
+    wsEngine.reset()
     this.resetReading()
     this.storeBindings.destroyStoreBindings()
   },