张延森 пре 3 година
родитељ
комит
d79006e78f

+ 2
- 2
config/dev.js Прегледај датотеку

@@ -3,8 +3,8 @@ module.exports = {
3 3
     NODE_ENV: '"development"'
4 4
   },
5 5
   defineConstants: {
6
-    HOST: '"https://xlk.njyz.tech"',
7
-    // HOST: '"http://127.0.0.1:8088"',
6
+    // HOST: '"https://xlk.njyz.tech"',
7
+    HOST: '"http://127.0.0.1:8081"',
8 8
     WSS_HOST: '"wss://xlk.njyz.tech"',
9 9
     OSS_PATH: '"https://zhiyun-image.oss-accelerate.aliyuncs.com/"',
10 10
     OSS_FAST_PATH: '"https://zhiyun-image.oss-accelerate.aliyuncs.com/"',

+ 7
- 2
src/components/Auth/AuthPhone.jsx Прегледај датотеку

@@ -6,10 +6,15 @@ import useAuth from './useAuth'
6 6
 import './style.scss'
7 7
 
8 8
 export default (props) => {
9
-  const { onCancel = (x => x) } = props;
9
+  const {
10
+    consultant,
11
+    router,
12
+    page,
13
+    onCancel = (x => x),
14
+  } = props;
10 15
 
11 16
   const [loading, setLoading] = useState(false)
12
-  const { updatePhoneNumber } = useAuth()
17
+  const { updatePhoneNumber } = useAuth(consultant, router, page)
13 18
 
14 19
   const handlePhoneNumber = (detail) => {
15 20
     const { errMsg, ...data } = detail || {}

+ 15
- 4
src/components/Auth/useAuth.js Прегледај датотеку

@@ -5,7 +5,7 @@ import { dispatchUpdateUserInfo } from '@/actions/user'
5 5
 import { queryUserPhone } from '@/services/user'
6 6
 import { UPDATE_USER_INFO } from '@/constants/user'
7 7
 
8
-export default function useAuth() {
8
+export default function useAuth(consultant, router, page) {
9 9
   const dispatch = useDispatch()
10 10
 
11 11
   const updateUserInfo = useCallback((data) => {
@@ -24,8 +24,19 @@ export default function useAuth() {
24 24
   const updatePhoneNumber = useCallback((data) => {
25 25
     return new Promise((resolve, reject) => {
26 26
       const sessionKey = Taro.getStorageSync('sessionKey')
27
-      Object.assign(data, { sessionKey })
28
-      queryUserPhone(data).then((res) => {
27
+      const { id: targetId, recommender } = router.params
28
+      const buildingId = router.path.indexOf('pages/index/buildingInfo/index') > -1 ? targetId : undefined
29
+      const params = {
30
+        sessionKey,
31
+        sceneId: router.scene,
32
+        buildingId,
33
+        targetId,
34
+        targetType: page.type,
35
+        targetName: page.name,
36
+        promoter: recommender,
37
+        ...data,
38
+      }
39
+      queryUserPhone(params).then((res) => {
29 40
         dispatch({
30 41
           type: UPDATE_USER_INFO,
31 42
           payload: {
@@ -38,7 +49,7 @@ export default function useAuth() {
38 49
         reject(err)
39 50
       })
40 51
     })
41
-  }, [dispatch])
52
+  }, [dispatch, consultant, router, page])
42 53
 
43 54
   return { updateUserInfo, updatePhoneNumber }
44 55
 }

+ 3
- 3
src/constants/api.js Прегледај датотеку

@@ -10,7 +10,7 @@ export const wss_host = WSS_HOST
10 10
 
11 11
 export const pathname = '/api/wx'
12 12
 
13
-const resolvePath = api => `${host + pathname}/${api}`
13
+export const resolvePath = api => `${host + pathname}/${api}`
14 14
 
15 15
 // 特价房源
16 16
 export const API_SPECIAL_ROOM_LIST = resolvePath('buildingSpecialRoom') // 特价房源列表
@@ -145,8 +145,8 @@ export const API_INDEX_SHARE = resolvePath('main/share')
145 145
 
146 146
 export const API_ACTIVITY_FAVOR = resolvePath('activity/save')
147 147
 export const API_NEWS_FAVOR = resolvePath('news/save')
148
-export const API_CARD_FAVOR = resolvePath('card/save')
149
-export const API_PROJECT_FAVOR = resolvePath('project/save')
148
+export const API_CARD_FAVOR = resolvePath('consultant/save')
149
+export const API_PROJECT_FAVOR = resolvePath('building/save')
150 150
 
151 151
 // 埋点接口
152 152
 export const API_BURIED_POINT = resolvePath('taPersonVisitRecord')

+ 4
- 5
src/layout/index.js Прегледај датотеку

@@ -17,15 +17,14 @@ export default (ChildComponent) => (props) => {
17 17
   const { spinning, userInfo } = useSelector(s => s.user)
18 18
   const { person, ...extInfo } = userInfo || {}
19 19
   const router = useRouter()
20
+  const page = routes.filter((r) => (router.path.indexOf(r.page) > -1))[0]
20 21
   const [loading, setLoading] = useState(false)
21
-  const [authPhone, authAvatar] = useAuth(person)
22
+  const [authPhone, authAvatar] = useAuth(person, page)
22 23
 
23
-  
24 24
   // 主要用于埋点
25 25
   useEffect(() => {
26
-    const page = routes.filter((r) => (router.path.indexOf(r.page) > -1))[0]
27 26
     Taro.setStorage({ key: 'page', data: page })
28
-  }, [router.path])
27
+  }, [page])
29 28
 
30 29
   useEffect(() => {
31 30
     setLoading(!person || !person.personId)
@@ -43,7 +42,7 @@ export default (ChildComponent) => (props) => {
43 42
       </Overlay>
44 43
       <Overlay visible={authPhone} aligin='bottom'>
45 44
         <View className='auth-wrapper'>
46
-          <AuthPhone />
45
+          <AuthPhone consultant={consultant} router={router} page={page} />
47 46
         </View>
48 47
       </Overlay>
49 48
       <Overlay visible={!authPhone && authAvatar} aligin='bottom'>

+ 5
- 9
src/layout/useAuth.js Прегледај датотеку

@@ -1,17 +1,13 @@
1 1
 import { useState, useEffect } from 'react'
2
-import { useRouter } from '@tarojs/taro'
3
-import { routes } from '../routes'
4 2
 
5
-export default function useAuth(person) {
3
+export default function useAuth(person, page) {
6 4
   const [authPhone, setAuthPhone] = useState(false)
7 5
   const [authAvatar, setAuthAvatar] = useState(false)
8
-  const { path } = useRouter()
9 6
 
10 7
   useEffect(() => {
11
-    const current = routes.filter((route) => path.indexOf(route.page) > -1)[0]
12
-    if (current && current.auth && current.auth.length) {
8
+    if (page && page.auth && page.auth.length) {
13 9
       // 如果需要授权手机
14
-      if (current.auth.indexOf('phone') > -1) {
10
+      if (page.auth.indexOf('phone') > -1) {
15 11
         if (person.inited && !person.phone) {
16 12
           setAuthPhone(true)
17 13
         } else {
@@ -20,7 +16,7 @@ export default function useAuth(person) {
20 16
       }
21 17
 
22 18
       // 如果需要授权头像
23
-      if (current.auth.indexOf('avatar') > -1) {
19
+      if (page.auth.indexOf('avatar') > -1) {
24 20
         if (person.inited && (!person.avatarurl || person.avatarurl.indexOf('default_avatar') > -1)) {
25 21
           setAuthAvatar(true)
26 22
         } else {
@@ -31,7 +27,7 @@ export default function useAuth(person) {
31 27
       setAuthPhone(false)
32 28
       setAuthAvatar(false)
33 29
     }
34
-  }, [person, path])
30
+  }, [person, page])
35 31
 
36 32
   return [authPhone, authAvatar]
37 33
 }

+ 1
- 1
src/pages/index/buildingDetail/components/BasicInfo/index.jsx Прегледај датотеку

@@ -11,7 +11,7 @@ export default function BasicInfo (props) {
11 11
   const { Info = {} } = props
12 12
   const { buildingId, isSave } = Info
13 13
 
14
-  const [isSaved, handleFavor] = useFavor(isSave)
14
+  const [isSaved, handleFavor] = useFavor(isSave, { id: buildingId, buildingId, eventType: 'building' })
15 15
 
16 16
   const goto = (url) => Taro.navigateTo({ url })
17 17
 

+ 15
- 4
src/pages/index/buildingDetail/components/LivingActivity/index.jsx Прегледај датотеку

@@ -1,11 +1,22 @@
1
-
1
+import Taro from '@tarojs/taro'
2 2
 import { Image } from '@tarojs/components'
3 3
 import '@/assets/css/iconfont.css'
4 4
 import { getImgURL } from '@/utils/image'
5 5
 import './index.scss'
6 6
 
7 7
 export default function LivingActivity (props) {
8
-  const { List = [] } = props
8
+  const { Info = {} } = props
9
+  const List = Info?.liveActivityList || []
10
+
11
+  const gotoList = () => {
12
+    const buildingId = Info?.buildingId
13
+    Taro.switchTab({
14
+      url: `/pages/video/index?buildingId=${buildingId}`
15
+    })
16
+  }
17
+
18
+  const gotoDetail = () => {}
19
+
9 20
   return List.length > 0 ? (
10 21
     <view className='components LivingActivity'>
11 22
 
@@ -13,14 +24,14 @@ export default function LivingActivity (props) {
13 24
         <view className='flex-item'>
14 25
           <text>直播活动</text>
15 26
         </view>
16
-        <text>更多</text>
27
+        <text onClick={gotoList}>更多</text>
17 28
         <text className='iconfont icon-jiantouright'></text>
18 29
       </view>
19 30
 
20 31
       <view className='List flex-h'>
21 32
         {
22 33
           List.map((item, index) => (
23
-            <view className='flex-item' key={`ListItem-${index}`}>
34
+            <view className='flex-item' key={`ListItem-${index}`} onClick={() => gotoDetail(item)}>
24 35
               <view style={{display: item.listImg ? 'block' : 'none'}}>
25 36
                 <Image mode='aspectFill' src={getImgURL(item.listImg)} className='centerLabel'></Image>
26 37
               </view>

+ 34
- 6
src/pages/index/buildingDetail/components/News/index.jsx Прегледај датотеку

@@ -1,26 +1,54 @@
1
-
1
+import { useState, useEffect } from 'react'
2
+import Taro from '@tarojs/taro'
2 3
 import { Image } from '@tarojs/components'
3 4
 import { getImgURL } from '@/utils/image'
5
+import { fetch } from '@/utils/request'
6
+import { API_NEWS_LIST } from '@/constants/api'
4 7
 import '@/assets/css/iconfont.css'
5 8
 import './index.scss'
6 9
 
7 10
 export default function News (props) {
8
-  const { List = [] } = props
9
-  return List.length > 0 ? (
11
+  const { Info = {} } = props
12
+
13
+  const [NewsList, setNewsList] = useState([])
14
+
15
+  const gotoList = () => {
16
+    const buildingId = Info?.buildingId
17
+    Taro.navigateTo({
18
+      url: `/pages/index/newsList/index?buildingId=${buildingId}`
19
+    })
20
+  }
21
+
22
+  const gotoDetail = (item) => {
23
+    Taro.navigateTo({
24
+      url: `/pages/index/newsDetail/index?id=${item.newsId}`
25
+    })
26
+  }
27
+
28
+  useEffect(() => {
29
+    if (Info?.buildingId) {
30
+      // 获取资讯列表
31
+      fetch({ url: API_NEWS_LIST, payload: { buildingId: Info.buildingId, pageSize: 2, pageNum: 1 } }).then((res) => {
32
+        setNewsList(res.records || [])
33
+      })
34
+    }
35
+  }, [Info?.buildingId])
36
+
37
+  return NewsList.length > 0 ? (
10 38
     <view className='components News'>
11 39
 
12 40
       <view className='Title flex-h'>
13 41
         <view className='flex-item'>
14 42
           <text>新鲜资讯</text>
15 43
         </view>
16
-        <text>更多</text>
44
+        <text onClick={gotoList}>更多</text>
17 45
         <text className='iconfont icon-jiantouright'></text>
18 46
       </view>
19 47
 
20 48
       <view className='List flex-h'>
21 49
         {
22
-          List.map((item, index) => (
23
-            <view className='flex-item' key={`ListItem-${index}`}>
50
+          NewsList.map((item, index) => (
51
+            <view className='flex-item' key={`ListItem-${index}`} onClick={() => gotoDetail(item)}>
24 52
               <view className='Img' style={{display: item.newsImg || item.newsName ? 'block' : 'none'}}>
25 53
                 <Image mode='aspectFill' src={getImgURL(item.newsImg)} className='centerLabel'></Image>
26 54
               </view>

+ 9
- 2
src/pages/index/buildingDetail/components/ProjectDynamic/index.jsx Прегледај датотеку

@@ -1,4 +1,5 @@
1 1
 // import React, { useState, useEffect } from 'react'
2
+import Taro from '@tarojs/taro'
2 3
 import '@/assets/css/iconfont.css'
3 4
 import './index.scss'
4 5
 
@@ -7,6 +8,12 @@ export default function ProjectDynamic (props) {
7 8
 
8 9
   const info = List[0]
9 10
 
11
+  const handleClick = () => {
12
+    Taro.navigateTo({
13
+      url: `/pages/index/buildingDynamic/index?id=${info.buildingId}`
14
+    })
15
+  }
16
+
10 17
   return info ? (
11 18
     <view className='components ProjectDynamic'>
12 19
 
@@ -14,11 +21,11 @@ export default function ProjectDynamic (props) {
14 21
         <view className='flex-item'>
15 22
           <text>项目动态</text>
16 23
         </view>
17
-        <text>更多</text>
24
+        <text onClick={handleClick}>更多</text>
18 25
         <text className='iconfont icon-jiantouright'></text>
19 26
       </view>
20 27
 
21
-      <view className='Info'>
28
+      <view className='Info' onClick={handleClick}>
22 29
         <text className='Time'>{info.trendTime}</text>
23 30
         <text className='Title'>{info.trendTitle}</text>
24 31
         <text className='Desc'>{info.trendContent}</text>

+ 4
- 9
src/pages/index/buildingDetail/index.jsx Прегледај датотеку

@@ -1,10 +1,10 @@
1
-import { useState, useEffect, useMemo, useRef } from 'react'
1
+import { useState, useEffect } from 'react'
2 2
 import withLayout from '@/layout'
3 3
 import { ScrollView } from '@tarojs/components'
4 4
 import Disclaimer from '@/components/Disclaimer'
5 5
 import Poster from '@/components/Poster'
6 6
 import { fetch } from '@/utils/request'
7
-import { API_ITEMS_DETAIL, API_NEWS_LIST } from '@/constants/api'
7
+import { API_ITEMS_DETAIL } from '@/constants/api'
8 8
 import DetailBottom from './components/DetailBottom/index'
9 9
 import BuildingDetailBanner from './components/BuildingDetailBanner/index'
10 10
 import BasicInfo from './components/BasicInfo/index'
@@ -30,7 +30,6 @@ export default withLayout((props) => {
30 30
   const [showPoster, setShowPoster] = useState(false)
31 31
   const [DetailInfo, setDetailInfo] = useState({})
32 32
   const [PictureList, setPictureList] = useState([])
33
-  const [NewsList, setNewsList] = useState([])
34 33
 
35 34
   // 本页面分享或者海报参数
36 35
   const paramsRef = useParams(person, DetailInfo)
@@ -55,10 +54,6 @@ export default withLayout((props) => {
55 54
       console.error(err)
56 55
     })
57 56
 
58
-    // 获取资讯列表
59
-    fetch({ url: API_NEWS_LIST, payload: { buildingId: id, pageSize: 2, pageNum: 1 } }).then((res) => {
60
-      setNewsList(res.records || [])
61
-    })
62 57
   }, [id, router.path])
63 58
 
64 59
   return (
@@ -117,12 +112,12 @@ export default withLayout((props) => {
117 112
 
118 113
                 {/* 直播活动 */}
119 114
                 <view className='LivingActivity' style={{minHeight: 0}}>
120
-                  <LivingActivity List={DetailInfo?.liveActivityList}></LivingActivity>
115
+                  <LivingActivity Info={DetailInfo}></LivingActivity>
121 116
                 </view>
122 117
 
123 118
                 {/* 新鲜资讯 */}
124 119
                 <view className='News' style={{minHeight: 0}}>
125
-                  <News List={NewsList}></News>
120
+                  <News Info={DetailInfo}></News>
126 121
                 </view>
127 122
 
128 123
                 {/* 相册 */}

+ 16
- 17
src/utils/hooks/useFavor.js Прегледај датотеку

@@ -1,15 +1,21 @@
1 1
 import { useEffect, useState } from 'react'
2 2
 import Taro from '@tarojs/taro'
3
-import { favorProject, cancelFavorProject } from '@/services/item'
3
+import { fetch } from '@/utils/request'
4
+import { resolvePath } from '@/constants/api'
5
+import track from '@/utils/tracking/track'
4 6
 
5
-export default function(eventType, saved) {
7
+const addFavor = (type, id) => fetch({ url: resolvePath(`${type}/save/${id}`),  method: 'POST' })
8
+const cancelFavor = (type, id) => fetch({ url: resolvePath(`${type}/save/${id}`),  method: 'POST' })
9
+
10
+export default function(saved, options = {}) {
11
+  const { id, eventType } = options
6 12
   const [isSaved, setIsSaved] = useState(saved)
7 13
 
8 14
   useEffect(() => setIsSaved(saved), [saved])
9 15
 
10
-  const handleSave = (buildingId) => {
16
+  const handleSave = () => {
11 17
     if (isSaved) {
12
-      cancelFavorProject(buildingId).then(() => {
18
+      cancelFavor(eventType, id).then(() => {
13 19
         setIsSaved(false)
14 20
         Taro.showToast({
15 21
           title: '已取消收藏',
@@ -17,7 +23,7 @@ export default function(eventType, saved) {
17 23
         })
18 24
       })
19 25
     } else {
20
-      favorProject(buildingId).then(() => {
26
+      addFavor(eventType, id).then(() => {
21 27
         setIsSaved(true)
22 28
         Taro.showToast({
23 29
           title: '收藏成功',
@@ -25,18 +31,11 @@ export default function(eventType, saved) {
25 31
         })
26 32
       })
27 33
     }
28
-    // savePoint({
29
-    //   event: 'save',
30
-    //   eventType: type,
31
-    //   propertyName: '项目收藏',
32
-    //   data: '{}'
33
-    // })
34
+    track({
35
+      event: 'save',
36
+      ...options,
37
+    })
34 38
   }
35 39
 
36
-  switch (eventType) {
37
-    case 'building':
38
-      return [isSaved, handleSave];
39
-    default:
40
-      return [];
41
-  }
40
+  return [isSaved, handleSave];
42 41
 }

+ 5
- 17
src/utils/tracking/share.js Прегледај датотеку

@@ -1,5 +1,5 @@
1 1
 import Taro from '@tarojs/taro'
2
-import { savePoint } from '@/services/common'
2
+import track from './track'
3 3
 import addNum from './addNum'
4 4
 
5 5
 export default (options) => {
@@ -7,25 +7,13 @@ export default (options) => {
7 7
   if (!page) return;
8 8
 
9 9
   const { name: propertyName, type: eventType } = page
10
-  const {
11
-    event = 'share',
12
-    // eventType = '',
13
-    // propertyName = '',
14
-    consultantId = '',
15
-    sharePersonId = '',
16
-    targetId = '',
17
-    buildingId = '',
18
-  } = options
10
+  addNum({ eventType, targetId: options.targetId })
19 11
 
20
-  addNum({ eventType, targetId })
21
-  savePoint({
22
-    event,
12
+  track({
13
+    event: 'share',
23 14
     eventType,
24 15
     propertyName,
25
-    consultantId,
26
-    sharePersonId,
27
-    targetId,
28
-    buildingId,
29 16
     data: '{}',
17
+    ...options,
30 18
   })
31 19
 }

+ 29
- 0
src/utils/tracking/track.js Прегледај датотеку

@@ -0,0 +1,29 @@
1
+import Taro from '@tarojs/taro'
2
+import { savePoint } from '@/services/common'
3
+
4
+export default (options) => {
5
+  const page = Taro.getStorageSync('page')
6
+  if (!page) return;
7
+
8
+  const { name: propertyName, type: eventType } = page
9
+  const {
10
+    event = '',
11
+    // eventType = '',
12
+    // propertyName = '',
13
+    consultantId = '',
14
+    sharePersonId = '',
15
+    targetId = '',
16
+    buildingId = '',
17
+  } = options
18
+
19
+  savePoint({
20
+    event,
21
+    eventType,
22
+    propertyName,
23
+    consultantId,
24
+    sharePersonId,
25
+    targetId,
26
+    buildingId,
27
+    data: '{}',
28
+  })
29
+}