优化测试
This commit is contained in:
@@ -32,11 +32,63 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
onLoad () {
|
||||
uni.setStorageSync('address', {
|
||||
lat: '',
|
||||
lng: '',
|
||||
address: '',
|
||||
weather: '',
|
||||
cityCode: ``
|
||||
})
|
||||
|
||||
this.getLocation()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.$refs?.TabPage?.show()
|
||||
this.$nextTick(() => {
|
||||
this.injectJWeixin(['getLocation', 'previewImage'])
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
getLocation () {
|
||||
this.injectJWeixin(['getLocation']).then(() => {
|
||||
wx.getLocation({
|
||||
type: 'wgs84',
|
||||
success: res => {
|
||||
var lat = res.latitude
|
||||
var lng = res.longitude
|
||||
this.$http.post('/api/appdvcpconfig/apiForward', `https://apis.map.qq.com/ws/geocoder/v1/?location=${lat},${lng}&key=3RZBZ-LZUCF-CT6J5-NWKZH-FCWOQ-UUFKY&get_poi=1`).then(res => {
|
||||
if (res.code === 0) {
|
||||
const data = res.data.result
|
||||
uni.setStorageSync('address', {
|
||||
lat,
|
||||
lng,
|
||||
address: data.address,
|
||||
cityCode: `${data.ad_info.adcode}`
|
||||
})
|
||||
this.getWeather(`${data.ad_info.adcode}`)
|
||||
}
|
||||
})
|
||||
},
|
||||
error: res => {
|
||||
console.log(res)
|
||||
}
|
||||
})
|
||||
}).catch(e => {
|
||||
})
|
||||
},
|
||||
|
||||
getWeather (code) {
|
||||
this.$http.post(`/api/bdweather/wdata?districtId=${code}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
const data = res.data.result.now
|
||||
|
||||
uni.setStorageSync('address', {
|
||||
...uni.getStorageSync('address'),
|
||||
weather: `${data.text} ${data.temp}°` || ''
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -183,17 +183,12 @@
|
||||
this.albumId = query.albumId
|
||||
}
|
||||
|
||||
uni.setStorageSync('address', {
|
||||
lat: '',
|
||||
lng: '',
|
||||
address: '',
|
||||
weather: '',
|
||||
cityCode: ``
|
||||
})
|
||||
this.img = decodeURIComponent(query.url)
|
||||
this.height = uni.getSystemInfoSync().windowHeight
|
||||
|
||||
this.getLocation()
|
||||
if (uni.getStorageSync('address').address) {
|
||||
this.getLocation()
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.getWatermarkList()
|
||||
|
||||
Reference in New Issue
Block a user