Commit 74ebcf2a by 前端

Merge branch 'map_1.1' into 'master'

上线合并

See merge request !6
2 parents 8e3b484c 8b2a91c9
......@@ -75,9 +75,11 @@ Component({
},
getLocationByIp() {
mapApi.getLocationByIp().then(({
city
content: {
address_detail
}
}) => {
let defaultCity = city.replace('市', '')
let defaultCity = address_detail.city.replace('市', '')
this.setData({
defaultCity,
cityCode: defaultCity
......@@ -169,7 +171,7 @@ Component({
}) => {
let distanceList = []
data.elements.map(e => {
let distance = Number((e.distance / 1000)).toFixed(2)
let distance = e.distance.value ? Number((e.distance.value / 1000)).toFixed(2) : 0
distanceList.push(distance)
})
indexGroup[index].map((s, ind) => {
......@@ -212,25 +214,20 @@ Component({
},
openLocation(e) {
let {
item
} = e.currentTarget.dataset
if (!item.distance) {
mapApi.geocoder(item.address).then(({geocodes}) => {
let location = geocodes[0].location.split(',')
wx.openLocation({
longitude: Number(location[0]),
latitude: Number(location[1]),
name: item.storeName,
address: item.address
})
location,
storeName,
address
} = e.currentTarget.dataset.item
mapApi.translate([
[location.latitude, location.longitude]
], 5).then(res => {
let {x,y} = res[0]
wx.openLocation({
latitude: y,
longitude: x,
name: storeName,
address
})
return
}
wx.openLocation({
latitude: Number(item.location.latitude),
longitude: Number(item.location.longitude),
name: item.storeName,
address: item.address
})
},
// 下拉触底
......
......@@ -53,10 +53,12 @@ Component({
defaultBrand
} = this.data
mapApi.getLocationByIp().then(({
city
content: {
address_detail
}
}) => {
if (defaultBrand) return
let defaultCity = city.replace('市', '')
let defaultCity = address_detail.city.replace('市', '')
this.setData({
defaultCity,
cityCode: defaultCity
......@@ -169,10 +171,11 @@ Component({
let {
location
} = defaultStore
if(location.latitude == '0.0') return
mapApi.calculateDistance(fromPosition, [location.latitude, location.longitude]).then(data => {
let {
distance
} = data.elements[0]
} = data.elements
this.setData({
'defaultStore.distance': Number((distance / 1000)).toFixed(2)
})
......@@ -223,7 +226,7 @@ Component({
}) => {
let distanceList = []
data.elements.map(e => {
let distance = Number((e.distance / 1000)).toFixed(2)
let distance = e.distance.value ? Number((e.distance.value / 1000)).toFixed(2) : 0
distanceList.push(distance)
})
indexGroup[index].map((s, ind) => {
......@@ -242,25 +245,39 @@ Component({
openLocation(e) {
let {
item
} = e.currentTarget.dataset
if (!item.distance) {
mapApi.geocoder(item.address).then(({geocodes})=> {
let location = geocodes[0].location.split(',')
wx.openLocation({
longitude: Number(location[0]),
latitude: Number(location[1]),
name: item.storeName,
address: item.address
location,
storeName,
address,
distance
} = e.currentTarget.dataset.item
if (!distance) {
mapApi.geocoder(address).then(({
location:locat
}) => {
mapApi.translate([
[locat.lat, locat.lng]
], 5).then(res => {
let {x,y} = res[0]
wx.openLocation({
latitude: y,
longitude: x,
name: storeName,
address
})
})
})
return
}
wx.openLocation({
latitude: Number(item.location.latitude),
longitude: Number(item.location.longitude),
name: item.storeName,
address: item.address
mapApi.translate([
[location.latitude, location.longitude]
], 5).then(res => {
let {x,y} = res[0]
wx.openLocation({
latitude: y,
longitude: x,
name: storeName,
address
})
})
},
clearData() {
......
......@@ -4,16 +4,16 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"glsk-map-jssdk": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/glsk-map-jssdk/-/glsk-map-jssdk-0.1.1.tgz",
"integrity": "sha512-kwCyU8A1t7Q7V2hlzC03nc9VNNW9HPXQ5YhHsGGnrEtPxykGDG7AEyT5O7LY1zZk/8adkkk6FHgCM53r6p/4yw=="
},
"glsx-applet-component": {
"version": "1.1.24",
"resolved": "https://registry.npmjs.org/glsx-applet-component/-/glsx-applet-component-1.1.24.tgz",
"integrity": "sha512-3XTG9J99rgKVJpcC7aKS/+N7CaS+MNYdy5qmWH8siFaRFiSo1PeBRDaprfjCazaud/c31RvpoDFUof/fxNkxjw=="
},
"glsx-map-sdk": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/glsx-map-sdk/-/glsx-map-sdk-0.2.0.tgz",
"integrity": "sha512-uEFlXvJEDofYjasR4mwkmF5yNTRs5QA2ZAynGPHiKpKdpjQkVFPJH0zGupmQEkxmh4f5B0wPbDobHvLgld7mVw=="
},
"number-precision": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/number-precision/-/number-precision-1.6.0.tgz",
......
......@@ -4,8 +4,8 @@
"description": "",
"main": "app.js",
"dependencies": {
"glsk-map-jssdk": "^0.1.1",
"glsx-applet-component": "^1.1.24",
"glsx-map-sdk": "^0.2.0",
"number-precision": "^1.6.0"
},
"devDependencies": {},
......
import {
equityApi
} from "../../../../api/api"
import mapApi from '../../../../utils/mapapi'
const baseUrl = 'https://img02.glsx.com.cn/weapp/resource/equity-h5-new/mini/'
Page({
......
......@@ -93,14 +93,17 @@ Page({
img_version
} = this.data
const map = wx.createMapContext('map')
mapApi.translate([`${detail.beginGpsLat},${detail.beginGpsLon}`, `${detail.endGpsLat},${detail.endGpsLon}`], 1).then(({
mapApi.translate([
[detail.beginGpsLat, detail.beginGpsLon],
[detail.endGpsLat, detail.endGpsLon]
], 1).then(({
locations
}) => {
let markers = []
let points = []
locations.map((e, index) => {
let latitude = e.lat
let longitude = e.lng
let latitude = e.y
let longitude = e.x
markers.push({
iconPath: `${IMGURL}packageIndex/gps/${index == 0?'begin':'end'}.png?v=${img_version}`,
latitude,
......
......@@ -41,7 +41,7 @@ Page({
rows: [data]
}) => {
data.elements.map((e, index) => {
let distance = Number((e.distance / 1000)).toFixed(2)
let distance = e.distance.value ? Number((e.distance.value / 1000)).toFixed(2) : 0
this.setData({
[`merchantList[${index}].Distance`]: distance
})
......
import { indexApi, mineApi } from "../../../../api/api";
import mapApi from "../../../../utils/mapapi";
Page({
data: {
obj: {
......
import { indexApi, mineApi } from "../../../../api/api";
import mapApi from "../../../../utils/mapapi";
Page({
data: {
desc: "",
......@@ -105,7 +104,6 @@ Page({
store
});
}
// this.getLocationByIp();
this.getGHUserInfo();
},
getGHUserInfo() {
......@@ -118,21 +116,6 @@ Page({
}
});
},
getLocationByIp() {
let storeCode = wx.$util.getStorageSync("srcm_shopmall_store_code");
if (storeCode) {
this.getStore({ storeCode });
} else {
mapApi
.getLocationByIp()
.then(({ city }) => {
this.getStore({ storeName: city });
})
.catch(() => {
this.getStore();
});
}
},
getStore(obj = {}) {
indexApi.getGHStoreList({ pageNum: 1, ...obj }).then((data) => {
if (data.length) {
......
......@@ -76,10 +76,12 @@ Page({
})
} else {
mapApi.getLocationByIp().then(({
city
content: {
address_detail
}
}) => {
this.getStore({
storeName: city
storeName: address_detail.city
})
}).catch(() => {
this.getStore()
......
......@@ -335,26 +335,44 @@ Page({
},
openLocation(e) {
let {
item
} = e.currentTarget.dataset
if (item.location.latitude == '0.0') {
mapApi.geocoder(item.address).then(({
location
location,
storeName,
address,
} = e.currentTarget.dataset.item
if (location.latitude == '0.0') {
mapApi.geocoder(address).then(({
location: locat
}) => {
wx.openLocation({
latitude: Number(location.lat),
longitude: Number(location.lng),
name: item.storeName,
address: item.address
mapApi.translate([
[locat.lat, locat.lng]
], 5).then(res => {
let {
x,
y
} = res[0]
wx.openLocation({
latitude: y,
longitude: x,
name: storeName,
address
})
})
})
return
}
wx.openLocation({
latitude: Number(item.location.latitude),
longitude: Number(item.location.longitude),
name: item.storeName,
address: item.address
mapApi.translate([
[location.latitude, location.longitude]
], 5).then(res => {
let {
x,
y
} = res[0]
wx.openLocation({
latitude: y,
longitude: x,
name: storeName,
address
})
})
},
......
......@@ -82,7 +82,7 @@
通话
</view>
</block>
<block wx:if="{{merchantDetail.merchantAddress}}">
<block wx:if="{{merchantDetail.address}}">
<view class="item flex" bindtap="openLocation" data-item="{{merchantDetail}}">
<view class="sprite-icon icon-mine-gh-gps"></view>
导航
......
......@@ -9,6 +9,13 @@
"miniprogram": {
"list": [
{
"name": "packageEquity/pages/commodity/list/list",
"pathName": "packageMine/pages/address/detail/detail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "pages/tab/index/index",
"pathName": "pages/tab/index/index",
"query": "merchantId=44210895",
......
import GlMap from 'glsx-map-sdk'
import GlMap from 'glsk-map-jssdk'
export default new GlMap()
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!