wkyy 3 years ago
parent
commit
d9484d2748
1 changed files with 32 additions and 0 deletions
  1. 32 0
      pages/index/index.vue

+ 32 - 0
pages/index/index.vue

@@ -189,9 +189,15 @@
 </template>
 
 <script>
+	import * as WxJsApi from '@/utils/wxJsApi.js'
+	import MapLoader from '@/utils/AMap'
+	
 	export default {
 		data() {
 			return {
+				longitude: '',
+				latitude: '',
+				message: '',
 				tabbarList: [{
 						iconPath: "home-3-line",
 						selectedIconPath: "home-3-fill",
@@ -219,6 +225,32 @@
 				],
 				current: 0
 			}
+		},
+		onReady() {
+			WxJsApi.getWxConfig(['getLocation','addEventListener']).then((res)=>{
+				// console.log(res)
+			}).catch(error => {
+					console.log(res)
+			})	
+		},
+		methods: {
+			getPoint() {
+				WxJsApi.getLocation().then((res) => {
+					this.latitude = parseFloat(res.latitude);
+					this.longitude = parseFloat(res.longitude);
+					this.message = res.errMsg;
+					
+					if(res.errMsg != 'getLocation:ok') {
+						uni.showToast({
+							title:JSON.stringify(res)
+						})
+					}				
+				}).catch(error => {
+					uni.showToast({
+						title:JSON.stringify(error)
+					})					
+				})
+			},
 		}
 	}
 </script>