From 9d901b4215323c97a00a068cd962f5c9c04dadfa Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期四, 04 九月 2025 10:15:09 +0800
Subject: [PATCH] 前端
---
small-program/App.vue | 93 ++++++++++++++++++++++++++++------------------
1 files changed, 56 insertions(+), 37 deletions(-)
diff --git a/small-program/App.vue b/small-program/App.vue
index f6b779b..bb12718 100644
--- a/small-program/App.vue
+++ b/small-program/App.vue
@@ -1,12 +1,13 @@
<script>
import { mapState } from 'vuex'
+ var QQMapWX = require('@/utils/qqmap-wx-jssdk.js')
export default {
computed: {
...mapState(['userInfo','openid'])
},
- onLaunch: function() {
- // console.log(ua)
+ onLaunch: function() {
var that = this;
+ that.getLocaltionBiz()
if (!this.openid || this.openid =='') {
uni.login({
provider: 'weixin',
@@ -17,17 +18,6 @@
that.$store.commit('setToken', res.data.token)
that.$store.commit('setOpenid', res.data.openid)
that.$store.commit('setUserInfo', res.data.member)
- uni.getLocation({
- type: 'wgs84',
- success: (addr) => {
- that.$store.commit('setPosition', { latitude: addr.latitude, longitude: addr.longitude })
- that.$isResolve()
- },
- fail: (err) => {
- console.error('鑾峰彇浣嶇疆澶辫触', err);
- that.$isResolve()
- }
- });
}
}
@@ -36,32 +26,10 @@
var that = this
let res = this.$u.api.getMemberInfo({}).then(res =>{
if (res && res.code === 200) {
- that.$store.commit('setUserInfo', res.data)
- uni.getLocation({
- type: 'wgs84',
- success: (addr) => {
- that.$store.commit('setPosition', { latitude: addr.latitude, longitude: addr.longitude })
- that.$isResolve()
- },
- fail: (err) => {
- console.error('鑾峰彇浣嶇疆澶辫触', err);
- that.$isResolve()
- }
- });
+ that.$store.commit('setUserInfo', res.data)
} else {
that.$store.commit('setToken','')
- that.$store.commit('setUserInfo',{})
- uni.getLocation({
- type: 'wgs84',
- success: (addr) => {
- that.$store.commit('setPosition', { latitude: addr.latitude, longitude: addr.longitude })
- that.$isResolve()
- },
- fail: (err) => {
- console.error('鑾峰彇浣嶇疆澶辫触', err);
- that.$isResolve()
- }
- });
+ that.$store.commit('setUserInfo',{})
}
})
}
@@ -71,10 +39,61 @@
},
onHide: function() {
console.log('App Hide')
+ },
+ methods:{
+ getLocaltionBiz(){
+ var that =this
+ uni.getLocation({
+ type: 'wgs84',
+ success: (addr) => {
+ const locParam = { latitude: addr.latitude, longitude: addr.longitude };
+ uni.setStorageSync('address', locParam);
+ var address =null
+ const qqmapsdk = new QQMapWX({
+ key: '4PXBZ-JLBC7-LCLXG-P2SZX-C4HYE-LDBLQ' //鑵捐鍦板浘鐢宠鐨刱ey锛堝悗缁渶瑕佸叕鍙告彁渚涳紝涓汉寮�鍙戣�呴搴︽湁闄愶級
+ });
+ // 鑵捐鍦板浘閫嗗湴鐞嗙紪鐮�
+ qqmapsdk.reverseGeocoder({
+ locParam,
+ success: function(res) {
+ console.log(res, '==================鑾峰彇鍦板潃');
+ let info = res.result;
+ locParam.province = info.address_component.province;
+ locParam.city = info.address_component.city;
+ locParam.area = info.address_component.district;
+ locParam.street = info.address_component.street;
+ var ta = info.address || '鍦板潃鑾峰彇澶辫触' ;
+ if(info.formatted_addresses && info.formatted_addresses.recommend){
+ ta =info.formatted_addresses.recommend
+ }
+ locParam.address =ta
+ that.$store.commit('setPosition',locParam)
+ that.$isResolve()
+ },
+ fail: (err) => {
+ console.error('鑾峰彇浣嶇疆澶辫触===========', err);
+ that.$store.commit('setPosition',locParam)
+ that.$isResolve()
+ }
+ });
+ // that.$store.commit('setPosition',locParam)
+ that.$isResolve()
+ },
+ fail: (err) => {
+ console.error('鑾峰彇浣嶇疆澶辫触', err);
+ that.$isResolve()
+ }
+ });
+ }
}
}
</script>
<style lang="scss">
@import "uview-ui/index.scss";
+
+ .toast-custom {
+ width: 500px !important;
+ font-size: 14px !important;
+ }
</style>
\ No newline at end of file
--
Gitblit v1.9.3