Your Name 3 years ago
parent
commit
7682cf4e8e

+ 4
- 4
config/prod.js View File

3
     NODE_ENV: '"production"'
3
     NODE_ENV: '"production"'
4
   },
4
   },
5
   defineConstants: {
5
   defineConstants: {
6
-    HOST: '"https://xlj.newlandsh.com"', //正式
7
-    WSS_HOST: '"wss://xlj.newlandsh.com"',
8
-    // HOST: '"https://xlk.njyz.tech"', //正式
9
-    // WSS_HOST: '"wss://xlk.njyz.tech"',
6
+    // HOST: '"https://xlj.newlandsh.com"', //正式
7
+    // WSS_HOST: '"wss://xlj.newlandsh.com"',
8
+    HOST: '"https://xlk.njyz.tech"', //正式
9
+    WSS_HOST: '"wss://xlk.njyz.tech"',
10
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
10
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
11
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
11
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
12
     ICON_FONT: '"https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/css/iconfont.ttf"',
12
     ICON_FONT: '"https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/css/iconfont.ttf"',

+ 4
- 1
src/constants/api.js View File

279
 export const API_VIDEO_DETAIL = resolvePath('detail')
279
 export const API_VIDEO_DETAIL = resolvePath('detail')
280
 
280
 
281
 // 客服热线
281
 // 客服热线
282
-export const API_FEEDBACK_SETTING = resolvePath('/searchHouse/setting')
282
+export const API_FEEDBACK_SETTING = resolvePath('searchHouse/setting')
283
+
284
+// 系统参数
285
+export const API_SYSTEM_PARAM = resolvePath('sysOrgParams')

+ 21
- 0
src/pages/index/activityDetail/CountDown.jsx View File

1
+import React from 'react'
2
+import useCountDown from '@/utils/hooks/useCountDown'
3
+
4
+export default (props) => {
5
+  const { endTime } = props
6
+  const CountDown = useCountDown(endTime, new Date())
7
+
8
+  return (
9
+    <view className='CountDown'>
10
+      <text>距离结束还有</text>
11
+      <text className='Red'>{CountDown[1]||0}</text>
12
+      <text>天</text>
13
+      <text className='Number' style={{ marginLeft: '40rpx' }}>{CountDown[2]||0}</text>
14
+      <text className='active'>时</text>
15
+      <text className='Number'>{CountDown[3]||0}</text>
16
+      <text className='active'>分</text>
17
+      <text className='Number'>{CountDown[4]||0}</text>
18
+      <text className='active'>秒</text>
19
+    </view>
20
+  )
21
+}

+ 2
- 1
src/pages/index/activityDetail/index.config.js View File

1
 export default {
1
 export default {
2
-  navigationBarTitleText: '活动详情'
2
+  navigationBarTitleText: '活动详情',
3
+  enableShareAppMessage: true
3
 }
4
 }

+ 2
- 58
src/pages/index/activityDetail/index.jsx View File

24
 import useFavor from "@/utils/hooks/useFavor";
24
 import useFavor from "@/utils/hooks/useFavor";
25
 import { times } from "@/utils/tools";
25
 import { times } from "@/utils/tools";
26
 import useStatus from './useStatus'
26
 import useStatus from './useStatus'
27
+import CountDown from './CountDown'
27
 
28
 
28
 import "./index.scss";
29
 import "./index.scss";
29
 
30
 
113
     }
114
     }
114
   }, [id])
115
   }, [id])
115
 
116
 
116
-  const [CountDown, setCountDown] = useState({
117
-    day: 0,
118
-    hours: 0,
119
-    minutes: 0,
120
-    seconds: 0,
121
-  })
122
-
123
-  useEffect(() => {
124
-    if(detail.title) {
125
-      const CountsTime = new Date(detail.enlistEnd).getTime() - Date.now()
126
-      if(CountsTime > 0) {
127
-        SetCountsDown(CountsTime)
128
-      }
129
-    }
130
-  }, [detail])
131
-
132
-  const SetCountsDown = (counts) => {
133
-    let Num = counts - 0
134
-    let Timer = setInterval(() => {
135
-      if(Num) {
136
-        Num -= 1000
137
-        let Time = Num
138
-        let day = Math.floor(Time / 1000 / 60 / 60 / 24)
139
-        Time = Time % (1000 * 60 * 60 * 24) 
140
-        let hours = Math.floor(Time / 1000 / 60 / 60)
141
-        Time = Time % (1000 * 60 * 60) 
142
-        let minutes = Math.floor(Time / 1000 / 60)
143
-        Time = Time % (1000 * 60) 
144
-        let seconds = Math.floor(Time / 1000)
145
-        setCountDown({
146
-          day,
147
-          hours,
148
-          minutes,
149
-          seconds
150
-        })
151
-      } else {
152
-        clearInterval(Timer)
153
-        setCountDown({
154
-          day: 0,
155
-          hours: 0,
156
-          minutes: 0,
157
-          seconds: 0,
158
-        })
159
-      }
160
-    }, 1000)
161
-  }
162
-
163
   const handleSignup = () => {
117
   const handleSignup = () => {
164
     setCanChoose("block");
118
     setCanChoose("block");
165
   };
119
   };
268
         </view>
222
         </view>
269
       </view>
223
       </view>
270
 
224
 
271
-      <view className='CountDown'>
272
-        <text>距离结束还有</text>
273
-        <text className='Red'>{CountDown.day}</text>
274
-        <text>天</text>
275
-        <text className='Number' style={{ marginLeft: '40rpx' }}>{CountDown.hours}</text>
276
-        <text className='active'>时</text>
277
-        <text className='Number'>{CountDown.minutes}</text>
278
-        <text className='active'>分</text>
279
-        <text className='Number'>{CountDown.seconds}</text>
280
-        <text className='active'>秒</text>
281
-      </view>
225
+      <CountDown endTime={detail?.enlistEnd} />
282
 
226
 
283
       <view className='Apply flex-h'>
227
       <view className='Apply flex-h'>
284
         <view className='Collect' onClick={handleFavor}>
228
         <view className='Collect' onClick={handleFavor}>

+ 22
- 2
src/pages/index/components/Menu/index.jsx View File

1
-import { useState } from 'react'
1
+import { useState, useEffect, useRef } from 'react'
2
 import { Swiper, SwiperItem, Image } from '@tarojs/components'
2
 import { Swiper, SwiperItem, Image } from '@tarojs/components'
3
 import Taro from '@tarojs/taro'
3
 import Taro from '@tarojs/taro'
4
+import { getSystemParsm } from '@/services/common'
4
 import './index.scss'
5
 import './index.scss'
5
 
6
 
7
+const MINI_KANGYANG = 'MINI_KANGYANG'
8
+
6
 export default function Menu () {
9
 export default function Menu () {
10
+  const kangyangRef = useRef()
11
+
7
   const List = [
12
   const List = [
8
     { name: '全部楼盘', id: 1, icon: require('@/assets/index-icon9.png'), router: '/pages/index/buildingList/index' },
13
     { name: '全部楼盘', id: 1, icon: require('@/assets/index-icon9.png'), router: '/pages/index/buildingList/index' },
9
     { name: '品牌地产', id: 2, icon: require('@/assets/index-icon8.png'), router: '/pages/index/brandList/index' },
14
     { name: '品牌地产', id: 2, icon: require('@/assets/index-icon8.png'), router: '/pages/index/brandList/index' },
14
     { name: '活动信息', id: 7, icon: require('@/assets/index-icon5.png'), router: '/pages/index/activityList/index?type=dymic' },
19
     { name: '活动信息', id: 7, icon: require('@/assets/index-icon5.png'), router: '/pages/index/activityList/index?type=dymic' },
15
     { name: '团房信息', id: 8, icon: require('@/assets/index-icon12.png'), router: '/pages/index/activityList/index?type=house' },
20
     { name: '团房信息', id: 8, icon: require('@/assets/index-icon12.png'), router: '/pages/index/activityList/index?type=house' },
16
     { name: '特价房', id: 9, icon: require('@/assets/index-icon11.png'), router: '/pages/index/specialPriceHouse/index' },
21
     { name: '特价房', id: 9, icon: require('@/assets/index-icon11.png'), router: '/pages/index/specialPriceHouse/index' },
17
-    { name: '康养', id: 10, icon: require('@/assets/index-icon7.png'), router: '/pages/index/recovered/index' },
22
+    { name: '康养', id: 10, icon: require('@/assets/index-icon7.png'), miniapp: MINI_KANGYANG },
18
     { name: '文旅商办', id: 11, icon: require('@/assets/index-icon13.png'), router: `/pages/index/buildingList/index?isCommerce=1` },
23
     { name: '文旅商办', id: 11, icon: require('@/assets/index-icon13.png'), router: `/pages/index/buildingList/index?isCommerce=1` },
19
     { name: '新闻资讯', id: 12, icon: require('@/assets/index-icon15.png'), router: '/pages/index/newsList/index' },
24
     { name: '新闻资讯', id: 12, icon: require('@/assets/index-icon15.png'), router: '/pages/index/newsList/index' },
20
     { name: '购房百科', id: 13, icon: require('@/assets/index-icon4.png'), router: '/pages/index/encyclopediasOfBuyHouse/index' },
25
     { name: '购房百科', id: 13, icon: require('@/assets/index-icon4.png'), router: '/pages/index/encyclopediasOfBuyHouse/index' },
21
     { name: '房贷计算', id: 14, icon: require('@/assets/index-icon3.png'), router: '/pages/index/mortgageCalculation/index' }
26
     { name: '房贷计算', id: 14, icon: require('@/assets/index-icon3.png'), router: '/pages/index/mortgageCalculation/index' }
22
   ]
27
   ]
28
+
23
   let Arr = []
29
   let Arr = []
24
   List.map((item) => {
30
   List.map((item) => {
25
     if (Arr.length) {
31
     if (Arr.length) {
38
     return () => {
44
     return () => {
39
       if (item.router) {
45
       if (item.router) {
40
         Taro.navigateTo({ url: item.router })
46
         Taro.navigateTo({ url: item.router })
47
+      } else if (item.miniapp === MINI_KANGYANG) {
48
+        if (kangyangRef.current) {
49
+          // 跳转到康养小程序
50
+          Taro.navigateToMiniProgram(kangyangRef.current)
51
+        }
41
       }
52
       }
42
     }
53
     }
43
   }
54
   }
55
+  
56
+  useEffect(() => {
57
+    // 获取康养小程序相关
58
+    getSystemParsm(MINI_KANGYANG).then((res) => {
59
+      if (res && res.paramValue) {
60
+        kangyangRef.current = JSON.parse(res.paramValue)
61
+      }
62
+    })
63
+  }, [])
44
 
64
 
45
   return (
65
   return (
46
     <view className='components Menu'>
66
     <view className='components Menu'>

+ 1
- 1
src/pages/index/helpToFindHouse/index.jsx View File

6
 import '@/assets/css/iconfont.css'
6
 import '@/assets/css/iconfont.css'
7
 import { useSelector } from 'react-redux'
7
 import { useSelector } from 'react-redux'
8
 import AreaPickerView from '@/components/AreaPickerView/index'
8
 import AreaPickerView from '@/components/AreaPickerView/index'
9
-import { getFeedbackSetting } from '@/services/common'
9
+import { getFeedbackSetting } from '@/services/feedback'
10
 import './index.scss'
10
 import './index.scss'
11
 import BuyHouse from './components/BuyHouse/index'
11
 import BuyHouse from './components/BuyHouse/index'
12
 import RentingHouse from './components/RentingHouse/index'
12
 import RentingHouse from './components/RentingHouse/index'

+ 2
- 1
src/pages/index/index.config.js View File

1
 export default {
1
 export default {
2
-  navigationBarTitleText: '新联宝'
2
+  navigationBarTitleText: '新联宝',
3
+  enableShareAppMessage: true
3
 }
4
 }

+ 17
- 8
src/pages/index/index.jsx View File

6
 import ProjectListItem from '@/components/ProjectListItem/index'
6
 import ProjectListItem from '@/components/ProjectListItem/index'
7
 import { fetch } from '@/utils/request'
7
 import { fetch } from '@/utils/request'
8
 import { API_BANNER_LIST, API_INDEX_PROJECTS } from '@/constants/api'
8
 import { API_BANNER_LIST, API_INDEX_PROJECTS } from '@/constants/api'
9
-
9
+import useParams from '@/utils/hooks/useParams'
10
+import useShare from '@/utils/hooks/useShare'
10
 import Location from './components/Location/index'
11
 import Location from './components/Location/index'
11
 import Banner from './components/Banner/index'
12
 import Banner from './components/Banner/index'
12
 import Menu from './components/Menu/index'
13
 import Menu from './components/Menu/index'
13
 import HotRecommend from './components/HotRecommend/index'
14
 import HotRecommend from './components/HotRecommend/index'
14
 import LiveSale from './components/LiveSale/index'
15
 import LiveSale from './components/LiveSale/index'
15
 import ColumnTitle from './components/ColumnTitle/index'
16
 import ColumnTitle from './components/ColumnTitle/index'
17
+import useIndexShareContent from './useIndexShareContent'
16
 
18
 
17
 import './index.scss'
19
 import './index.scss'
18
 
20
 
19
-export default withLayout(() => {
20
-
21
-  const city = useSelector(state => state.city)
21
+export default withLayout((props) => {
22
+  const { city, router, person, trackData, page } = props
23
+  
24
+  // 本页面分享或者海报参数
25
+  const paramsRef = useParams({person, from: `${page.type}_share`})
26
+  const { miniApp } = useSelector(s => s.user.userInfo)
22
   const [BannerList, setBannerList] = useState([])
27
   const [BannerList, setBannerList] = useState([])
23
   const [ProjectList, setProjectList] = useState([])
28
   const [ProjectList, setProjectList] = useState([])
24
   const [ShowHotRecommend, setShowHotRecommend] = useState(false)
29
   const [ShowHotRecommend, setShowHotRecommend] = useState(false)
25
   const [ShowLive, setShowLive] = useState(false)
30
   const [ShowLive, setShowLive] = useState(false)
31
+  const shareContent = useIndexShareContent(miniApp, paramsRef, router)
32
+
33
+  // 分享
34
+  useShare(shareContent, trackData)
26
 
35
 
27
   useEffect(() => {
36
   useEffect(() => {
28
-    if (city.curCity.name) {
37
+    if (city?.id) {
29
       GetBanner()
38
       GetBanner()
30
       GetProjectList()
39
       GetProjectList()
31
     }
40
     }
32
-  }, [city])
41
+  }, [city?.id])
33
 
42
 
34
   const GetBanner = () => { // 获取banner
43
   const GetBanner = () => { // 获取banner
35
-    fetch({ url: `${API_BANNER_LIST}/banner`, method: 'get', payload: { cityId: city.curCity.id, showPosition: 'index' } }).then((res) => {
44
+    fetch({ url: `${API_BANNER_LIST}/banner`, method: 'get', payload: { cityId: city.id, showPosition: 'index' } }).then((res) => {
36
       setBannerList(res || [])
45
       setBannerList(res || [])
37
     })
46
     })
38
   }
47
   }
39
 
48
 
40
   const GetProjectList = () => { // 获取项目列表
49
   const GetProjectList = () => { // 获取项目列表
41
-    fetch({ url: API_INDEX_PROJECTS, method: 'get', payload: { cityId: city.curCity.id, pageNum: 1, pageSize: 10 } }).then((res) => {
50
+    fetch({ url: API_INDEX_PROJECTS, method: 'get', payload: { cityId: city.id, pageNum: 1, pageSize: 10 } }).then((res) => {
42
       setProjectList(res.records || [])
51
       setProjectList(res.records || [])
43
     })
52
     })
44
   }
53
   }

+ 31
- 0
src/pages/index/useIndexShareContent.js View File

1
+import { useRef, useEffect } from 'react'
2
+import { getIndexShare } from '@/services/user'
3
+import { getImgURL } from '@/utils/image'
4
+
5
+export default function useIndexShareContent(miniApp, paramsRef, router) {
6
+  const shareImg = useRef()
7
+  const shareTitle = useRef()
8
+
9
+  useEffect(() => {
10
+    shareTitle.current = `欢迎访问 ${miniApp.name}`
11
+
12
+    // 获取首页分享信息
13
+    getIndexShare().then((res) => {
14
+      const setting = (res || []).filter(x => x.imgType === 'index')[0]
15
+      if (setting) {
16
+        if (setting.imgUrl) {
17
+          shareImg.current = getImgURL(setting.imgUrl)
18
+        }
19
+        if (setting.imgDocument) {
20
+          shareTitle.current = setting.imgDocument
21
+        }
22
+      }
23
+    })
24
+  }, [miniApp.name])
25
+
26
+  return {
27
+    title: shareTitle.current,
28
+    path: `${router.path}?${paramsRef.current}`,
29
+    image: shareImg.current,
30
+  }
31
+}

+ 7
- 2
src/services/common.js View File

10
   API_BRAND_LIST,
10
   API_BRAND_LIST,
11
   API_BRAND_INFO,
11
   API_BRAND_INFO,
12
   API_INDEX_ICONS,
12
   API_INDEX_ICONS,
13
-  API_FEEDBACK_SETTING,
13
+  API_SYSTEM_PARAM,
14
 } from "@/constants/api";
14
 } from "@/constants/api";
15
 
15
 
16
 /**
16
 /**
105
  */
105
  */
106
 export const queryBrandInfo = (id) => fetch({ url: `${API_BRAND_INFO}/${id}`});
106
 export const queryBrandInfo = (id) => fetch({ url: `${API_BRAND_INFO}/${id}`});
107
 
107
 
108
-export const getFeedbackSetting = () => fetch({ url: API_FEEDBACK_SETTING });
108
+/**
109
+ * 获取系统参数
110
+ * @param {*} code 
111
+ * @returns 
112
+ */
113
+export const getSystemParsm = (code) => fetch({ url: `${API_SYSTEM_PARAM}/${code}` })

+ 8
- 1
src/services/feedback.js View File

1
 import { fetch } from '@/utils/request'
1
 import { fetch } from '@/utils/request'
2
 import {
2
 import {
3
-  API_FEEDBACK_SUBMIT
3
+  API_FEEDBACK_SUBMIT,
4
+  API_FEEDBACK_SETTING,
4
 } from '@/constants/api'
5
 } from '@/constants/api'
5
 
6
 
6
 /**
7
 /**
8
  * @param {*} payload 
9
  * @param {*} payload 
9
  */
10
  */
10
 export const submitFeedBack = payload => fetch({ url: API_FEEDBACK_SUBMIT, payload, method: 'POST' })
11
 export const submitFeedBack = payload => fetch({ url: API_FEEDBACK_SUBMIT, payload, method: 'POST' })
12
+
13
+/**
14
+ * 获取帮我找房的相关设置
15
+ * @returns 
16
+ */
17
+export const getFeedbackSetting = () => fetch({ url: API_FEEDBACK_SETTING });

+ 17
- 12
src/utils/chatDate.js View File

1
-/**
2
-* 对Date的扩展,将 Date 转化为指定格式的String。
3
-*
4
-*  月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
5
-*  年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)。
6
-*
7
-*  【示例】:
8
-*  common.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss.S') ==> 2006-07-02 08:09:04.423
9
-*  common.formatDate(new Date(), 'yyyy-M-d h:m:s.S')      ==> 2006-7-2 8:9:4.18
10
-*  common.formatDate(new Date(), 'hh:mm:ss.S')            ==> 08:09:04.423
11
-*  
12
-*/
1
+
2
+
3
+export const MILLISECONDS_A_SECOND = 1e3
4
+export const MILLISECONDS_A_MINUTE = 60 * MILLISECONDS_A_SECOND
5
+export const MILLISECONDS_A_HOUR = 60 * MILLISECONDS_A_MINUTE
6
+export const MILLISECONDS_A_DAY = 24 * MILLISECONDS_A_HOUR
7
+
8
+export const diff = (dt1, dt2) => {
9
+  if (!dt1 || !dt2) return [];
10
+
11
+  const bw = new Date(dt1) - new Date(dt2)
12
+  const day = Math.floor(bw / MILLISECONDS_A_DAY)
13
+  const hour = Math.floor(bw % MILLISECONDS_A_DAY / MILLISECONDS_A_HOUR)
14
+  const min = Math.floor(bw % MILLISECONDS_A_DAY % MILLISECONDS_A_HOUR / MILLISECONDS_A_MINUTE)
15
+  const sec = Math.floor(bw % MILLISECONDS_A_DAY % MILLISECONDS_A_HOUR % MILLISECONDS_A_MINUTE / MILLISECONDS_A_SECOND)
16
+  return [bw, day, hour, min, sec]
17
+}
13
 
18
 
14
 //例子 getDateFormat(new Date().valueOf(),true,'yyyy/M/d')
19
 //例子 getDateFormat(new Date().valueOf(),true,'yyyy/M/d')
15
 export function formatDate(dt, fmt) {
20
 export function formatDate(dt, fmt) {

+ 18
- 0
src/utils/hooks/useCountDown.js View File

1
+import { useState } from "react"
2
+import { diff } from '@/utils/chatDate'
3
+import useInterval from './useInterval'
4
+
5
+/**
6
+ * 倒计时
7
+ * @param {*} date1 
8
+ * @param {*} date2 
9
+ */
10
+export default function useCountDown(date1, date2) {
11
+  const [countdown, setCountDown] = useState([])
12
+
13
+  useInterval(() => {
14
+    setCountDown(diff(date1, date2))
15
+  }, 1000)
16
+
17
+  return countdown
18
+}

+ 14
- 0
src/utils/hooks/useInterval.js View File

1
+import { useEffect, useRef } from "react";
2
+
3
+/**
4
+ * 计时器
5
+ */
6
+export default function useInterval(fn, delay) {
7
+  const callbackRef = useRef()
8
+  callbackRef.current = fn;
9
+
10
+  useEffect(() => {
11
+    const ticker = setInterval(() => callbackRef.current(), delay)
12
+    return () => clearInterval(ticker)
13
+  }, [delay])
14
+}

+ 1
- 1
src/utils/hooks/useParams.js View File

12
   const paramsRef = useRef()
12
   const paramsRef = useRef()
13
   paramsRef.current = useMemo(() => {
13
   paramsRef.current = useMemo(() => {
14
     return [
14
     return [
15
-      `id=${id}`,
15
+      id ? `id=${id}` : undefined, // 非详情页, 比如首页分享的时候, 没有 id
16
       `from=${from}`,
16
       `from=${from}`,
17
       `recommender=${person.personId}`,
17
       `recommender=${person.personId}`,
18
       buildingId ? `buildingId=${buildingId}` : undefined,
18
       buildingId ? `buildingId=${buildingId}` : undefined,