Quellcode durchsuchen

定位到最近的广场

soldDate
HolyKnightIX vor 1 Jahr
Ursprung
Commit
d9a214ff26
2 geänderte Dateien mit 27 neuen und 15 gelöschten Zeilen
  1. +24
    -15
      index/index.js
  2. +3
    -0
      index/index.ttss

+ 24
- 15
index/index.js Datei anzeigen

@@ -158,9 +158,9 @@ Page({
})
},

bindPickerChange(e) {
const index = e.detail.value
const mallTenantId = this.data.shopList[index].tenantId
bindPickerChange(e, indexIn, id) {
const index = indexIn || e.detail.value
const mallTenantId = id || this.data.shopList[index].tenantId
tt.setStorageSync('mallTenantId', mallTenantId)
tt.setStorageSync('mallIndex', index)
this.setData({
@@ -630,8 +630,8 @@ Page({
const longitudeNow = that.data.locateData.longitude

const mallLocationArr = []
let index = 0
that.data.shopList.forEach(item => {
that.data.shopList.forEach((item, index) => {
const obj = {
latitude: item.latitude,
longitude: item.longitude,
@@ -639,17 +639,28 @@ Page({
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)
const tempArr = that.data.shopList
const bloobArr = []
mallLocationArr.forEach((item, index) => {
const distanceData = that.getDistances(latitudeNow, longitudeNow, item.latitude, item.longitude)
tempArr[index].distance = distanceData.distance
bloobArr.push(distanceData.distance)
})
that.setData({
shopList: tempArr
})
const nearestDistance = that.bloob(bloobArr)[0]
const nearestArr = that.data.shopList.filter((item, index) => {
if (item.distance == nearestDistance) {
that.bindPickerChange('', index, item.tenantId)
return true
} else {
return false
}
})
console.log(isBest, 'isBest');
const winer = this.bloob(isBest)
console.log(winer, 'winer');
console.log(nearestArr[0], 'nearestArr');
}
})

@@ -697,9 +708,7 @@ Page({
let temp = tempArr[j];
tempArr[j] = tempArr[j + 1];
tempArr[j + 1] = temp;

}

}
}
return tempArr


+ 3
- 0
index/index.ttss Datei anzeigen

@@ -130,6 +130,9 @@ page {
margin-right: 10rpx;
}

.distance_str {
margin-left: 10rpx;
}

.right {
position: relative;


Laden…
Abbrechen
Speichern