| @@ -645,10 +645,10 @@ Page({ | |||||
| const isBest = [] | const isBest = [] | ||||
| mallLocationArr.forEach(item => { | mallLocationArr.forEach(item => { | ||||
| const num = that.getDistances(latitudeNow, longitudeNow, item.latitude, item.longitude) | const num = that.getDistances(latitudeNow, longitudeNow, item.latitude, item.longitude) | ||||
| isBest.push(num.distance_str) | |||||
| isBest.push(num.distance) | |||||
| }) | }) | ||||
| console.log(isBest, 'isBest'); | console.log(isBest, 'isBest'); | ||||
| const winer = isBest.bubbleSort() | |||||
| const winer = this.bloob(isBest) | |||||
| console.log(winer, 'winer'); | console.log(winer, 'winer'); | ||||
| } | } | ||||
| }) | }) | ||||
| @@ -661,9 +661,8 @@ Page({ | |||||
| * @return: distanceObj: { distance , distance_str } | * @return: distanceObj: { distance , distance_str } | ||||
| */ | */ | ||||
| getDistances(lat1, lng1, lat2, lng2) { | getDistances(lat1, lng1, lat2, lng2) { | ||||
| function rad(d) { | |||||
| return d * Math.PI / 180.0; | |||||
| function rad(num) { | |||||
| return num * Math.PI / 180.0; | |||||
| } | } | ||||
| var radLat1 = rad(lat1); | var radLat1 = rad(lat1); | ||||
| var radLat2 = rad(lat2); | var radLat2 = rad(lat2); | ||||
| @@ -690,6 +689,23 @@ Page({ | |||||
| return objData | return objData | ||||
| }, | }, | ||||
| bloob(arr) { | |||||
| const tempArr = arr | |||||
| for (let i = 0; i < tempArr.length - 1; i++) { | |||||
| for (let j = 0; j < tempArr.length - 1 - i; j++) { | |||||
| if (tempArr[j] > tempArr[j + 1]) { | |||||
| let temp = tempArr[j]; | |||||
| tempArr[j] = tempArr[j + 1]; | |||||
| tempArr[j + 1] = temp; | |||||
| } | |||||
| } | |||||
| } | |||||
| return tempArr | |||||
| }, | |||||
| onShow: function () { | onShow: function () { | ||||
| this.mallSync() | this.mallSync() | ||||
| console.log(app.globalData.mouldType, "mouldType") | console.log(app.globalData.mouldType, "mouldType") | ||||