Quellcode durchsuchen

Merge branch 'main' of http://git.ycjcjy.com/marketing/miniapp into main

1002884655 vor 3 Jahren
Ursprung
Commit
a6235a8f83
4 geänderte Dateien mit 18 neuen und 14 gelöschten Zeilen
  1. 14
    5
      src/components/ChatIcon/index.jsx
  2. 2
    0
      src/constants/api.js
  3. 2
    2
      src/pages/index/index.jsx
  4. 0
    7
      src/utils/login.js

+ 14
- 5
src/components/ChatIcon/index.jsx Datei anzeigen

@@ -1,24 +1,33 @@
1 1
 import { useEffect, useState } from 'react'
2
+import classNames from 'classnames'
2 3
 import Taro from '@tarojs/taro'
3 4
 import { MovableArea, MovableView } from '@tarojs/components'
4 5
 import { showSubscribeMessage, MESSAGE_TYPE } from '@/utils/subscribeMessage'
6
+import { API_CHAT_UNREADED } from '@/constants/api'
7
+import { fetch } from '@/utils/request'
8
+import useInterval from '@/utils/hooks/useInterval'
5 9
 import './style.scss'
6 10
 
7 11
 export default function ChatIcon(props) {
8 12
 
13
+  const [unReadNum, setUnReadNum] = useState(0)
9 14
   const [PageX] = useState(Taro.getSystemInfoSync().windowWidth - 60)
10
-  const [PageY] = useState(Taro.getSystemInfoSync().windowHeight - 60)
15
+  const [PageY] = useState(Taro.getSystemInfoSync().windowHeight - 160)
11 16
 
12 17
   const handleClick = () => {
13
-    showSubscribeMessage(MESSAGE_TYPE.NOTICE).then((res) => {
14
-      //
18
+    showSubscribeMessage(MESSAGE_TYPE.NOTICE).then(() => {
19
+      Taro.switchTab({ url: '/pages/chat/index' })
15 20
     })
16 21
   }
17 22
 
23
+  useInterval(() =>{
24
+    fetch({url: API_CHAT_UNREADED, showToast: false}).then(x => setUnReadNum(x || 0))
25
+  }, 30000, true)
26
+
18 27
   return (
19
-    <MovableArea className='components ChatIcon'>
28
+    <MovableArea className='components ChatIcon' onClick={handleClick}>
20 29
       <MovableView className='MoveItem' x={PageX} y={PageY} direction='all'>
21
-        <text className='iconfont icon-xiaoxi centerLabel active'></text>
30
+        <text className={classNames('iconfont icon-xiaoxi centerLabel', { active: unReadNum > 0 })}></text>
22 31
       </MovableView>
23 32
     </MovableArea>
24 33
   )

+ 2
- 0
src/constants/api.js Datei anzeigen

@@ -72,6 +72,8 @@ export const API_CHAT_SEND = wss_host + '/wx/chat'
72 72
 export const API_CHAT_FRIENDS = resolvePath('chat/with')
73 73
 export const API_UPLOAD_IMAGE = resolvePath('image')
74 74
 export const API_CHAT_READED = resolvePath('chat/message')
75
+export const API_CHAT_UNREADED = resolvePath('chat/unReaded')
76
+
75 77
 
76 78
 // card
77 79
 export const API_CARDS_LIST = resolvePath('cards')

+ 2
- 2
src/pages/index/index.jsx Datei anzeigen

@@ -65,8 +65,8 @@ export default withLayout((props) => {
65 65
 
66 66
   return (
67 67
     <view className='Page Index'>
68
-      <ChatIcon></ChatIcon>
69
-      {/* <ShareToCircle visible></ShareToCircle> */}
68
+      <ChatIcon />
69
+
70 70
       <ScrollView scroll-y>
71 71
         <view className='PageContent'>
72 72
 

+ 0
- 7
src/utils/login.js Datei anzeigen

@@ -35,10 +35,6 @@ export default (params) => {
35 35
       // 获取人员详细信息
36 36
       // eslint-disable-next-line no-unused-vars
37 37
       queryUserInfo().then(info => {
38
-        // const { unReadNum } = info
39
-
40
-        // 默认红点开始就有
41
-        dispatch({ type: ASSIGN_UNREADNUM, payload: true });
42 38
         resolve(data)
43 39
       }).catch(reject)
44 40
 
@@ -51,9 +47,6 @@ export default (params) => {
51 47
           }
52 48
         })
53 49
       }
54
-
55
-      // 如果通过扫码进入
56
-
57 50
     }).catch(reject)
58 51
   
59 52
   })