Your Name 3 years ago
parent
commit
3f9e534fee

src/components/Adv/index.jsx → src/components/FirstScreen/index.jsx View File

1
 import { useState, useEffect } from 'react'
1
 import { useState, useEffect } from 'react'
2
 import { Image } from '@tarojs/components'
2
 import { Image } from '@tarojs/components'
3
+import { getImgURL } from '@/utils/image'
3
 import './style.scss'
4
 import './style.scss'
4
 
5
 
5
 export default (props) => {
6
 export default (props) => {
6
-
7
-  const { show = false } = props
8
-
9
-  const [ShowAdv, setShowAdv] = useState(show)
7
+  const { info, visible = false, onClose } = props
10
 
8
 
11
   const ImgClick = () => {
9
   const ImgClick = () => {
12
 
10
 
13
   }
11
   }
14
 
12
 
15
-  const Close = () => {
16
-    setShowAdv(false)
17
-  }
13
+  console.log('---------info------>', info, visible)
18
 
14
 
19
   return (
15
   return (
20
-    <view className='components Adv' style={{display: ShowAdv ? 'block' : 'none'}}>
16
+    <view className='components Adv' style={{display: visible ? 'block' : 'none'}}>
21
       <view className='centerLabel'>
17
       <view className='centerLabel'>
22
         <view>
18
         <view>
23
           <view className='Img' onClick={ImgClick}>
19
           <view className='Img' onClick={ImgClick}>
24
-            <Image mode='scaleToFill' src={null}></Image>
20
+            <Image mode='scaleToFill' src={getImgURL(info?.image)}></Image>
25
           </view>
21
           </view>
26
-          <text className='iconfont icon-guanbi' onClick={Close}></text>
22
+          <text className='iconfont icon-guanbi' onClick={onClose}></text>
27
         </view>
23
         </view>
28
       </view>
24
       </view>
29
     </view>
25
     </view>

src/components/Adv/style.scss → src/components/FirstScreen/style.scss View File


+ 4
- 2
src/layout/index.js View File

8
 import AuthPhone from '@/components/Auth/AuthPhone'
8
 import AuthPhone from '@/components/Auth/AuthPhone'
9
 import Spin from '@/components/Spin/Spin2'
9
 import Spin from '@/components/Spin/Spin2'
10
 import FixedConsultant from '@/components/FixedConsultant'
10
 import FixedConsultant from '@/components/FixedConsultant'
11
+import FirstScreen from '@/components/FirstScreen'
11
 import { report as reportCustomer } from '@/utils/customer'
12
 import { report as reportCustomer } from '@/utils/customer'
12
 import { ROLE_CODE } from '@/constants/user'
13
 import { ROLE_CODE } from '@/constants/user'
13
 import useAuth from './useAuth'
14
 import useAuth from './useAuth'
18
 
19
 
19
 export default (ChildComponent) => (props) => {
20
 export default (ChildComponent) => (props) => {
20
   const consultant = useSelector(s => s.system.consultant)
21
   const consultant = useSelector(s => s.system.consultant)
21
-  const city = useSelector(s => s.city)
22
+  const city = useSelector(s => s.city.curCity)
22
   const { spinning, userInfo } = useSelector(s => s.user)
23
   const { spinning, userInfo } = useSelector(s => s.user)
23
   const { person, ...extInfo } = userInfo || {}
24
   const { person, ...extInfo } = userInfo || {}
24
   const router = useRouter()
25
   const router = useRouter()
34
   // 页面埋点
35
   // 页面埋点
35
   const [trackData, setTrackData] = useState({})
36
   const [trackData, setTrackData] = useState({})
36
   // 开屏广告
37
   // 开屏广告
37
-  const [firstScreen, showScreen, toggleShowScreen] = useScreen(city.id, person)
38
+  const [screenInfo, screenVisible, toggleShowScreen] = useScreen(city.id, person)
38
 
39
 
39
   // 报备客户
40
   // 报备客户
40
   useEffect(() => {
41
   useEffect(() => {
105
       {
106
       {
106
         !!showConsultant && (<FixedConsultant consultant={consultant} />)
107
         !!showConsultant && (<FixedConsultant consultant={consultant} />)
107
       }
108
       }
109
+      <FirstScreen info={screenInfo} visible={screenVisible} onClose={toggleShowScreen} />
108
     </>
110
     </>
109
   )
111
   )
110
 }
112
 }

+ 5
- 1
src/layout/useScreen.js View File

10
   const dispatch = useDispatch()
10
   const dispatch = useDispatch()
11
 
11
 
12
   const [firstScreen, setFirstScreen] = useState()
12
   const [firstScreen, setFirstScreen] = useState()
13
-  const show = useSelector(s => !s.system.firstScreen.filter(x => x === cityId)[0])
13
+  const canShow = useSelector(s => !s.system.firstScreen.filter(x => x === cityId)[0])
14
   const toggle = useCallback(
14
   const toggle = useCallback(
15
     () => dispatch({ type: 'TOGGLE_FIRSTSCREEN', payload: { cityId } }),
15
     () => dispatch({ type: 'TOGGLE_FIRSTSCREEN', payload: { cityId } }),
16
     [cityId, dispatch],
16
     [cityId, dispatch],
29
     }
29
     }
30
   }, [cityId, toggle, person?.personId])
30
   }, [cityId, toggle, person?.personId])
31
 
31
 
32
+  const show = canShow && firstScreen
33
+
34
+  console.log('------showshow--------->', show)
35
+
32
   return [firstScreen, show, toggle]
36
   return [firstScreen, show, toggle]
33
 }
37
 }

+ 0
- 4
src/pages/index/index.jsx View File

4
 import { ScrollView } from '@tarojs/components'
4
 import { ScrollView } from '@tarojs/components'
5
 import withLayout from '@/layout'
5
 import withLayout from '@/layout'
6
 import ProjectListItem from '@/components/ProjectListItem/index'
6
 import ProjectListItem from '@/components/ProjectListItem/index'
7
-import Adv from '@/components/Adv/index'
8
 import { fetch } from '@/utils/request'
7
 import { fetch } from '@/utils/request'
9
 import { API_BANNER_LIST, API_INDEX_PROJECTS } from '@/constants/api'
8
 import { API_BANNER_LIST, API_INDEX_PROJECTS } from '@/constants/api'
10
 
9
 
54
 
53
 
55
   return (
54
   return (
56
     <view className='Page Index'>
55
     <view className='Page Index'>
57
-
58
-      <Adv show></Adv>
59
-
60
       <ScrollView scroll-y>
56
       <ScrollView scroll-y>
61
         <view className='PageContent'>
57
         <view className='PageContent'>
62
 
58
 

+ 1
- 1
src/utils/login.js View File

40
 
40
 
41
           // 获取人员详细信息
41
           // 获取人员详细信息
42
           // eslint-disable-next-line no-unused-vars
42
           // eslint-disable-next-line no-unused-vars
43
-          queryUserInfo(person.personId).then(info => {
43
+          queryUserInfo().then(info => {
44
             // const { unReadNum } = info
44
             // const { unReadNum } = info
45
 
45
 
46
             // 默认红点开始就有
46
             // 默认红点开始就有

+ 12
- 10
src/utils/request.js View File

91
   const recommender = Taro.getStorageSync('recommender') || ''
91
   const recommender = Taro.getStorageSync('recommender') || ''
92
 
92
 
93
   // 去掉 null 跟 undefined 字段
93
   // 去掉 null 跟 undefined 字段
94
-  const data = Object.keys(payload).reduce((acc, key) => {
95
-    const val = payload[key]
96
-    if (val === null || val === undefined) {
97
-      return acc;
98
-    }
94
+  const data = typeof payload === 'Object'
95
+    ? Object.keys(payload).reduce((acc, key) => {
96
+        const val = payload[key]
97
+        if (val === null || val === undefined) {
98
+          return acc;
99
+        }
99
 
100
 
100
-    return {
101
-      ...acc,
102
-      [key]: val,
103
-    }
104
-  }, {})
101
+        return {
102
+          ...acc,
103
+          [key]: val,
104
+        }
105
+      }, {})
106
+    : payload
105
   
107
   
106
   return [
108
   return [
107
     {
109
     {