From bd6229ebd9cb543a22944ecb1142fad92b675dce Mon Sep 17 00:00:00 2001 From: rk <94314517@qq.com> Date: 星期一, 13 十月 2025 14:26:25 +0800 Subject: [PATCH] bug 修复 --- small-program/App.vue | 112 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 84 insertions(+), 28 deletions(-) diff --git a/small-program/App.vue b/small-program/App.vue index a3cecd4..931fcfe 100644 --- a/small-program/App.vue +++ b/small-program/App.vue @@ -1,48 +1,104 @@ <script> import { mapState } from 'vuex' + var QQMapWX = require('@/utils/qqmap-wx-jssdk.js') export default { computed: { ...mapState(['userInfo','openid']) }, - onLaunch: function() { - var that = this; - if (!this.openid || this.openid =='') { - uni.login({ - provider: 'weixin', - success: async function (loginRes) { - let { code } = loginRes; - let res = await that.$u.api.wxLogin({ code }) - if (res.code === 200) { - that.$store.commit('setToken', res.data.token) - that.$store.commit('setOpenid', res.data.openid) - that.$store.commit('setUserInfo', res.data.member) - that.$isResolve() - } + onLaunch: function() { + var that = this; + if (!this.openid || this.openid =='') { + uni.login({ + provider: 'weixin', + success: async function (loginRes) { + let { code } = loginRes; + let res = await that.$u.api.wxLogin({ code }) + if (res && res.code === 200) { + that.$store.commit('setToken', res.data.token) + that.$store.commit('setOpenid', res.data.openid) + that.$store.commit('setUserInfo', res.data.member) + } - }); - } + } + }); + } else { + var that = this + let res = this.$u.api.getMemberInfo({}).then(res =>{ + if (res && res.code === 200) { + that.$store.commit('setUserInfo', res.data) + } else { + that.$store.commit('setToken','') + that.$store.commit('setUserInfo',{}) + } + }) + } + uni.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage', 'shareTimeline'] + }) + }, onShow: function() { console.log('App Show') - var that =this - let res = this.$u.api.getMemberInfo({}).then(res =>{ - if (res.code ===200) { - that.$store.commit('setUserInfo', res.data) - that.$isResolve() - }else{ - that.$store.commit('setToken','') - that.$store.commit('setUserInfo',{}) - that.$isResolve() - } - }) - + this.getLocaltionBiz() }, 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