Преглед на файлове

Merge branch 'v3.5.1' of http://git.ycjcjy.com/zhiyuxing/miniapp-v3 into v3.5.1

周立森 преди 5 години
родител
ревизия
4cf6d434b2

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

@@ -3,10 +3,10 @@ module.exports = {
3 3
     NODE_ENV: '"production"'
4 4
   },
5 5
   defineConstants: {
6
-    // HOST: '"https://dev.jinchengjiaye.com"',
7
-    // WSS_HOST: '"wss://dev.jinchengjiaye.com"',
8
-    HOST: '"https://lt.pawoma.cn"',
9
-    WSS_HOST: '"wss://lt.pawoma.cn"',
6
+    HOST: '"https://dev.jinchengjiaye.com"',
7
+    WSS_HOST: '"wss://dev.jinchengjiaye.com"',
8
+    // HOST: '"https://lt.pawoma.cn"',
9
+    // WSS_HOST: '"wss://lt.pawoma.cn"',
10 10
   },
11 11
   weapp: {},
12 12
   h5: {}

+ 8
- 1
project.config.json Целия файл

@@ -2,7 +2,7 @@
2 2
 	"miniprogramRoot": "dist/",
3 3
 	"projectname": "mini-chengjiao",
4 4
 	"description": "知与行",
5
-	"appid": "wxd9ee3a9480a4e544",
5
+	"appid": "wxda1f84b79b3edeb3",
6 6
 	"setting": {
7 7
 		"urlCheck": false,
8 8
 		"es6": false,
@@ -59,6 +59,13 @@
59 59
 					"pathName": "pages/activity/detail/assistance",
60 60
 					"query": "id=85",
61 61
 					"scene": null
62
+				},
63
+				{
64
+					"id": -1,
65
+					"name": "pages/project/detail/index",
66
+					"pathName": "pages/project/detail/index",
67
+					"query": "id=93e6d86b8b48e3ea359084e3ceaf2d03",
68
+					"scene": null
62 69
 				}
63 70
 			]
64 71
 		}

BIN
src/assets/icons/marker.png Целия файл


BIN
src/assets/icons/marker_checked.png Целия файл


+ 60
- 0
src/components/amap/PoiAround.js Целия файл

@@ -0,0 +1,60 @@
1
+import Taro, { Component } from '@tarojs/taro'
2
+import { Map } from '@tarojs/components'
3
+
4
+const makerIcon = require('@assets/icons/marker.png')
5
+const makerCheckedIcon = require('@assets/icons/marker_checked.png')
6
+
7
+
8
+export default class PoiAround extends Component {
9
+
10
+  state = {
11
+    current: undefined,
12
+  }
13
+
14
+  markerTap = false
15
+
16
+  handleTap = (e) => {
17
+    const inx = e.markerId
18
+    this.markerTap = true
19
+    this.setState({ current: inx }, () => {
20
+      const marker = this.props.markers.filter((_, i) => i=== inx)[0]
21
+      this.props.onMarkerClick && this.props.onMarkerClick(marker)
22
+    })
23
+  }
24
+
25
+  render() {
26
+    const { current } = this.state
27
+    const markers =  (this.props.markers || []).map((marker, index) => {
28
+      return {
29
+        id: marker.id,
30
+        latitude: marker.latitude,
31
+        longitude: marker.longitude,
32
+        iconPath: index === current && this.markerTap ? makerCheckedIcon : makerIcon,
33
+        width: marker.width,
34
+        height: marker.height,
35
+        alpha: 0.7,
36
+        title: index + 1,
37
+        label: {
38
+          content: index + 1,
39
+          // borderRadius: 1000,
40
+          color: '#fff',
41
+          bgColor: '#f00',
42
+          textAlign: 'center',
43
+        },
44
+      }
45
+    })
46
+
47
+    this.markerTap = false
48
+
49
+    return this.props.longitude && (
50
+      <Map
51
+        showLocation
52
+        scale={12}
53
+        markers={markers}
54
+        longitude={this.props.longitude}
55
+        latitude={this.props.latitude}
56
+        onMarkerTap={this.handleTap}
57
+      />
58
+    )
59
+  }
60
+}

+ 1
- 0
src/lib/amap-wx.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 12
- 14
src/pages/person/index.js Целия файл

@@ -24,6 +24,7 @@ export default class Person extends Component {
24 24
     consultant: false,//置业顾问
25 25
     tourist: false,//普通用户,
26 26
     menus: [],
27
+    roleName: '普通用户',
27 28
   }
28 29
 
29 30
   componentDidShow() {
@@ -34,14 +35,14 @@ export default class Person extends Component {
34 35
 
35 36
   loadUserInfo() {
36 37
     queryUserInfo().then(user => {
38
+      const [roleSetting, roleName] = this.getRoleName(user.personType)
39
+
37 40
       this.setState({
38 41
         user,
39 42
         phone: user.phone,
40
-        menus: menus.map(group => group.filter(x => x.userTypes.indexOf(user.personType) > -1))
41
-      }, () => {
42
-        if (user.personType != ROLE_CODE['CHANNEL_AGENT'] && user.personType != ROLE_CODE['ESTATE_AGENT'] && user.personType != 'Realty Consultant') {
43
-          this.setState({ tourist: true, phone: user.phone })
44
-        }
43
+        menus: menus.map(group => group.filter(x => x.userTypes.indexOf(user.personType) > -1)),
44
+        roleName,
45
+        ...roleSetting,        
45 46
       })
46 47
     })
47 48
   }
@@ -91,16 +92,13 @@ export default class Person extends Component {
91 92
   getRoleName(type) {
92 93
     switch (type) {
93 94
       case ROLE_CODE['CONSULTANT']:
94
-        this.setState({ consultant: true })
95
-        return '置业顾问'
95
+        return [{ consultant: true }, '置业顾问']
96 96
       case ROLE_CODE['ESTATE_AGENT']:
97
-        this.setState({ isAgent: true })
98
-        return '独立经纪人'
97
+        return [{ isAgent: true }, '独立经纪人']
99 98
       case ROLE_CODE['CHANNEL_AGENT']:
100
-        this.setState({ isAgent: true })
101
-        return '渠道经纪人'
99
+        return [{ isAgent: true }, '渠道经纪人']
102 100
       default:
103
-        return '普通用户'
101
+        return [{ tourist: true }, '普通用户']
104 102
     }
105 103
   }
106 104
 
@@ -133,7 +131,7 @@ export default class Person extends Component {
133 131
   }
134 132
 
135 133
   renderDetail() {
136
-    const { user, menus, isAgent, consultant, tourist } = this.state
134
+    const { user, menus, roleName } = this.state
137 135
     // const showQRCode = user.personType === ROLE_CODE['CONSULTANT'] || ROLE_CODE['ESTATE_AGENT'] || ROLE_CODE['CHANNEL_AGENT']
138 136
     // const isConsultant = user.personType == ROLE_CODE['CONSULTANT']
139 137
     // const isConsultant = user.personType
@@ -146,7 +144,7 @@ export default class Person extends Component {
146 144
             <View className="info-block">
147 145
               <View className="avatar" onClick={this.goPersonDetail}>
148 146
                 <Image className="info__headimg" src={user.avatar} />
149
-                <View className="info-intro">{this.getRoleName(user.personType)}</View>
147
+                <View className="info-intro">{roleName}</View>
150 148
               </View>
151 149
 
152 150
               <View className="info-text" onClick={this.goPersonDetail}>

+ 73
- 61
src/pages/project/detail/index.js Целия файл

@@ -4,7 +4,7 @@ import './index.scss'
4 4
 import Banner from '../banner'
5 5
 import HelpGroupBanner from '../swiper'
6 6
 import Poster from './poster'
7
-import ActivityItem from '../../activity/item'
7
+import PoiAround from '@components/amap/PoiAround'
8 8
 import BackHomeBtn from '@components/BackHomeBtn'
9 9
 import {
10 10
   addItemUv,
@@ -20,6 +20,7 @@ import 'dayjs/locale/zh-cn' // 按需加载
20 20
 import ready from '@utils/ready'
21 21
 import Notice from '@components/Notice'
22 22
 import { getDownloadURL, getThumbnail } from '@utils/tools'
23
+import { getPoiAround } from '@utils/amap'
23 24
 import { connect } from '@tarojs/redux'
24 25
 import { dispatchProjectDetail } from '@actions/project'
25 26
 import getUserPhone from '@utils/getUserPhone'
@@ -47,25 +48,8 @@ export default class Index extends Component {
47 48
     helpList: [],
48 49
     groupList: [],
49 50
     statusOpts: ['待定', '在建', '在售'],
50
-    circumOpts: [
51
-      {
52
-        name: '交通',
53
-        id: 'buildingTransport'
54
-      },
55
-      {
56
-        name: '教育',
57
-        id: 'buildingEdu'
58
-      },
59
-      {
60
-        name: '医疗',
61
-        id: 'buildingHospital'
62
-      },
63
-      {
64
-        name: '商业',
65
-        id: 'buildingMall'
66
-      }
67
-    ],
68
-    curTab: 'buildingTransport',
51
+    circumOpts: [],
52
+    curTab: 'Transport',
69 53
     recordId: null,
70 54
     posterShow: 'none',
71 55
     current: 1,
@@ -78,8 +62,7 @@ export default class Index extends Component {
78 62
       const router = Taro.getStorageSync('router')
79 63
       const id = this.$router.params.id || router.query.id
80 64
       // const id='82b54f4a1f5b981df572253792afbfa1' 
81
-      console.info('project-1:', router)
82
-      console.info('project-2:', this.$router)
65
+
83 66
       this.setState({
84 67
         buildingId: id
85 68
       }, () => {
@@ -111,7 +94,16 @@ export default class Index extends Component {
111 94
     const { recordId } = this.state
112 95
     recordId && updatePoint(recordId)
113 96
   }
114
-  loadHelpGroupList () {
97
+
98
+  loadMapAround(building) {
99
+    const [lat, lng] = (building.coordinate || '').split(',')
100
+
101
+    if (!lat || !lng) return Promise.reject()
102
+
103
+    return getPoiAround({ lng, lat})
104
+  }
105
+
106
+  loadHelpGroupList() {
115 107
     const { buildingId } = this.state
116 108
     queryHelpGroup({ buildingId: buildingId }).then(res => {
117 109
       console.log(res, "buildingId")
@@ -132,8 +124,8 @@ export default class Index extends Component {
132 124
     )
133 125
   }
134 126
 
135
-  loadDetail () {
136
-    const { buildingId, circumOpts } = this.state
127
+  loadDetail() {
128
+    const { buildingId } = this.state
137 129
     const { dispatchProjectDetail } = this.props
138 130
     this.setState({
139 131
       loaded: false,
@@ -144,25 +136,32 @@ export default class Index extends Component {
144 136
     })
145 137
 
146 138
     dispatchProjectDetail(buildingId).then(res => {
147
-      circumOpts.map(item => {
148
-        let arr = res[item.id] ? res[item.id].split(',') : []
149
-        item.content = arr
150
-        item.num = arr.length
151
-      })
139
+      this.loadMapAround(res).then(data => {
140
+        const newCircumOpts = data.map((item) => {
141
+          const dtKey = `building${item.key}`
142
+          const manualDt = res[dtKey] ? res[dtKey].split(',') : []
143
+
144
+          return {
145
+            ...item,
146
+            manualDt,
147
+            num: manualDt.length + item.poisData.length
148
+          }
149
+        })
152 150
 
153
-      this.setState({
154
-        loaded: true,
155
-        circumOpts,
156
-        isSaved: res.isSave
157
-      }, () => {
158
-        if (res.posters && res.posters.length) {
159
-          this.setState({
160
-            posterShow: 'flex'
161
-          })
162
-        }
151
+        this.setState({
152
+          loaded: true,
153
+          circumOpts: newCircumOpts,
154
+          isSaved: res.isSave
155
+        }, () => {
156
+          if (res.posters && res.posters.length) {
157
+            this.setState({
158
+              posterShow: 'flex'
159
+            })
160
+          }
161
+        })
162
+
163
+        Taro.hideToast()
163 164
       })
164
-      Taro.hideToast()
165
-      // WxParse.wxParse('article', 'html', res.remark, this.$scope, 0)
166 165
     })
167 166
   }
168 167
 
@@ -490,13 +489,11 @@ export default class Index extends Component {
490 489
     })
491 490
   }
492 491
 
493
-  // changeCurrent (current) {
494
-  //   console.log(current, 'current')
495
-  //   this.setState({
496
-  //     current: current
497
-  //   })
498
-  // }
499
-  renderBottomMenu () {
492
+  handleMarkerTap = (marker) => {
493
+
494
+  }
495
+
496
+  renderBottomMenu() {
500 497
     const { userInfo: { person: { personType } } } = this.props
501 498
     const { posterShow } = this.state
502 499
     return (
@@ -622,7 +619,8 @@ export default class Index extends Component {
622 619
   rendercircum () {
623 620
     const { curTab, circumOpts } = this.state
624 621
     const { projectDetail } = this.props
625
-    const panel = circumOpts.filter(item => item.id === curTab)[0]
622
+    const panel = circumOpts.filter(item => item.key === curTab)[0]
623
+    const [lat, lng] = (projectDetail.coordinate || '').split(',')
626 624
 
627 625
     return (
628 626
       <View className="section circum">
@@ -634,25 +632,39 @@ export default class Index extends Component {
634 632
             {
635 633
               circumOpts.map(item => (
636 634
                 <Text
637
-                  key={item.id}
638
-                  className={curTab === item.id ? 'selected item' : 'item'}
639
-                  onClick={this.HandleCircumTabClick.bind(this, item.id)}>{item.name}({item.num})</Text>
635
+                  key={item.key}
636
+                  className={curTab === item.key ? 'selected item' : 'item'}
637
+                  onClick={this.HandleCircumTabClick.bind(this, item.key)}>{item.label}({item.num})</Text>
640 638
               ))
641 639
             }
642 640
           </View>
643 641
 
644 642
           <View className='map'>
645
-            <Image src={getThumbnail(projectDetail.mapImg)} className='map__img' mode="widthFix"></Image>
643
+            <PoiAround markers={panel.markers} longitude={lng} latitude={lat} onMarkerClick={this.handleMarkerTap}/>
646 644
           </View>
647 645
           <ScrollView className="body" scrollY >
648
-            {
649
-              panel.content.map((text, index) => (
650
-                <View className="row" key={index}>
651
-                  {text}</View>
652
-              ))
653
-            }
646
+            <View class="">
647
+              <View></View>
648
+              {
649
+                panel.poisData.map((poi, inx) => (
650
+                  <View className="row flex" key={`poi-${inx}`}>
651
+                    <View>{inx + 1}</View>
652
+                    <View>{poi.name}</View>
653
+                    <View>{poi.distance} m</View>
654
+                  </View>
655
+                ))
656
+              }
657
+            </View>
658
+            <View class="">              
659
+              <View>其他</View>
660
+              {
661
+                panel.manualDt.map((text, index) => (
662
+                  <View className="row" key={`mt-${index}`}>{text}</View>
663
+                ))
664
+              }
665
+            </View>
654 666
           </ScrollView>
655
-          <Button className='map-more-btn' onClick={this.openMap.bind(this)}>查看全部配套</Button>
667
+          <Button className='map-more-btn' onClick={this.openMap.bind(this)}>立即前往</Button>
656 668
         </View>
657 669
       </View>
658 670
     )

+ 99
- 0
src/utils/amap.js Целия файл

@@ -0,0 +1,99 @@
1
+/**
2
+ * 高德地图
3
+ * 
4
+ * POI 类型下载 https://lbs.amap.com/api/webservice/guide/api/search/#around
5
+ * 
6
+ */
7
+const amapLib = require('../lib/amap-wx');
8
+const myAmapKey = '766411323b66f7e876f428d8a23aa83c'
9
+const amap = new amapLib.AMapWX({ key: myAmapKey })
10
+
11
+// key 值会被拿到 building 表中 组合为字段名
12
+const POI_TYPES = [
13
+  {
14
+    key: 'Transport',
15
+    label: '交通',
16
+    types: ['150100', '150200', '150300', '150400', '150500', '150600'],
17
+  },
18
+  {
19
+    key: 'Mall',
20
+    label: '商业',
21
+    types: ['060100', '060200', '060300', '060400', '060500', '060600',
22
+            '060700', '060800', '060900', '061000', '061100', '061200',
23
+            '061300', '061400', '080100', '080200', '080300', '080400',
24
+            '080500', '080600'],
25
+  },
26
+  {
27
+    key: 'Edu',
28
+    label: '学校',
29
+    types: ['141200'],
30
+  },
31
+  {
32
+    key: 'Hospital',
33
+    label: '医院',
34
+    types: ['090100', '090200', '090300', '090400', '090500', '090600', '090700'],
35
+  },
36
+  {
37
+    key: 'Bank',
38
+    label: '银行',
39
+    types: ['160100'],
40
+  },
41
+  {
42
+    key: 'Restaurant',
43
+    label: '餐饮',
44
+    types: ['050100', '050200', '050300', '050400', '050500', '050600',
45
+            '050700', '050800', '050900'],
46
+  },
47
+]
48
+
49
+const getPrefix = str => str.substr(0, 4)
50
+
51
+export function getPoiAround(params) {
52
+  const {
53
+    lng,
54
+    lat
55
+  } = params || {}
56
+
57
+  return new Promise((resolve, reject) => {
58
+    const querytypes = POI_TYPES.reduce((acc, item) => ([ ...acc, ...item.types ]), []).join('|')
59
+    const location = `${lng},${lat}`
60
+    const iconPath = undefined
61
+    const iconPathSelected = undefined
62
+    const resultList = []
63
+
64
+    // 成功回调
65
+    // https://lbs.amap.com/api/webservice/guide/api/search/#around
66
+    const successCall = poiType => res => {
67
+      resultList.push({
68
+        key: poiType.key,
69
+        label: poiType.label,
70
+        poisData: res.poisData,
71
+        markers: res.markers
72
+      })
73
+
74
+      if (resultList.length === POI_TYPES.length) {
75
+        resolve(resultList)
76
+      }
77
+    }
78
+
79
+    // 失败回调
80
+    // https://lbs.amap.com/api/webservice/guide/tools/info/
81
+    const failCall = poiType => info => {
82
+      console.error(poiType, info)
83
+      reject(info)
84
+    }
85
+
86
+    POI_TYPES.forEach((pt) => {
87
+      const querytypes = pt.types.join('|')
88
+
89
+      amap.getPoiAround({
90
+        querytypes,
91
+        location,
92
+        iconPath,
93
+        iconPathSelected,
94
+        success: successCall(pt),
95
+        fail: failCall(pt),
96
+      })
97
+    })
98
+  })
99
+}