Your Name 3 年 前
コミット
3f9e534fee
共有7 個のファイルを変更した28 個の追加28 個の削除を含む
  1. 6
    10
      src/components/FirstScreen/index.jsx
  2. 0
    0
      src/components/FirstScreen/style.scss
  3. 4
    2
      src/layout/index.js
  4. 5
    1
      src/layout/useScreen.js
  5. 0
    4
      src/pages/index/index.jsx
  6. 1
    1
      src/utils/login.js
  7. 12
    10
      src/utils/request.js

src/components/Adv/index.jsx → src/components/FirstScreen/index.jsx ファイルの表示

@@ -1,29 +1,25 @@
1 1
 import { useState, useEffect } from 'react'
2 2
 import { Image } from '@tarojs/components'
3
+import { getImgURL } from '@/utils/image'
3 4
 import './style.scss'
4 5
 
5 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 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 15
   return (
20
-    <view className='components Adv' style={{display: ShowAdv ? 'block' : 'none'}}>
16
+    <view className='components Adv' style={{display: visible ? 'block' : 'none'}}>
21 17
       <view className='centerLabel'>
22 18
         <view>
23 19
           <view className='Img' onClick={ImgClick}>
24
-            <Image mode='scaleToFill' src={null}></Image>
20
+            <Image mode='scaleToFill' src={getImgURL(info?.image)}></Image>
25 21
           </view>
26
-          <text className='iconfont icon-guanbi' onClick={Close}></text>
22
+          <text className='iconfont icon-guanbi' onClick={onClose}></text>
27 23
         </view>
28 24
       </view>
29 25
     </view>

src/components/Adv/style.scss → src/components/FirstScreen/style.scss ファイルの表示


+ 4
- 2
src/layout/index.js ファイルの表示

@@ -8,6 +8,7 @@ import AuthAvatar from '@/components/Auth/AuthAvatar'
8 8
 import AuthPhone from '@/components/Auth/AuthPhone'
9 9
 import Spin from '@/components/Spin/Spin2'
10 10
 import FixedConsultant from '@/components/FixedConsultant'
11
+import FirstScreen from '@/components/FirstScreen'
11 12
 import { report as reportCustomer } from '@/utils/customer'
12 13
 import { ROLE_CODE } from '@/constants/user'
13 14
 import useAuth from './useAuth'
@@ -18,7 +19,7 @@ import './style.scss'
18 19
 
19 20
 export default (ChildComponent) => (props) => {
20 21
   const consultant = useSelector(s => s.system.consultant)
21
-  const city = useSelector(s => s.city)
22
+  const city = useSelector(s => s.city.curCity)
22 23
   const { spinning, userInfo } = useSelector(s => s.user)
23 24
   const { person, ...extInfo } = userInfo || {}
24 25
   const router = useRouter()
@@ -34,7 +35,7 @@ export default (ChildComponent) => (props) => {
34 35
   // 页面埋点
35 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 41
   useEffect(() => {
@@ -105,6 +106,7 @@ export default (ChildComponent) => (props) => {
105 106
       {
106 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 ファイルの表示

@@ -10,7 +10,7 @@ export default function useScreen(cityId, person) {
10 10
   const dispatch = useDispatch()
11 11
 
12 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 14
   const toggle = useCallback(
15 15
     () => dispatch({ type: 'TOGGLE_FIRSTSCREEN', payload: { cityId } }),
16 16
     [cityId, dispatch],
@@ -29,5 +29,9 @@ export default function useScreen(cityId, person) {
29 29
     }
30 30
   }, [cityId, toggle, person?.personId])
31 31
 
32
+  const show = canShow && firstScreen
33
+
34
+  console.log('------showshow--------->', show)
35
+
32 36
   return [firstScreen, show, toggle]
33 37
 }

+ 0
- 4
src/pages/index/index.jsx ファイルの表示

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

+ 1
- 1
src/utils/login.js ファイルの表示

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

+ 12
- 10
src/utils/request.js ファイルの表示

@@ -91,17 +91,19 @@ export function optionBuilder(options) {
91 91
   const recommender = Taro.getStorageSync('recommender') || ''
92 92
 
93 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 108
   return [
107 109
     {