2022-03-08 10:35:29 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="form">
|
|
|
|
|
<component ref="TabPage" :is="component" @change="onChange" :params="params"/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import Tabbar from './components/Tabbar.vue'
|
2022-07-29 09:31:13 +08:00
|
|
|
import { mapActions, mapState } from "vuex"
|
2022-03-08 10:35:29 +08:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'AppCountryAlbum',
|
2022-05-30 14:15:15 +08:00
|
|
|
appName: '工作相册',
|
2022-03-08 10:35:29 +08:00
|
|
|
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
component: 'Tabbar',
|
|
|
|
|
params: {}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
components: {
|
|
|
|
|
Tabbar
|
|
|
|
|
},
|
|
|
|
|
|
2022-07-29 09:05:26 +08:00
|
|
|
onLoad () {
|
|
|
|
|
uni.setStorageSync('address', {
|
|
|
|
|
lat: '',
|
|
|
|
|
lng: '',
|
|
|
|
|
address: '',
|
|
|
|
|
weather: '',
|
|
|
|
|
cityCode: ``
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.getLocation()
|
|
|
|
|
},
|
|
|
|
|
|
2022-03-08 10:35:29 +08:00
|
|
|
onShow() {
|
2022-05-30 15:45:02 +08:00
|
|
|
this.$refs?.TabPage?.show()
|
2022-07-29 09:05:26 +08:00
|
|
|
},
|
|
|
|
|
|
2022-07-29 09:31:13 +08:00
|
|
|
computed: {
|
2022-07-29 09:45:32 +08:00
|
|
|
...mapState(['wxwork'])
|
2022-07-29 09:31:13 +08:00
|
|
|
},
|
|
|
|
|
|
2022-07-29 09:05:26 +08:00
|
|
|
methods: {
|
2022-07-29 09:31:13 +08:00
|
|
|
...mapActions(['injectJWeixin', 'agentSign']),
|
2022-07-29 09:13:56 +08:00
|
|
|
|
|
|
|
|
onChange(e) {
|
|
|
|
|
this.params = e.params
|
|
|
|
|
this.component = e.type
|
|
|
|
|
},
|
|
|
|
|
|
2022-07-29 09:05:26 +08:00
|
|
|
getLocation () {
|
2022-07-29 09:45:32 +08:00
|
|
|
console.log(this.wxwork)
|
2022-07-29 09:31:13 +08:00
|
|
|
this.agentSign({
|
|
|
|
|
corpId: this.wxwork.config.corpId,
|
|
|
|
|
suiteId: this.wxwork.config.suiteId
|
|
|
|
|
}).then(() => {
|
|
|
|
|
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.address = {
|
|
|
|
|
...uni.getStorageSync('address')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.getWeather(`${data.ad_info.adcode}`)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
error: res => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}).catch(e => {
|
2022-07-29 09:05:26 +08:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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}°` || ''
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-03-08 10:35:29 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
</style>
|