|
@@ -13,7 +13,9 @@ Page({
|
|
longitude: "",
|
|
longitude: "",
|
|
// 标记点 当前位置
|
|
// 标记点 当前位置
|
|
markers: [],
|
|
markers: [],
|
|
- isShow: true,
|
|
|
|
|
|
+ nearStoreList: [],
|
|
|
|
+ isShow: false,
|
|
|
|
+ storeId: "",
|
|
storeName: "",
|
|
storeName: "",
|
|
storeAddress: "",
|
|
storeAddress: "",
|
|
distance: ""
|
|
distance: ""
|
|
@@ -23,33 +25,29 @@ Page({
|
|
this.mapCtx = wx.createMapContext('myMap');
|
|
this.mapCtx = wx.createMapContext('myMap');
|
|
this.mapCtx.moveToLocation();
|
|
this.mapCtx.moveToLocation();
|
|
|
|
|
|
|
|
+ let nearStoreList = wx.getStorageSync('nearStoreList') ? JSON.parse(wx.getStorageSync('nearStoreList')) : [];
|
|
|
|
+ this.setData({
|
|
|
|
+ nearStoreList: nearStoreList
|
|
|
|
+ })
|
|
|
|
|
|
let that = this;
|
|
let that = this;
|
|
util.getLocation((lng, lat) => {
|
|
util.getLocation((lng, lat) => {
|
|
util.request(api.NearbyList, { longitude: lng, latitude: lat }).then((res) => {
|
|
util.request(api.NearbyList, { longitude: lng, latitude: lat }).then((res) => {
|
|
let markers = [];
|
|
let markers = [];
|
|
- let marker = {
|
|
|
|
- iconPath: "/static/images/myAddress.png",
|
|
|
|
- id: 0,
|
|
|
|
- latitude: lat,
|
|
|
|
- longitude: lng,
|
|
|
|
- width: 35,
|
|
|
|
- height: 35,
|
|
|
|
- clickable: true,
|
|
|
|
-
|
|
|
|
- };
|
|
|
|
- markers.push(marker);
|
|
|
|
-
|
|
|
|
let nlist = res.data;
|
|
let nlist = res.data;
|
|
- for (var i = 1; i <= nlist.length; i++) {
|
|
|
|
|
|
+ for (var i = 0; i < nlist.length; i++) {
|
|
let marker = {
|
|
let marker = {
|
|
iconPath: "/static/images/address.png",
|
|
iconPath: "/static/images/address.png",
|
|
id: i,
|
|
id: i,
|
|
- latitude: nlist[i-1].latitude,
|
|
|
|
- longitude: nlist[i-1].longitude,
|
|
|
|
|
|
+ latitude: nlist[i].latitude,
|
|
|
|
+ longitude: nlist[i].longitude,
|
|
width: 35,
|
|
width: 35,
|
|
height: 35,
|
|
height: 35,
|
|
- clickable: true
|
|
|
|
|
|
+ clickable: true,
|
|
|
|
+ storeId: nlist[i].id,
|
|
|
|
+ storeName: nlist[i].storeName,
|
|
|
|
+ storeAddress: nlist[i].storeAddress,
|
|
|
|
+ distance: nlist[i].distance
|
|
};
|
|
};
|
|
markers.push(marker);
|
|
markers.push(marker);
|
|
}
|
|
}
|
|
@@ -77,5 +75,55 @@ Page({
|
|
onUnload: function () {
|
|
onUnload: function () {
|
|
// 页面关闭
|
|
// 页面关闭
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+ markersClick: function(res) {
|
|
|
|
+ console.log(res);
|
|
|
|
+ let that = this;
|
|
|
|
+ if (res.markerId == 0) {
|
|
|
|
+ that.setData({
|
|
|
|
+ isShow: false
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let marker = that.data.markers[res.markerId];
|
|
|
|
+ that.setData({
|
|
|
|
+ isShow: true,
|
|
|
|
+ storeId: marker.storeId,
|
|
|
|
+ storeName: marker.storeName,
|
|
|
|
+ storeAddress: marker.storeAddress,
|
|
|
|
+ distance: marker.distance
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ chooseStore(e) {
|
|
|
|
+ console.log(e.currentTarget.id)
|
|
|
|
+ let storeId = e.currentTarget.id;
|
|
|
|
+
|
|
|
|
+ let that = this;
|
|
|
|
+ util.request(api.ChooseStoreId, { storeId: storeId }, 'POST').then(function (res) {
|
|
|
|
+ if (res.errno === 0) {
|
|
|
|
+ wx.setStorageSync('storeId', storeId);
|
|
|
|
+ var item = "";
|
|
|
|
+ for (var i = 0; i < that.data.nearStoreList.length; i++) {
|
|
|
|
+ if (storeId == that.data.nearStoreList[i].id) {
|
|
|
|
+ item = that.data.nearStoreList[i];
|
|
|
|
+ wx.setStorageSync('storeVo', JSON.stringify(item));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var pages = getCurrentPages();
|
|
|
|
+ var currPage = pages[pages.length - 1]; //当前页面
|
|
|
|
+ var prevPage = pages[pages.length - 2]; //上一个页面
|
|
|
|
+
|
|
|
|
+ //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
|
|
|
|
+ prevPage.setData({
|
|
|
|
+ storeName: item.storeName
|
|
|
|
+ })
|
|
|
|
+ prevPage.getIndexData();
|
|
|
|
+ prevPage.enableActivity();
|
|
|
|
+ prevPage.getGroupData();
|
|
|
|
+
|
|
|
|
+ wx.navigateBack()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
})
|
|
})
|