|
...
|
...
|
@@ -6,6 +6,7 @@ const {regeneratorRuntime} = global |
|
|
|
const mapScale = 15//18;
|
|
|
|
const def_latitude = 39.684670;
|
|
|
|
const def_longitude = 118.176300;
|
|
|
|
const cates_version = '?1.2';
|
|
|
|
Page({
|
|
|
|
data:{
|
|
|
|
map:{},
|
|
...
|
...
|
@@ -80,6 +81,196 @@ Page({ |
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
debounceTimer:null,
|
|
|
|
debounce(func,wait){
|
|
|
|
if(this.debounceTimer){
|
|
|
|
clearTimeout(this.debounceTimer)
|
|
|
|
}
|
|
|
|
this.debounceTimer=setTimeout(()=>{
|
|
|
|
this.debounceTimer=null;
|
|
|
|
func()
|
|
|
|
},wait);
|
|
|
|
},
|
|
|
|
regionChange(e){
|
|
|
|
if(e.type=='end'){
|
|
|
|
console.log('regionChange', e)
|
|
|
|
this.debounce(this.regionChangeDo,800)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mapCtx:null,
|
|
|
|
mapData: {
|
|
|
|
latitude: 0,
|
|
|
|
longitude: 0,
|
|
|
|
scale: 30,
|
|
|
|
hasRegionchange: false,
|
|
|
|
region: {
|
|
|
|
southwest: {},
|
|
|
|
northeast: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
regionChangeDo(){
|
|
|
|
console.log('regionChangeDo')
|
|
|
|
if(!this.mapCtx){
|
|
|
|
this.mapCtx = wx.createMapContext('map')
|
|
|
|
}
|
|
|
|
if(!this.mapCtx) return;
|
|
|
|
this.mapCtx.getRegion({
|
|
|
|
success: (res) => {
|
|
|
|
this.hasClickMoveToLocation = false
|
|
|
|
if (res.southwest.latitude) {
|
|
|
|
this.mapData.region = res
|
|
|
|
}
|
|
|
|
;
|
|
|
|
this.getSellers();
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
hasSellers:0,
|
|
|
|
sellers:[],
|
|
|
|
getSellers(){
|
|
|
|
console.log('getSellers',this.mapScale,this.mapData)
|
|
|
|
let param = {
|
|
|
|
lat: this.user.latitude == def_latitude ? '' : this.user.latitude,
|
|
|
|
lng: this.user.longitude == def_longitude ? '' : this.user.longitude,
|
|
|
|
offset: 0,
|
|
|
|
rows: 100,
|
|
|
|
distance: 100000,
|
|
|
|
map: JSON.stringify({...this.mapData.region, scale: 50})
|
|
|
|
}
|
|
|
|
if (param.lat) {
|
|
|
|
param.centre_pos = `${param.lat},${param.lng}`
|
|
|
|
} else {
|
|
|
|
let lat = (this.mapData.region.southwest.latitude + this.mapData.region.northeast.latitude) / 2
|
|
|
|
let lng = (this.mapData.region.southwest.longitude + this.mapData.region.northeast.longitude) / 2
|
|
|
|
param.centre_pos = `${lat},${lng}`
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
if (this.data.multiIndex[0] > 0) {
|
|
|
|
param.cuisine = await DA.getCatesID(this.data.multiIndex[0] - 1);
|
|
|
|
}
|
|
|
|
let tags = [];
|
|
|
|
this.data.tags.forEach(t => {
|
|
|
|
if (t.active) {
|
|
|
|
tags.push(t.id)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if (tags.length > 0) {
|
|
|
|
param.tags = tags;
|
|
|
|
}
|
|
|
|
if (param.lat) {
|
|
|
|
param.centre_pos = `${param.lat},${param.lng}`
|
|
|
|
} else {
|
|
|
|
let lat = (this.mapData.region.southwest.latitude + this.mapData.region.northeast.latitude) / 2
|
|
|
|
let lng = (this.mapData.region.southwest.longitude + this.mapData.region.northeast.longitude) / 2
|
|
|
|
param.centre_pos = `${lat},${lng}`
|
|
|
|
}
|
|
|
|
if (this.data.hasSuggestion) {
|
|
|
|
param.centre_pos = `${this.data.suggestion.latitude},${this.data.suggestion.longitude}`
|
|
|
|
}
|
|
|
|
if (this.findSellerData) {
|
|
|
|
param = Object.assign(param, this.findSellerData.paramObj)
|
|
|
|
}
|
|
|
|
if (this.filterParams) {//人均过滤
|
|
|
|
let filterParams = this.filterParams.min + ',' + this.filterParams.max
|
|
|
|
if (this.filterParams.min == this.filterParams.max && this.filterParams.min == 300) {
|
|
|
|
filterParams = this.filterParams.min + ',' + parseInt(new Date() / 1000)
|
|
|
|
}
|
|
|
|
param.average = filterParams
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
//this.selectComponent('#list').getList(param);
|
|
|
|
this.param = param;
|
|
|
|
App.Customer.SellerList(param).then(async res => {
|
|
|
|
if (res.ret == 200) {
|
|
|
|
this.hasSellers=res.data.flag
|
|
|
|
this.sellers=res.data.list
|
|
|
|
this.makeMarker();
|
|
|
|
this.makeSellers();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
makeMarker(){
|
|
|
|
this.mapCtx.getScale({
|
|
|
|
success: (res) => {
|
|
|
|
this.mapData.scale = res.scale;
|
|
|
|
let markers=[]
|
|
|
|
let sellersLength=this.sellers.length
|
|
|
|
this.sellers.forEach((seller,si)=>{
|
|
|
|
let marker = {
|
|
|
|
id: seller.id,
|
|
|
|
iconPath: "http://nosqn.colorcun.com/custom/lite-online/cates/circle1x5.png" + cates_version,
|
|
|
|
latitude: seller.lat,
|
|
|
|
longitude: seller.long,
|
|
|
|
width: 8,
|
|
|
|
height: 8,
|
|
|
|
//title:seller.seller_name,
|
|
|
|
zIndex: sellersLength - si,
|
|
|
|
zIndexBak: sellersLength - si,
|
|
|
|
//seller: seller,
|
|
|
|
};
|
|
|
|
if (seller.mode.length > 0) {
|
|
|
|
seller.mode.forEach(x => {
|
|
|
|
if (x.id == 1) {//大图标
|
|
|
|
marker.iconPath = "http://nosqn.colorcun.com/custom/lite-online/cates/其他菜品.png";
|
|
|
|
if (seller.cate.length > 0) {
|
|
|
|
marker.iconPath = seller.cate[0].icon
|
|
|
|
}
|
|
|
|
marker.iconPath = marker.iconPath.replace(/\/cates\/(.*)\.png/, function ($0, $1) {
|
|
|
|
return '/cates/' + encodeURI($1) + '.png'
|
|
|
|
})
|
|
|
|
marker.iconPath += cates_version
|
|
|
|
marker.width = 20;
|
|
|
|
marker.height = 25;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
markers.push(marker)
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
markers:markers,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
makeSellers(){
|
|
|
|
this.setData({
|
|
|
|
sellers:this.sellers,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
markertap(e){
|
|
|
|
let markers=this.data.markers
|
|
|
|
this.activeSellerID = e.markerId
|
|
|
|
let bl = 1.2;
|
|
|
|
markers.forEach((m, i) => {
|
|
|
|
m.iconPath = m.iconPath.replace('/cates-active/', '/cates/')
|
|
|
|
m.zIndex = m.zIndexBak
|
|
|
|
if (m.width == 20 * bl) {
|
|
|
|
m.width = 20;
|
|
|
|
m.height = 25;
|
|
|
|
}
|
|
|
|
if (m.width == 12) {
|
|
|
|
m.width = 8;
|
|
|
|
m.height = 8;
|
|
|
|
}
|
|
|
|
if (m.id == e.markerId) {
|
|
|
|
m.iconPath = m.iconPath.replace('/cates/', '/cates-active/')
|
|
|
|
if (m.width == 20) {
|
|
|
|
m.width = 20 * bl;
|
|
|
|
m.height = 25 * bl;
|
|
|
|
} else {
|
|
|
|
m.width = 12;
|
|
|
|
m.height = 12;
|
|
|
|
}
|
|
|
|
m.zIndex = 9999
|
|
|
|
}
|
|
|
|
})
|
|
|
|
let obj = {
|
|
|
|
markers: markers,
|
|
|
|
activeSellerID:this.activeSellerID,
|
|
|
|
};
|
|
|
|
this.setData(obj)
|
|
|
|
},
|
|
|
|
back:function() {
|
|
|
|
/*
|
|
|
|
var mta = require('mta-wechat-analysis')
|
...
|
...
|
|