|
@@ -89,76 +89,27 @@ export default class Index extends Component {
|
89
|
89
|
const { cityList, userInfo: { person: { org } } } = this.props
|
90
|
90
|
let defaultCity = cityList.filter(item => {
|
91
|
91
|
return item.id == org.defaultCityId
|
92
|
|
- })
|
93
|
|
-
|
94
|
|
-
|
|
92
|
+ })[0]
|
95
|
93
|
console.log('-----defaultCity-->', defaultCity)
|
|
94
|
+
|
96
|
95
|
Taro.getLocation().then(location => {
|
97
|
96
|
Taro.setStorageSync('lat', location.latitude)
|
98
|
97
|
Taro.setStorageSync('lon', location.longitude)
|
|
98
|
+
|
99
|
99
|
console.log(location, 'location')
|
100
|
100
|
|
101
|
101
|
const payload = { location: `${location.longitude},${location.latitude}` }
|
102
|
|
- console.log(payload, 'payload')
|
103
|
102
|
|
104
|
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
|
107
|
Taro.showToast({
|
111
|
|
- title: `当前定位城市:${res.name}`,
|
|
108
|
+ title: `定位错误: ${err.message}`,
|
112
|
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
|
114
|
}).catch(err => {
|
164
|
115
|
if (err.errMsg === 'getLocation:fail auth deny') {
|
|
@@ -173,13 +124,11 @@ export default class Index extends Component {
|
173
|
124
|
})
|
174
|
125
|
}
|
175
|
126
|
console.error(err)
|
176
|
|
- this.updateCity(defaultCity[0])
|
|
127
|
+ this.updateCity(defaultCity)
|
177
|
128
|
})
|
178
|
129
|
}
|
179
|
130
|
|
180
|
131
|
updateCity (payload) {
|
181
|
|
-
|
182
|
|
-
|
183
|
132
|
this.props.dispatchCitySelected(payload).then(res => {
|
184
|
133
|
this.loadData()
|
185
|
134
|
})
|