bayi 2 سال پیش
والد
کامیت
b78c811d98
8فایلهای تغییر یافته به همراه52 افزوده شده و 12 حذف شده
  1. 24 4
      pages/chat/index.js
  2. 2 1
      pages/chat/index.json
  3. 4 0
      pages/chat/index.less
  4. 4 3
      pages/chat/index.wxml
  5. 2 0
      pages/chat/index.wxss
  6. 8 2
      pages/friend/index.js
  7. 6 1
      pages/personal/index.js
  8. 2 1
      pages/searchFriend/index.js

+ 24 - 4
pages/chat/index.js

@@ -51,13 +51,17 @@ Page({
       list,
       totalSize
     })
-    console.log(data, this.data.userInfo);
+    console.log('就列表', data);
   },
   async getNewMsgDet() {
     let res = await getNewMsgDet({
       senderUid: this.data.targetUid,
     })
-    console.log(res);
+    let newList = [...this.data.list, ...res]
+    console.log(newList);
+    /* this.setData({
+      list: newList
+    }) */
   },
   async sendReply() {
     if (!this.data.value) {
@@ -67,8 +71,17 @@ Page({
       content: this.data.value,
       receiverUid: this.data.targetUid
     })
+    this.setData({
+      value: ''
+    })
+    this.getNewMsgDet()
+  },
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+    console.log('1');
   },
-
   chooseImage() {
     wx.chooseImage({
       count: 1, // 可选择的图片数量
@@ -76,6 +89,7 @@ Page({
       sourceType: ['album', 'camera'], // 来源:相册或相机
       success: (res) => {
         // 将选择的图片上传到服务器
+        console.log(res);
         this.uploadImage(res.tempFilePaths[0]);
       }
     })
@@ -84,11 +98,17 @@ Page({
     wx.uploadFile({
       url: 'https://reader-api.ai160.com/file/upload',
       filePath: imagePath,
+      name: '朗读录音',
       header: {
         uid: wx.getStorageSync('uid')
       },
-      success: (res) => {
+      success: async (res) => {
         console.log(res.data);
+        await sendMsg({
+          content: JSON.parse(res.data).data,
+          receiverUid: this.data.targetUid
+        })
+        this.getNewMsgDet()
       }
     })
   },

+ 2 - 1
pages/chat/index.json

@@ -1,3 +1,4 @@
 {
-  "usingComponents": {}
+  "usingComponents": {},
+  "enablePullDownRefresh": true
 }

+ 4 - 0
pages/chat/index.less

@@ -19,17 +19,20 @@
       }
 
       .message {
+        max-width: 80%;
         padding: 20rpx;
         box-sizing: border-box;
         font-size: 28rpx;
         line-height: 42rpx;
         border-radius: 14rpx;
         background-color: #F2F6FC;
+        word-break: break-all;
       }
     }
 
     .someone {
       justify-content: flex-start;
+
       .avatar {
         margin-right: 30rpx;
       }
@@ -37,6 +40,7 @@
 
     .self {
       justify-content: flex-end;
+
       .message {
         display: inline-block;
         margin-right: 30rpx;

+ 4 - 3
pages/chat/index.wxml

@@ -2,17 +2,18 @@
   <view class="content">
     <block wx:for="{{list}}" wx:key="id">
       <view class="base someone" wx:if="{{uid!=item.senderUid}}">
-        <image src="{{item.user.avatar}}" class="avatar" bindtap="jumpUserInfo" data-uid='{{item.uid}}' />
+        <image src="{{item.user.avatar}}" class="avatar" bindtap="jumpUserInfo" data-uid='{{item.receiverUid}}' />
         <view class="message">{{item.content}}</view>
       </view>
       <view class="base self" wx:else>
         <view class="message">{{item.content}}</view>
-        <image src="{{userInfo.avatar}}" class="avatar" bindtap="jumpUserInfo" data-uid='{{item.uid}}' />
+        <image src="{{userInfo.avatar}}" class="avatar" bindtap="jumpUserInfo" data-uid='{{item.senderUid}}' />
       </view>
     </block>
   </view>
   <view class="inputBox {{isIos?'iosPadding':''}}">
-    <input class="input" bindinput="bindKeyInput" value="{{value}}" placeholder="我有话说..." />
+    <input class="input" bindinput="bindKeyInput" value="{{value}}" placeholder="我有话说..." confirm-type='sendReply'
+      maxlength="100" />
     <image src="/static/follow_3.png" class="sendImg" bindtap="chooseImage" />
     <view class="submit" bindtap="sendReply">发送</view>
   </view>

+ 2 - 0
pages/chat/index.wxss

@@ -18,12 +18,14 @@
   background-color: #eeeeee;
 }
 .chat .content .base .message {
+  max-width: 80%;
   padding: 20rpx;
   box-sizing: border-box;
   font-size: 28rpx;
   line-height: 42rpx;
   border-radius: 14rpx;
   background-color: #F2F6FC;
+  word-break: break-all;
 }
 .chat .content .someone {
   justify-content: flex-start;

+ 8 - 2
pages/friend/index.js

@@ -9,7 +9,8 @@ Page({
     // 1我的关注;2我的粉丝
     currentType: 1,
     c1: 0,
-    c2: 0
+    c2: 0,
+    localUid: wx.getStorageSync('uid')
   },
   async onShow() {
     this.resetData()
@@ -104,12 +105,17 @@ Page({
     currentTarget
   }) {
     let user = currentTarget.dataset.user
-    console.log(user);
     let {
       nickName,
       eid,
       uid
     } = user
+    if (this.data.localUid == uid) {
+      return wx.showToast({
+        title: '不可以给自己发私信哦~',
+        icon: 'none'
+      })
+    }
     wx.navigateTo({
       url: `/pages/chat/index?title=${nickName||eid}&uid=${uid}`,
     })

+ 6 - 1
pages/personal/index.js

@@ -98,12 +98,17 @@ Page({
     currentTarget
   }) {
     let user = this.data.userInfo.user
-    console.log(user);
     let {
       nickName,
       eid,
       uid
     } = user
+    if (this.data.localUid == uid) {
+      return wx.showToast({
+        title: '不可以给自己发私信哦~',
+        icon: 'none'
+      })
+    }
     wx.navigateTo({
       url: `/pages/chat/index?title=${nickName||eid}&uid=${uid}`,
     })

+ 2 - 1
pages/searchFriend/index.js

@@ -4,7 +4,8 @@ Page({
   behaviors: [reachBottom],
   data: {
     text: '',
-    historySearch: []
+    historySearch: [],
+    localUid: wx.getStorageSync('uid')
   },
   onShow() {
     this.setData({