Prechádzať zdrojové kódy

bug修复 【ID1006563】 清运地图路线规划每秒调用上限,采用递归调用修复
【ID1006561】 uni.hideLoading()关闭加载中状态时会同时关闭提示信息。已为提示信息加上延时操作

chenrui 4 rokov pred
rodič
commit
a57599b1f6
2 zmenil súbory, kde vykonal 39 pridanie a 31 odobranie
  1. 15 11
      libs/axios.js
  2. 24 20
      pages/index/map.vue

+ 15 - 11
libs/axios.js

@@ -37,18 +37,22 @@ const request = (opts, hasToken) => {
 					resolve(ret)
 				}else{
 					if(ret.status != '401'){
-						uni.showToast({
-							icon:'none',
-							title: ret.message,
-							mask: true,
-							duration: 5000 
-						})
+						setTimeout(()=>{  //  通过延时避免uni.hideLoading()关闭加载中状态时同时关闭提示信息
+							uni.showToast({
+								icon:'none',
+								title: ret.message,
+								mask: true,
+								duration: 5000 
+							})
+						}, 1000)
 					}else{
-						uni.showToast({
-							icon:'none',
-							title: '未登录或登录已过期,请重新登录',
-							duration: 5000 
-						})
+						setTimeout(()=>{
+							uni.showToast({
+								icon:'none',
+								title: '未登录或登录已过期,请重新登录',
+								duration: 5000 
+							})
+						}, 1000)
 						setTimeout(function() {
 						  const currentRoute = getRoutePath()
 						  const url = `/pages/login/login?lanuch=${currentRoute.lanuch}&path=` + encodeURIComponent(currentRoute.url)

+ 24 - 20
pages/index/map.vue

@@ -133,27 +133,15 @@
 				const _this = this
 				_this.polyline = []
 				//  将所有标注点都按距离进行路线规划
-				_this.distanceMark.map((item,index) => {
-					var position = null
-					if(index==0){
-						position = [
-							{ latitude: _this.latitude, longitude: _this.longitude },
-							{ latitude: item.latitude, longitude: item.longitude }
-						]
-						//  当前位置到第一个标注点的路线规划
-						_this.getDirection(position)
-					}else{
-						position = [
-							{ latitude: _this.distanceMark[index-1].latitude, longitude: _this.distanceMark[index-1].longitude },
-							{ latitude: item.latitude, longitude: item.longitude }
-						]
-						//  第index-1个标注点到第index个标注点的路线规划
-						_this.getDirection(position)
-					}
-				})
+				var position = null
+				position = [
+					{ latitude: _this.latitude, longitude: _this.longitude },
+					{ latitude: _this.distanceMark[0].latitude, longitude: _this.distanceMark[0].longitude }
+				]
+				_this.getDirection(position, 0)
 			},
 			//  路线规划
-			getDirection(position){
+			getDirection(position, ind){
 				const _this = this
 				qqmapsdk.direction({
 					mode: 'driving',//可选值:'driving'(驾车)、'walking'(步行)、'bicycling'(骑行),不填默认:'driving',可不填
@@ -190,7 +178,23 @@
 						console.error(error)
 					},
 					complete: function (res) {
-						// console.log(res)
+						// 腾讯地图使用限制
+						// 为了保证我们的服务稳定,我们对每个key的每个服务接口的调用量做了如下限制:
+						// 日调用量:1万次 / Key
+						// 并发数:5次 / key / 秒
+						
+						//  递归调用避免并发限制
+						if(ind < _this.distanceMark.length-1){
+							let pos = [
+								{ latitude: _this.distanceMark[ind].latitude, longitude: _this.distanceMark[ind].longitude },
+								{ latitude: _this.distanceMark[ind+1].latitude, longitude: _this.distanceMark[ind+1].longitude }
+							]
+							let subInd = ind
+							subInd++
+							setTimeout(()=>{
+								_this.getDirection(pos, subInd)
+							},300)
+						}
 					}
 				})
 			},