Your Name преди 3 години
родител
ревизия
7682cf4e8e

+ 4
- 4
config/prod.js Целия файл

@@ -3,10 +3,10 @@ module.exports = {
3 3
     NODE_ENV: '"production"'
4 4
   },
5 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 10
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
11 11
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
12 12
     ICON_FONT: '"https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/css/iconfont.ttf"',

+ 4
- 1
src/constants/api.js Целия файл

@@ -279,4 +279,7 @@ export const API_BUILDINGSPECIALROOM_BUILDING_LIST = resolvePath('buildingSpecia
279 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 Целия файл

@@ -0,0 +1,21 @@
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 Целия файл

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

+ 2
- 58
src/pages/index/activityDetail/index.jsx Целия файл

@@ -24,6 +24,7 @@ import useShare from "@/utils/hooks/useShare";
24 24
 import useFavor from "@/utils/hooks/useFavor";
25 25
 import { times } from "@/utils/tools";
26 26
 import useStatus from './useStatus'
27
+import CountDown from './CountDown'
27 28
 
28 29
 import "./index.scss";
29 30
 
@@ -113,53 +114,6 @@ export default withLayout((props) => {
113 114
     }
114 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 117
   const handleSignup = () => {
164 118
     setCanChoose("block");
165 119
   };
@@ -268,17 +222,7 @@ export default withLayout((props) => {
268 222
         </view>
269 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 227
       <view className='Apply flex-h'>
284 228
         <view className='Collect' onClick={handleFavor}>

+ 22
- 2
src/pages/index/components/Menu/index.jsx Целия файл

@@ -1,9 +1,14 @@
1
-import { useState } from 'react'
1
+import { useState, useEffect, useRef } from 'react'
2 2
 import { Swiper, SwiperItem, Image } from '@tarojs/components'
3 3
 import Taro from '@tarojs/taro'
4
+import { getSystemParsm } from '@/services/common'
4 5
 import './index.scss'
5 6
 
7
+const MINI_KANGYANG = 'MINI_KANGYANG'
8
+
6 9
 export default function Menu () {
10
+  const kangyangRef = useRef()
11
+
7 12
   const List = [
8 13
     { name: '全部楼盘', id: 1, icon: require('@/assets/index-icon9.png'), router: '/pages/index/buildingList/index' },
9 14
     { name: '品牌地产', id: 2, icon: require('@/assets/index-icon8.png'), router: '/pages/index/brandList/index' },
@@ -14,12 +19,13 @@ export default function Menu () {
14 19
     { name: '活动信息', id: 7, icon: require('@/assets/index-icon5.png'), router: '/pages/index/activityList/index?type=dymic' },
15 20
     { name: '团房信息', id: 8, icon: require('@/assets/index-icon12.png'), router: '/pages/index/activityList/index?type=house' },
16 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 23
     { name: '文旅商办', id: 11, icon: require('@/assets/index-icon13.png'), router: `/pages/index/buildingList/index?isCommerce=1` },
19 24
     { name: '新闻资讯', id: 12, icon: require('@/assets/index-icon15.png'), router: '/pages/index/newsList/index' },
20 25
     { name: '购房百科', id: 13, icon: require('@/assets/index-icon4.png'), router: '/pages/index/encyclopediasOfBuyHouse/index' },
21 26
     { name: '房贷计算', id: 14, icon: require('@/assets/index-icon3.png'), router: '/pages/index/mortgageCalculation/index' }
22 27
   ]
28
+
23 29
   let Arr = []
24 30
   List.map((item) => {
25 31
     if (Arr.length) {
@@ -38,9 +44,23 @@ export default function Menu () {
38 44
     return () => {
39 45
       if (item.router) {
40 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 65
   return (
46 66
     <view className='components Menu'>

+ 1
- 1
src/pages/index/helpToFindHouse/index.jsx Целия файл

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

+ 2
- 1
src/pages/index/index.config.js Целия файл

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

+ 17
- 8
src/pages/index/index.jsx Целия файл

@@ -6,39 +6,48 @@ import withLayout from '@/layout'
6 6
 import ProjectListItem from '@/components/ProjectListItem/index'
7 7
 import { fetch } from '@/utils/request'
8 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 11
 import Location from './components/Location/index'
11 12
 import Banner from './components/Banner/index'
12 13
 import Menu from './components/Menu/index'
13 14
 import HotRecommend from './components/HotRecommend/index'
14 15
 import LiveSale from './components/LiveSale/index'
15 16
 import ColumnTitle from './components/ColumnTitle/index'
17
+import useIndexShareContent from './useIndexShareContent'
16 18
 
17 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 27
   const [BannerList, setBannerList] = useState([])
23 28
   const [ProjectList, setProjectList] = useState([])
24 29
   const [ShowHotRecommend, setShowHotRecommend] = useState(false)
25 30
   const [ShowLive, setShowLive] = useState(false)
31
+  const shareContent = useIndexShareContent(miniApp, paramsRef, router)
32
+
33
+  // 分享
34
+  useShare(shareContent, trackData)
26 35
 
27 36
   useEffect(() => {
28
-    if (city.curCity.name) {
37
+    if (city?.id) {
29 38
       GetBanner()
30 39
       GetProjectList()
31 40
     }
32
-  }, [city])
41
+  }, [city?.id])
33 42
 
34 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 45
       setBannerList(res || [])
37 46
     })
38 47
   }
39 48
 
40 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 51
       setProjectList(res.records || [])
43 52
     })
44 53
   }

+ 31
- 0
src/pages/index/useIndexShareContent.js Целия файл

@@ -0,0 +1,31 @@
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 Целия файл

@@ -10,7 +10,7 @@ import {
10 10
   API_BRAND_LIST,
11 11
   API_BRAND_INFO,
12 12
   API_INDEX_ICONS,
13
-  API_FEEDBACK_SETTING,
13
+  API_SYSTEM_PARAM,
14 14
 } from "@/constants/api";
15 15
 
16 16
 /**
@@ -105,4 +105,9 @@ export const queryBrandList = (params) => fetch({ url: API_BRAND_LIST, params })
105 105
  */
106 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 Целия файл

@@ -1,6 +1,7 @@
1 1
 import { fetch } from '@/utils/request'
2 2
 import {
3
-  API_FEEDBACK_SUBMIT
3
+  API_FEEDBACK_SUBMIT,
4
+  API_FEEDBACK_SETTING,
4 5
 } from '@/constants/api'
5 6
 
6 7
 /**
@@ -8,3 +9,9 @@ import {
8 9
  * @param {*} payload 
9 10
  */
10 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 Целия файл

@@ -1,15 +1,20 @@
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 19
 //例子 getDateFormat(new Date().valueOf(),true,'yyyy/M/d')
15 20
 export function formatDate(dt, fmt) {

+ 18
- 0
src/utils/hooks/useCountDown.js Целия файл

@@ -0,0 +1,18 @@
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 Целия файл

@@ -0,0 +1,14 @@
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 Целия файл

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