张延森 5 years ago
parent
commit
a61ca291fe
3 changed files with 14 additions and 66 deletions
  1. 3
    4
      src/pages/project/album/index.js
  2. 10
    61
      src/pages/project/index.js
  3. 1
    1
      src/pages/project/item/index.js

+ 3
- 4
src/pages/project/album/index.js View File

56
   }
56
   }
57
 
57
 
58
   render () {
58
   render () {
59
-    const { projectDetail: { buildingApartment } } = this.props
59
+    const { projectDetail: { buildingApartment = [] } } = this.props
60
     const list = buildingApartment.filter(item => item.apartmentType === 'photo')
60
     const list = buildingApartment.filter(item => item.apartmentType === 'photo')
61
     const { current } = this.state
61
     const { current } = this.state
62
-    const imgList = list[current].buildingImgList
62
+    const imgList = (list[current] || {}).buildingImgList || []
63
     let _photosImgs = imgList.map(img => img.url)
63
     let _photosImgs = imgList.map(img => img.url)
64
 
64
 
65
-
66
     return (
65
     return (
67
       <View className='photos'>
66
       <View className='photos'>
68
         <ScrollView scrollX>
67
         <ScrollView scrollX>
71
             <View className="around-tab">
70
             <View className="around-tab">
72
               {list.map((item, index) => {
71
               {list.map((item, index) => {
73
                 const { apartmentName } = item || {}
72
                 const { apartmentName } = item || {}
74
-                const buildingImgList = item.buildingImgList
73
+                const buildingImgList = item.buildingImgList || []
75
 
74
 
76
                 console.log(item, '22333333222')
75
                 console.log(item, '22333333222')
77
                 return (<View>
76
                 return (<View>

+ 10
- 61
src/pages/project/index.js View File

89
     const { cityList, userInfo: { person: { org } } } = this.props
89
     const { cityList, userInfo: { person: { org } } } = this.props
90
     let defaultCity = cityList.filter(item => {
90
     let defaultCity = cityList.filter(item => {
91
       return item.id == org.defaultCityId
91
       return item.id == org.defaultCityId
92
-    })
93
-
94
-
92
+    })[0]
95
     console.log('-----defaultCity-->', defaultCity)
93
     console.log('-----defaultCity-->', defaultCity)
94
+
96
     Taro.getLocation().then(location => {
95
     Taro.getLocation().then(location => {
97
       Taro.setStorageSync('lat', location.latitude)
96
       Taro.setStorageSync('lat', location.latitude)
98
       Taro.setStorageSync('lon', location.longitude)
97
       Taro.setStorageSync('lon', location.longitude)
98
+
99
       console.log(location, 'location')
99
       console.log(location, 'location')
100
 
100
 
101
       const payload = { location: `${location.longitude},${location.latitude}` }
101
       const payload = { location: `${location.longitude},${location.latitude}` }
102
-      console.log(payload, 'payload')
103
 
102
 
104
       getLocationCity(payload).then(res => {
103
       getLocationCity(payload).then(res => {
105
-        let cityId = res.id
106
-        let curCity = cityList.filter(item => {
107
-          return item.id == cityId
108
-        })
109
-
104
+        const curCity = res
105
+        this.updateCity(curCity)
106
+      }).catch(err=>{
110
         Taro.showToast({
107
         Taro.showToast({
111
-          title: `当前定位城市:${res.name}`,
108
+          title: `定位错误: ${err.message}`,
112
           icon: 'none',
109
           icon: 'none',
113
         })
110
         })
114
-
115
-        this.updateCity(curCity[0] || defaultCity[0])
116
-        console.log(curCity, 'location')
117
-
118
-
119
-        // this.qqmapsdk.getLocationCity({
120
-
121
-
122
-        //   location,
123
-        //   success: (res) => {
124
-        //     // debugger
125
-        //     let city = res.result.address_component.city
126
-
127
-        //     console.log('-----city-->', city)
128
-        //     console.log('-----cityList-->', cityList)
129
-
130
-
131
-        //     let curCity = cityList.filter(item => {
132
-        //       return item.name == city
133
-        //     })
134
-
135
-
136
-
137
-
138
-        //     Taro.showToast({
139
-        //       title: `当前定位城市:${(curCity[0] || {}).name}`,
140
-        //       icon: 'none',
141
-        //     })
142
-
143
-        //     this.updateCity(curCity[0] || defaultCity[0])
144
-        //   },
145
-        //   fail: (error) => {
146
-
147
-
148
-        //     Taro.showToast({
149
-        //       title: `定位错误: ${error.message}`,
150
-        //       icon: 'none',
151
-        //     })
152
-        //     console.error(err)
153
-        //     this.updateCity(defaultCity[0])
154
-        //   },
155
-      }).catch(err=>{
156
-               Taro.showToast({
157
-              title: `定位错误: ${error.message}`,
158
-              icon: 'none',
159
-            })
160
-            console.error(err)
161
-            this.updateCity(defaultCity[0])
111
+        console.error(err)
112
+        this.updateCity(defaultCity)
162
       })
113
       })
163
     }).catch(err => {
114
     }).catch(err => {
164
       if (err.errMsg === 'getLocation:fail auth deny') {
115
       if (err.errMsg === 'getLocation:fail auth deny') {
173
         })
124
         })
174
       }
125
       }
175
       console.error(err)
126
       console.error(err)
176
-      this.updateCity(defaultCity[0])
127
+      this.updateCity(defaultCity)
177
     })
128
     })
178
   }
129
   }
179
 
130
 
180
   updateCity (payload) {
131
   updateCity (payload) {
181
-
182
-
183
     this.props.dispatchCitySelected(payload).then(res => {
132
     this.props.dispatchCitySelected(payload).then(res => {
184
       this.loadData()
133
       this.loadData()
185
     })
134
     })

+ 1
- 1
src/pages/project/item/index.js View File

20
     const { data, onClick } = this.props
20
     const { data, onClick } = this.props
21
     const { uvList = {}, buildingTag = [], buildingListImg, shareList = {} } = data
21
     const { uvList = {}, buildingTag = [], buildingListImg, shareList = {} } = data
22
     const { records = [], total = 0 } = uvList
22
     const { records = [], total = 0 } = uvList
23
-    const imgSrc = (buildingListImg && buildingListImg[0]) ? buildingListImg[0].url : getThumbnail('https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/images/default.jpg')
23
+    const imgSrc = (buildingListImg && buildingListImg[0]) ? buildingListImg[0].url : 'https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/images/default.jpg'
24
 
24
 
25
     return (
25
     return (
26
       <View className='item' onClick={onClick.bind(this, data)}>
26
       <View className='item' onClick={onClick.bind(this, data)}>