张延森 3 lat temu
rodzic
commit
292125172a

+ 2
- 2
config/dev.js Wyświetl plik

@@ -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:8088"',
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/"',

+ 12
- 11
package.json Wyświetl plik

@@ -38,27 +38,28 @@
38 38
   "dependencies": {
39 39
     "@babel/runtime": "^7.7.7",
40 40
     "@tarojs/components": "3.2.8",
41
+    "@tarojs/react": "3.2.8",
41 42
     "@tarojs/runtime": "3.2.8",
42 43
     "@tarojs/taro": "3.2.8",
43
-    "redux-logger": "^3.0.6",
44
-    "redux-thunk": "^2.3.0",
45
-    "redux": "^4.0.0",
46
-    "react-redux": "^7.2.0",
44
+    "classnames": "^2.3.1",
45
+    "react": "^17.0.0",
47 46
     "react-dom": "^17.0.0",
48
-    "@tarojs/react": "3.2.8",
49
-    "react": "^17.0.0"
47
+    "react-redux": "^7.2.0",
48
+    "redux": "^4.0.0",
49
+    "redux-logger": "^3.0.6",
50
+    "redux-thunk": "^2.3.0"
50 51
   },
51 52
   "devDependencies": {
52
-    "@types/webpack-env": "^1.13.6",
53
-    "@types/react": "^17.0.2",
54
-    "@tarojs/mini-runner": "3.2.8",
55 53
     "@babel/core": "^7.8.0",
54
+    "@tarojs/mini-runner": "3.2.8",
56 55
     "@tarojs/webpack-runner": "3.2.8",
56
+    "@types/react": "^17.0.2",
57
+    "@types/webpack-env": "^1.13.6",
57 58
     "babel-preset-taro": "3.2.8",
58
-    "eslint-config-taro": "3.2.8",
59 59
     "eslint": "^6.8.0",
60
-    "eslint-plugin-react": "^7.8.2",
60
+    "eslint-config-taro": "3.2.8",
61 61
     "eslint-plugin-import": "^2.12.0",
62
+    "eslint-plugin-react": "^7.8.2",
62 63
     "eslint-plugin-react-hooks": "^4.2.0",
63 64
     "stylelint": "9.3.0"
64 65
   }

+ 1
- 1
src/app.jsx Wyświetl plik

@@ -14,7 +14,7 @@ class App extends Component {
14 14
 
15 15
   componentDidShow (options) {
16 16
     // 保留初始场景
17
-    Taro.setStorage('scene', options.scene)
17
+    Taro.setStorage({ key: 'scene', data: options.scene })
18 18
   }
19 19
 
20 20
   componentDidHide () {}

+ 1
- 1
src/constants/api.js Wyświetl plik

@@ -13,7 +13,7 @@ export const pathname = '/api/wx'
13 13
 const resolvePath = api => `${host + pathname}/${api}`
14 14
 
15 15
 // 特价房源
16
-export const API_SPECIAL_ROOM_LIST = resolvePath('specialRoomList') // 特价房源列表
16
+export const API_SPECIAL_ROOM_LIST = resolvePath('buildingSpecialRoom') // 特价房源列表
17 17
 
18 18
 // 项目动态
19 19
 export const API_PROJECT_TREND_LIST = resolvePath('trendList') // 项目动态

+ 42
- 5
src/pages/index/buildingDetail/components/BasicInfo/index.jsx Wyświetl plik

@@ -1,10 +1,47 @@
1
-
2
-import '@/assets/css/iconfont.css'
1
+import { useState, useEffect } from 'react'
2
+import Taro from '@tarojs/taro'
3 3
 import { ScrollView, Image } from '@tarojs/components'
4
+import classNames from 'classnames'
5
+import { favorProject, cancelFavorProject } from '@/services/item'
6
+import '@/assets/css/iconfont.css'
4 7
 import './index.scss'
5 8
 
6 9
 export default function BasicInfo (props) {
7 10
   const { Info = {} } = props
11
+  const { buildingId, isSave } = Info
12
+
13
+  const [isSaved, setIsSaved] = useState(false)
14
+
15
+  useEffect(() => { setIsSaved(isSave) }, [isSave])
16
+  
17
+  const handleFavor = () => {
18
+    if (isSaved) {
19
+      cancelFavorProject(buildingId).then(() => {
20
+        setIsSaved(false)
21
+        Taro.showToast({
22
+          title: '已取消收藏',
23
+          icon: 'none',
24
+        })
25
+      })
26
+    } else {
27
+      favorProject(buildingId).then(() => {
28
+        setIsSaved(true)
29
+        Taro.showToast({
30
+          title: '收藏成功',
31
+          icon: 'none',
32
+        })
33
+      })
34
+    }
35
+    // savePoint({
36
+    //   event: 'save',
37
+    //   eventType: 'building',
38
+    //   propertyName: '项目收藏',
39
+    //   data: '{}'
40
+    // }).then(res => {
41
+    //   console.log('活动项目收藏')
42
+    // })
43
+  }
44
+
8 45
   return (
9 46
     <view className='components BasicInfo'>
10 47
 
@@ -13,9 +50,9 @@ export default function BasicInfo (props) {
13 50
         <view className='flex-item'>
14 51
           <text>{Info.buildingName}</text>
15 52
         </view>
16
-        <view className='Collect'>
17
-          <text className='iconfont icon-shoucang'></text>
18
-          <text>收藏</text>
53
+        <view className='Collect' onClick={handleFavor}>
54
+          <text className={classNames(['iconfont icon-shoucang'], { active: isSaved })}></text>
55
+          <text>{isSaved ? '取消收藏' : '收藏'}</text>
19 56
         </view>
20 57
       </view>
21 58
 

+ 5
- 1
src/pages/index/buildingDetail/components/BasicInfo/index.scss Wyświetl plik

@@ -17,7 +17,7 @@
17 17
       }
18 18
     }
19 19
     >.Collect {
20
-      width: 80px;
20
+      width: 100px;
21 21
       >text {
22 22
         display: block;
23 23
         text-align: center;
@@ -27,6 +27,10 @@
27 27
           font-size: 40px;
28 28
           line-height: 50px;
29 29
         }
30
+
31
+        &.active {
32
+          color: #F6B61D;
33
+        }
30 34
       }
31 35
     }
32 36
   }

+ 26
- 4
src/pages/index/buildingDetail/components/SpecialPriceHouse/index.jsx Wyświetl plik

@@ -1,10 +1,32 @@
1 1
 import React, { useState, useEffect } from 'react'
2
-import './index.scss'
3
-import '../../../../../assets/css/iconfont.css'
2
+import { API_SPECIAL_ROOM_LIST } from '@/constants/api'
4 3
 import { ScrollView, Image } from '@tarojs/components'
4
+import { fetch } from '@/utils/request'
5
+import '@/assets/css/iconfont.css'
6
+import './index.scss'
5 7
 
6 8
 export default function SpecialPriceHouse (props) {
7
-  const { Data = {} } = props
9
+  const { Info } = props
10
+  const { buildingId } = Info || {}
11
+
12
+  const [list, setList] = useState([])
13
+
14
+  useEffect(() => {
15
+    if (!buildingId) {
16
+      setList([])
17
+      return;
18
+    }
19
+
20
+    fetch({ url: API_SPECIAL_ROOM_LIST, method: 'get', params: { pageSize: 500, buildingId }, showToast: false}).then((res) => {
21
+      const { records } = res || {}
22
+      if (records && records.length) {
23
+        setList(records)
24
+      } else {
25
+        setList([])
26
+      }
27
+    })
28
+  }, [buildingId])
29
+
8 30
   return (
9 31
     <view className='components SpecialPriceHouse'>
10 32
 
@@ -19,7 +41,7 @@ export default function SpecialPriceHouse (props) {
19 41
       <view className='List'>
20 42
         <ScrollView scroll-x={true}>
21 43
           {
22
-            ['', '', '', '', ''].map((item, index) => (
44
+            list.map((item, index) => (
23 45
               <view className='ListItem' key={`List-${index}`}>
24 46
                 <text className='Tips'>省17.8万</text>
25 47
                 <view className='Price'>

+ 1
- 8
src/pages/index/buildingDetail/index.jsx Wyświetl plik

@@ -41,7 +41,6 @@ export default withLayout((props) => {
41 41
   useEffect(() => {
42 42
     if (PersonId) {
43 43
       GetBuildingDetail()
44
-      GetSpecialRoomList()
45 44
       GetProjectTrendList()
46 45
       GetActivityList()
47 46
       GetLiveList()
@@ -65,12 +64,6 @@ export default withLayout((props) => {
65 64
     })
66 65
   }
67 66
 
68
-  const GetSpecialRoomList = () => { // 获取特价房源列表
69
-    fetch({ url: API_SPECIAL_ROOM_LIST, method: 'get' }).then((res) => {
70
-      console.log(res)
71
-    })
72
-  }
73
-
74 67
   const GetProjectTrendList = () => { // 获取项目动态
75 68
     fetch({ url: API_PROJECT_TREND_LIST, method: 'get' }).then((res) => {
76 69
       console.log(res)
@@ -144,7 +137,7 @@ export default withLayout((props) => {
144 137
 
145 138
                 {/* 特价房源 */}
146 139
                 <view className='SpecialPriceHouse'>
147
-                  <SpecialPriceHouse></SpecialPriceHouse>
140
+                  <SpecialPriceHouse Info={DetailInfo}></SpecialPriceHouse>
148 141
                 </view>
149 142
 
150 143
                 {/* 项目动态 */}

+ 1
- 1
src/pages/index/components/Location/index.jsx Wyświetl plik

@@ -13,7 +13,7 @@ export default function Location (props) {
13 13
   }
14 14
 
15 15
   const ToSearch = () => {
16
-    Taro.navigateTo({ url: `/pages/index/buildingSearch/index` })
16
+    Taro.navigateTo({ url: `/pages/index/buildingList/index` })
17 17
   }
18 18
 
19 19
   return (

+ 4
- 2
src/utils/request.js Wyświetl plik

@@ -67,14 +67,16 @@ export const uploadFiles = async (files) => {
67 67
 }
68 68
 
69 69
 export function optionBuilder(options) {
70
-  const { url, payload = {}, method = 'GET', showToast = true, autoLogin = true, header } = options
70
+  const { url, params = {}, payload = {}, method = 'GET', showToast = true, autoLogin = true, header } = options
71 71
   const showMessage = Object.prototype.hasOwnProperty.call(payload, 'showToast') ? payload.showToast : showToast
72 72
   const consultant = Taro.getStorageSync('consultantId') || ''
73 73
   const recommender = Taro.getStorageSync('recommender') || ''
74
+  const queryStr = Object.keys(params).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`).join('&')
75
+  const apiURL = queryStr ? `${url}${url.indexOf('?') > -1 ? '&' : '?'}${queryStr}` : url
74 76
 
75 77
   return [
76 78
     {
77
-      url,
79
+      url: apiURL,
78 80
       method,
79 81
       data: payload,
80 82
       header: {

+ 5
- 0
yarn.lock Wyświetl plik

@@ -3289,6 +3289,11 @@ classnames@^2.2.5:
3289 3289
   resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.1.tgz#dfcfa3891e306ec1dad105d0e88f4417b8535e8e"
3290 3290
   integrity sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==
3291 3291
 
3292
+classnames@^2.3.1:
3293
+  version "2.3.1"
3294
+  resolved "https://registry.npm.taobao.org/classnames/download/classnames-2.3.1.tgz#dfcfa3891e306ec1dad105d0e88f4417b8535e8e"
3295
+  integrity sha1-38+jiR4wbsHa0QXQ6I9EF7hTXo4=
3296
+
3292 3297
 clean-css@4.2.x, clean-css@^4.2.1:
3293 3298
   version "4.2.3"
3294 3299
   resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.3.tgz#507b5de7d97b48ee53d84adb0160ff6216380f78"