Browse Source

代码优化,增加逆地址解析, 初始化修复

zhengJ_docnet 3 months ago
parent
commit
b6eba96bc7
7 changed files with 1155 additions and 24 deletions
  1. 0 1
      README.md
  2. 0 1
      colorui/animation.css
  3. 0 9
      colorui/main.css
  4. 1123 0
      common/utils/qqmap-wx-jssdk.js
  5. 1 1
      manifest.json
  6. 30 11
      pages/index/index.vue
  7. 1 1
      pages/setting/setting.vue

+ 0 - 1
README.md

@@ -1 +0,0 @@
-# uni-app

+ 0 - 1
colorui/animation.css

@@ -1,6 +1,5 @@
 /* 
   Animation 微动画  
-  基于ColorUI组建库的动画模块 by 文晓港 2019年3月26日19:52:28
  */
 
 /* css 滤镜 控制黑白底色gif的 */

+ 0 - 9
colorui/main.css

@@ -1,12 +1,3 @@
-/*
-  ColorUi for uniApp  v2.1.5 | by 文晓港 2019年4月25日18:57:19
-  仅供学习交流,如作它用所承受的法律责任一概与作者无关  
-  
-  *使用ColorUi开发扩展与插件时,请注明基于ColorUi开发 
-  
-  (QQ交流群:240787041)
-*/
-
 /* ==================
         初始化
  ==================== */

File diff suppressed because it is too large
+ 1123 - 0
common/utils/qqmap-wx-jssdk.js


+ 1 - 1
manifest.json

@@ -82,7 +82,7 @@
             "postcss" : true,
             "minified" : true
         },
-        "usingComponents" : true,
+        "usingComponents" : false,
         "permission" : {
             "scope.userLocation" : {
                 "desc" : "获取位置信息,提供最优服务"

+ 30 - 11
pages/index/index.vue

@@ -103,7 +103,6 @@
 			<view class="uni-center">{{text}}</view>
 		</view>
 	</view>
-	
 </template>
 
 <script >
@@ -115,6 +114,11 @@
 	import mpvueGestureLock from '@/components/mpvueGestureLock/index.vue';
 	//#ifdef MP-WEIXIN
 		import amapFile from "@/common/utils/amap-wx.js"
+		import MapWX from "@/common/utils/qqmap-wx-jssdk.js"
+		
+		var qqmapsdk = new MapWX({
+			key: '申请的秘钥' // 必填
+		});
 	//#endif
 	export default {
 		data() {
@@ -154,9 +158,7 @@
 			//#ifdef H5 
 				document.title="首頁"
 			//#endif
-				
 			this.getLocation()
-			
 		},
 		onReady() {
 			console.log("4")
@@ -186,7 +188,7 @@
 			console.log("9")
 		},
 		methods: {
-			...mapMutations(["setPwSta"]),
+			...mapMutations(["setPwSta","setCity"]),
 			// 手势解锁
 			onEnd(data) {
 				console.log(data.join(''))
@@ -197,15 +199,32 @@
 					this.text = "手势不正确"
 				}
 			},
-			// 高德地址逆解析
+			// 逆解析
 			getLocation() {
+				let that = this
 				// 仅支持https
-				uni.getLocation({
-					success: function (res) {
-						console.log(res)
-					}
-				})
-				this.getWether(this.city)
+				//#ifdef MP-WEIXIN
+					uni.getLocation({
+						type:"gcj02",
+						success: function (res) {
+							qqmapsdk.reverseGeocoder({
+								location: res.latitude+","+res.longitude,
+								success: (res)=>{
+									console.log(res.result.ad_info,"--0000000--")
+									that.setCity(res.result.ad_info.district)
+									
+									that.getWether(that.city)
+								},
+								fail: (err)=>{
+									
+								}
+							})
+						}
+					})
+				//#endif
+				//#ifndef MP-WEIXIN
+					this.getWether(this.city)
+				//#endif
 			},
 			// 获取页面数据
 			getWether(key) {

+ 1 - 1
pages/setting/setting.vue

@@ -396,7 +396,7 @@
 							uni.showToast({
 								title: '初始化成功', icon:"none"
 							})
-							
+							this.setTing(that.setting)
 						}
 					}
 				})