| @@ -626,7 +626,30 @@ Page({ | |||||
| console.log(error); | console.log(error); | ||||
| }, | }, | ||||
| complete: finish => { | complete: finish => { | ||||
| const latitudeNow = that.data.locateData.latitude | |||||
| const longitudeNow = that.data.locateData.longitude | |||||
| const mallLocationArr = [] | |||||
| let index = 0 | |||||
| that.data.shopList.forEach(item => { | |||||
| const obj = { | |||||
| latitude: item.latitude, | |||||
| longitude: item.longitude, | |||||
| mallTenantId: item.tenantId, | |||||
| index: index | |||||
| } | |||||
| mallLocationArr.push(obj) | |||||
| index++ | |||||
| }) | |||||
| const isBest = [] | |||||
| mallLocationArr.forEach(item => { | |||||
| const num = that.getDistances(latitudeNow, longitudeNow, item.latitude, item.longitude) | |||||
| isBest.push(num.distance_str) | |||||
| }) | |||||
| console.log(isBest, 'isBest'); | |||||
| const winer = isBest.bubbleSort() | |||||
| console.log(winer, 'winer'); | |||||
| } | } | ||||
| }) | }) | ||||
| @@ -667,8 +690,6 @@ Page({ | |||||
| return objData | return objData | ||||
| }, | }, | ||||
| onShow: function () { | onShow: function () { | ||||
| this.mallSync() | this.mallSync() | ||||
| console.log(app.globalData.mouldType, "mouldType") | console.log(app.globalData.mouldType, "mouldType") | ||||
| @@ -1442,4 +1463,16 @@ Page({ | |||||
| } | } | ||||
| }; | }; | ||||
| } | } | ||||
| }); | |||||
| }); | |||||
| Array.prototype.bubbleSort = function () { | |||||
| for (let i = 0; i < this.length - 1; i += 1) { | |||||
| for (let j = 0; j < this.length - 1 - i; j += 1) { | |||||
| if (this[j] > this[j + 1]) { | |||||
| const temp = this[j]; | |||||
| this[j] = this[j + 1]; | |||||
| this[j + 1] = temp; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||