xujing 5 年之前
父節點
當前提交
0d30ebba24
共有 5 個檔案被更改,包括 34 行新增7 行删除
  1. 5
    0
      config/dev.js
  2. 3
    2
      src/components/Notice/index.js
  3. 4
    2
      src/pages/im/index.js
  4. 14
    2
      src/pages/im/list/index.js
  5. 8
    1
      src/reducers/user.js

+ 5
- 0
config/dev.js 查看文件

@@ -9,8 +9,13 @@ module.exports = {
9 9
     WSS_HOST: '"wss://dev.jinchengjiaye.com"',
10 10
     // HOST: '"https://lt.pawoma.cn"',
11 11
     // WSS_HOST: '"wss://lt.pawoma.cn"',
12
+<<<<<<< HEAD
12 13
     // HOST: '"http://192.168.2.52:8080"',
13 14
     // WSS_HOST: '"ws://192.168.2.52:8080"',
15
+=======
16
+    HOST: '"http://192.168.2.52:8080"',
17
+    WSS_HOST: '"ws://192.168.2.52:8080"',
18
+>>>>>>> 6d2db04a857d72bc8504b0f061c8baf8a3c98aba
14 19
   },
15 20
   weapp: {},
16 21
   h5: {}

+ 3
- 2
src/components/Notice/index.js 查看文件

@@ -10,8 +10,9 @@ export default class Index extends Component {
10 10
   }
11 11
 
12 12
   handleClick() {
13
-    const { dispatch } = getStore()
14
-    dispatch({ type: DECREASE_UNREADNUM })
13
+    // toFix #5922
14
+    // const { dispatch } = getStore()
15
+    // dispatch({ type: DECREASE_UNREADNUM })
15 16
     Taro.navigateTo({
16 17
       url: '/pages/im/list/index'
17 18
     })

+ 4
- 2
src/pages/im/index.js 查看文件

@@ -183,13 +183,15 @@ export default class Chat extends Component {
183 183
       const chattingName = res.name || chatting.nickname
184 184
 
185 185
       // 发送 卡片 消息
186
-      socket.sendNotice({
186
+      const payload = {
187 187
         sendPerson: chatting.personId,
188 188
         receivePerson: me.personId,
189 189
         message: `您好,我是${chattingName},有什么可以帮助您的吗?您可以在这里跟我实时沟通哦~`,
190 190
         messageType: MESSAGETYPE.CARD,
191 191
         createDate: new Date().valueOf(),
192
-      }, res => {
192
+      }
193
+
194
+      socket.sendNotice(payload, res => {
193 195
         console.log('发送成功')
194 196
         this.appendData(payload)
195 197
       })

+ 14
- 2
src/pages/im/list/index.js 查看文件

@@ -6,7 +6,10 @@ import { queryChatFriends } from '@services/chat'
6 6
 import EmptyPage from '@components/empty-page'
7 7
 import Item from './item'
8 8
 import ready from '@utils/ready'
9
-import { connect } from '@tarojs/redux'
9
+
10
+import { DECREASE_UNREADNUM } from '@constants/user'
11
+import { getStore, connect } from '@tarojs/redux'
12
+
10 13
 @connect(state => state.user)
11 14
 export default class Index extends Component {
12 15
   config = {
@@ -61,6 +64,15 @@ export default class Index extends Component {
61 64
     })
62 65
   }
63 66
 
67
+  handleItemClick = ({ unReadNum }) => {
68
+    if (unReadNum > 0) {
69
+      const { dispatch } = getStore()
70
+      dispatch({ type: DECREASE_UNREADNUM, payload: unReadNum })
71
+    }
72
+
73
+    return this.toChat.bind(this);
74
+  }
75
+
64 76
   render() {
65 77
     const { list } = this.state
66 78
     return (
@@ -73,7 +85,7 @@ export default class Index extends Component {
73 85
           height: getWindowHeight()
74 86
         }}>
75 87
 
76
-        {(loaded && list.length === 0) ? <EmptyPage text="暂无好友哦~" /> : list.map(item => <Item key={item.sendPerson} data={item} onClick={this.toChat.bind(this)} />)}
88
+        {(loaded && list.length === 0) ? <EmptyPage text="暂无好友哦~" /> : list.map(item => <Item key={item.sendPerson} data={item} onClick={this.handleItemClick(item)} />)}
77 89
 
78 90
         {/* <Loadmore nodata={!list.length} loading={loading} loadend={loadend}></Loadmore> */}
79 91
       </ScrollView>

+ 8
- 1
src/reducers/user.js 查看文件

@@ -87,9 +87,16 @@ export default function user(state = INITIAL_STATE, action) {
87 87
       }
88 88
     }
89 89
     case DECREASE_UNREADNUM: {
90
+      let { unReadNum } = state
91
+      unReadNum = unReadNum - action.payload
92
+
93
+      if (unReadNum < 0) {
94
+        unReadNum = 0
95
+      }
96
+
90 97
       return {
91 98
         ...state,
92
-        unReadNum: 0
99
+        unReadNum,
93 100
       }
94 101
     }
95 102
     default: