|
...
|
...
|
@@ -131,11 +131,10 @@ Page({ |
|
|
|
if(!this.mapCtx) return;
|
|
|
|
this.mapCtx.getRegion({
|
|
|
|
success: (res) => {
|
|
|
|
this.hasClickMoveToLocation = false
|
|
|
|
if (res.southwest.latitude) {
|
|
|
|
this.mapData.region = res
|
|
|
|
}
|
|
|
|
;
|
|
|
|
this.selectComponent('#filter-group').hide();
|
|
|
|
this.getSellers();
|
|
|
|
},
|
|
|
|
})
|
|
...
|
...
|
@@ -319,1033 +318,4 @@ Page({ |
|
|
|
this.markertap({markerId:this.sellers[idx].id},false)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
back:function() {
|
|
|
|
/*
|
|
|
|
var mta = require('mta-wechat-analysis')
|
|
|
|
import util from '../../utils/util';
|
|
|
|
import App from '../../utils/api';
|
|
|
|
import DA from './data';
|
|
|
|
import reddot from '../../utils/reddot';
|
|
|
|
import PubSub from '../../utils/PubSub'
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
const mapScale = 15//18;
|
|
|
|
const barHeight = 50;
|
|
|
|
const transverseViewHeight = 253 + barHeight;
|
|
|
|
|
|
|
|
const renNum = function () {
|
|
|
|
let arr = []
|
|
|
|
for (let i = 1; i <= 30; i++) {
|
|
|
|
arr.push(i + '位')
|
|
|
|
}
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
const cates_version = '?1.2';
|
|
|
|
const hasSellerConcat = false;//变量存储所有商户
|
|
|
|
const def_latitude = 39.684670;
|
|
|
|
const def_longitude = 118.176300;
|
|
|
|
*/
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
map: {
|
|
|
|
latitude: def_latitude + 0.0001,
|
|
|
|
longitude: def_longitude + 0.0001,
|
|
|
|
scale: mapScale,
|
|
|
|
height: 300,
|
|
|
|
},
|
|
|
|
markers: [],
|
|
|
|
//polygons:{},
|
|
|
|
//sellers:[],
|
|
|
|
multiArray: ['全部菜系'],
|
|
|
|
multiIndex: [0],
|
|
|
|
//scrollIntoView:'',
|
|
|
|
suggestion: {},
|
|
|
|
hasSuggestion: false,//搜索返回
|
|
|
|
current: 0,
|
|
|
|
hasSellers: false,
|
|
|
|
hasGetSellersEnd: false,
|
|
|
|
hasSetActivity: false,
|
|
|
|
tags: [
|
|
|
|
{id: 1, name: '环境好'},
|
|
|
|
{id: 2, name: '菜品有特色'},
|
|
|
|
{id: 3, name: '超大包间'},
|
|
|
|
],
|
|
|
|
listMoreCount: 0,
|
|
|
|
hasSearchLimit: false,
|
|
|
|
hasGetPos: false,
|
|
|
|
},
|
|
|
|
hasClickMoveToLocation: false,//点击回到我的位置
|
|
|
|
hasSellerConcat: hasSellerConcat,
|
|
|
|
transverseViewHeight: transverseViewHeight,//横向滚动高度,苹果要比安卓多20
|
|
|
|
//qqmapsdk:null,
|
|
|
|
sellers: [],
|
|
|
|
sellersIds: [],
|
|
|
|
sellersNow: [],//本次视图内商户
|
|
|
|
searchAddrTop: 50,
|
|
|
|
user: {
|
|
|
|
latitude: def_latitude,
|
|
|
|
longitude: def_longitude,
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
hasOnLoad: false,
|
|
|
|
hasGetLocation: false,//定位信息
|
|
|
|
hasAppHide: false,//app切至后台
|
|
|
|
param: {},
|
|
|
|
onLoad: async function (options) {
|
|
|
|
this.reportTime = new Date()
|
|
|
|
|
|
|
|
this.hasOnLoad = true;
|
|
|
|
// this.qqmapsdk=new QQMapWX({
|
|
|
|
// key: 'SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ'
|
|
|
|
// });
|
|
|
|
this.setData({
|
|
|
|
multiArray: [['全部菜系'].concat(await DA.getCates())]
|
|
|
|
})
|
|
|
|
mta.Page.init({
|
|
|
|
"appID": "500667280",
|
|
|
|
"eventID": "500667287",
|
|
|
|
"statPullDownFresh": true,
|
|
|
|
"statShareApp": true,
|
|
|
|
"statReachBottom": true,
|
|
|
|
"lauchOpts": options, //渠道分析
|
|
|
|
});
|
|
|
|
PubSub.on(
|
|
|
|
'searchParam',
|
|
|
|
data => {
|
|
|
|
console.log('searchParam.msg', data)
|
|
|
|
if (data.fun == 'tagsChange') {
|
|
|
|
this.tagsChange(data.e);
|
|
|
|
}
|
|
|
|
if (data.fun == 'caixiActive') {
|
|
|
|
this.caixiActive(data.e);
|
|
|
|
}
|
|
|
|
if (data.fun == 'setSuggestion') {
|
|
|
|
this.setSuggestion(data.suggestion);
|
|
|
|
}
|
|
|
|
if (data.fun == 'moveToLocation') {
|
|
|
|
this.moveToLocation();
|
|
|
|
}
|
|
|
|
if (data.fun == 'filterEvent') {
|
|
|
|
this.filterEvent(data.e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
PubSub.on(
|
|
|
|
'appHide',
|
|
|
|
data => {
|
|
|
|
console.log('appHide');
|
|
|
|
let pages = getCurrentPages();
|
|
|
|
if (pages.length == 1) {//用户停留在首页
|
|
|
|
this.hasGetLocation = false
|
|
|
|
this.hasClickMoveToLocation = false
|
|
|
|
this.hasAppHide = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
reddot.init()
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
mapCtx: null,
|
|
|
|
mapData: {
|
|
|
|
lat: '',
|
|
|
|
lng: '',
|
|
|
|
latitude: 0,
|
|
|
|
longitude: 0,
|
|
|
|
scale: 18,
|
|
|
|
hasRegionchange: false,
|
|
|
|
region: {
|
|
|
|
southwest: {},
|
|
|
|
northeast: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mapDataLast: null,//最后一次成功视角,防止地图视角丢失
|
|
|
|
onReady: function () {
|
|
|
|
if (wx.canIUse('reportPerformance')) {
|
|
|
|
wx.reportPerformance(2002, new Date() - this.reportTime)
|
|
|
|
}
|
|
|
|
this.mapCtx = wx.createMapContext('map')
|
|
|
|
// this.mapCtx.moveToLocation({
|
|
|
|
// success:(res)=>{
|
|
|
|
// console.log('moveToLocation',res)
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: async function (e) {
|
|
|
|
if (typeof this.getTabBar === 'function' &&
|
|
|
|
this.getTabBar()) {
|
|
|
|
this.getTabBar().setData({
|
|
|
|
selected: 0
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log({
|
|
|
|
'this.hasGetLocation': this.hasGetLocation,
|
|
|
|
'this.hasOnLoad': this.hasOnLoad,
|
|
|
|
'this.hasClickMoveToLocation': this.hasClickMoveToLocation,
|
|
|
|
'this.data.hasSuggestion': this.data.hasSuggestion,
|
|
|
|
})
|
|
|
|
this.getClassNameFlag = true;
|
|
|
|
//this.getPos();
|
|
|
|
if (this.data.hasSuggestion) return;
|
|
|
|
if (!this.hasOnLoad && this.hasGetLocation) return;
|
|
|
|
this.hasOnLoad = false;
|
|
|
|
//导航栏自适应
|
|
|
|
let systemInfo = wx.getSystemInfoSync();
|
|
|
|
console.log('systemInfo:', systemInfo)
|
|
|
|
let reg = /ios/i;
|
|
|
|
let pt = 20;//导航状态栏上内边距
|
|
|
|
let h = 44;//导航状态栏高度
|
|
|
|
if (reg.test(systemInfo.system)) {
|
|
|
|
pt = systemInfo.statusBarHeight;
|
|
|
|
h = 44;
|
|
|
|
if (systemInfo.pixelRatio > 2) {
|
|
|
|
this.transverseViewHeight = transverseViewHeight + 26;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (/xiaomi/i.test(systemInfo.brand)) {
|
|
|
|
this.transverseViewHeight = transverseViewHeight + 15;
|
|
|
|
} else {
|
|
|
|
this.transverseViewHeight = transverseViewHeight - 15;
|
|
|
|
}
|
|
|
|
pt = systemInfo.statusBarHeight;
|
|
|
|
h = 48;
|
|
|
|
}
|
|
|
|
console.log('onShow', systemInfo, systemInfo.windowHeight, systemInfo.windowHeight - this.transverseViewHeight)
|
|
|
|
this.setData({
|
|
|
|
[`map.height`]: systemInfo.windowHeight - this.transverseViewHeight,
|
|
|
|
statusBarHeight: pt,
|
|
|
|
titleBarHeight: h,
|
|
|
|
})
|
|
|
|
//this.getPos(systemInfo);
|
|
|
|
this.systemInfo = systemInfo
|
|
|
|
//this.selectComponent('#getpos').getPos();
|
|
|
|
if (!this.hasClickMoveToLocation) {
|
|
|
|
//this.getMarkers();
|
|
|
|
//this.timeoutGetMarkers();
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function (e) {
|
|
|
|
util.elog(null, '离开地图页')
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
PubSub.off('searchParam')
|
|
|
|
PubSub.off('appHide')
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
return {
|
|
|
|
title: '请客订包间,就上周到安排'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onpos(e) {
|
|
|
|
console.log('onpos', e);
|
|
|
|
let res = e.detail;
|
|
|
|
if (!res.latitude) return this.timeoutGetMarkers();
|
|
|
|
this.hasGetLocation = true;
|
|
|
|
this.sellersIds = []
|
|
|
|
this.sellers = []
|
|
|
|
let map = this.data.map;
|
|
|
|
map.latitude = res.latitude;
|
|
|
|
map.longitude = res.longitude;
|
|
|
|
map.scale = mapScale;
|
|
|
|
this.user.latitude = res.latitude;
|
|
|
|
this.user.longitude = res.longitude;
|
|
|
|
map.height = this.systemInfo.windowHeight - this.transverseViewHeight
|
|
|
|
let sdobj = {
|
|
|
|
map: map,
|
|
|
|
hasSuggestion: false,
|
|
|
|
}
|
|
|
|
if (!this.hasSellerConcat) {
|
|
|
|
sdobj.markers = []
|
|
|
|
}
|
|
|
|
this.setData(sdobj)
|
|
|
|
this.timeoutGetMarkers()
|
|
|
|
/*
|
|
|
|
if(this.mapCtx){
|
|
|
|
//this.mapCtx.moveToLocation();
|
|
|
|
this.mapCtx.getRegion({
|
|
|
|
success:(res)=>{
|
|
|
|
console.log('onpos.getRegion',res)
|
|
|
|
if(this.mapData.region.southwest.latitude) {
|
|
|
|
this.mapData.region = res
|
|
|
|
this.timeoutGetMarkers()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
},
|
|
|
|
regionchange(e) {
|
|
|
|
if (e.type != 'end') return;
|
|
|
|
console.log('regionchange', e)
|
|
|
|
if (typeof this.mapCtx == 'undefined' || !this.mapCtx) return;
|
|
|
|
this.getClassNameFlag = true;
|
|
|
|
this.mapCtx.getScale({
|
|
|
|
success: (res) => {
|
|
|
|
this.mapData.scale = res.scale;
|
|
|
|
console.log('regionchange.getScale', res, this.data.map.scale)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
this.mapCtx.getCenterLocation({
|
|
|
|
success: (res) => {
|
|
|
|
console.log('regionchange.getCenterLocation', res)
|
|
|
|
this.mapData.latitude = res.latitude;
|
|
|
|
this.mapData.longitude = res.longitude;
|
|
|
|
if (this.mapData.lat == '' && res.latitude.toString().length > 6 && res.longitude.toString().length > 6) {
|
|
|
|
this.mapData.lat = res.latitude;
|
|
|
|
this.mapData.lng = res.longitude;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
this.mapCtx.getRegion({
|
|
|
|
success: (res) => {
|
|
|
|
console.log('regionchange.getRegion', res.southwest.latitude, this.mapData.region.southwest.latitude, res)
|
|
|
|
this.hasClickMoveToLocation = false
|
|
|
|
if (res.southwest.latitude) {
|
|
|
|
this.mapData.region = res
|
|
|
|
}
|
|
|
|
;
|
|
|
|
this.timeoutGetMarkers();
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
setTimeoutGetMarkers: '',
|
|
|
|
timeoutGetMarkers() {//延时获取
|
|
|
|
if (this.setTimeoutGetMarkers) {
|
|
|
|
clearTimeout(this.setTimeoutGetMarkers);
|
|
|
|
this.setTimeoutGetMarkers = '';
|
|
|
|
}
|
|
|
|
this.setTimeoutGetMarkers = setTimeout(() => {
|
|
|
|
this.getMarkers();
|
|
|
|
}, 300)
|
|
|
|
},
|
|
|
|
mapUpdated(e) {
|
|
|
|
console.log('mapUpdated', e)
|
|
|
|
if (typeof this.mapCtx == 'undefined' || !this.mapCtx) return;
|
|
|
|
this.getClassNameFlag = true;
|
|
|
|
this.mapCtx.getScale({
|
|
|
|
success: (res) => {
|
|
|
|
this.mapData.scale = res.scale;
|
|
|
|
console.log('mapUpdated.getScale', res, this.data.map.scale)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
this.mapCtx.getCenterLocation({
|
|
|
|
success: (res) => {
|
|
|
|
console.log('mapUpdated.getCenterLocation', res)
|
|
|
|
this.mapData.latitude = res.latitude;
|
|
|
|
this.mapData.longitude = res.longitude;
|
|
|
|
if (this.mapData.lat == '' && res.latitude.toString().length > 6 && res.longitude.toString().length > 6) {
|
|
|
|
this.mapData.lat = res.latitude;
|
|
|
|
this.mapData.lng = res.longitude;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
this.mapCtx.getRegion({
|
|
|
|
success: (res) => {
|
|
|
|
if (this.mapData.region.southwest.latitude == '' || !res.southwest.latitude) return;
|
|
|
|
console.log('mapUpdated.getRegion', [res.southwest.latitude, this.mapData.region.southwest.latitude])
|
|
|
|
this.mapData.region = res
|
|
|
|
//this.timeoutGetMarkers();
|
|
|
|
},
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
hasBoost: true,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
hasMarkertap: false,
|
|
|
|
markertap(e, flag = true) {
|
|
|
|
if (e.markerId == 'location' || e.markerId == 'locationMe') return;
|
|
|
|
this.hasMarkertap = false
|
|
|
|
let markers = this.data.markers;
|
|
|
|
console.log('markertap', e)
|
|
|
|
this.activeSellerID = e.markerId
|
|
|
|
let bl = 1.2;
|
|
|
|
let current = 0, hasCurrent = true;
|
|
|
|
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.callout) {
|
|
|
|
m.callout.borderColor = '#cccccc';
|
|
|
|
m.callout.bgColor = '#fefefe';
|
|
|
|
m.callout.color = '#353535';
|
|
|
|
m.callout.display = m.calloutDisplay;
|
|
|
|
}
|
|
|
|
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
|
|
|
|
if (m.callout) {
|
|
|
|
m.callout.borderColor = '#F05522';
|
|
|
|
m.callout.bgColor = '#F05522';
|
|
|
|
m.callout.color = '#fefefe';
|
|
|
|
m.callout.display = 'ALWAYS';
|
|
|
|
}
|
|
|
|
hasCurrent = false
|
|
|
|
if ("markertap" == e.type) {
|
|
|
|
util.elog({id: m.seller.id, sellername: m.seller.sellername}, '点击地图区域的店铺标记')
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (m.display != 'none' && hasCurrent) {
|
|
|
|
current++
|
|
|
|
}
|
|
|
|
})
|
|
|
|
let obj = {
|
|
|
|
markers: markers,
|
|
|
|
};
|
|
|
|
console.log('markertap::current,', current);
|
|
|
|
if (flag) {
|
|
|
|
//obj.scrollIntoView='seller-'+e.markerId;
|
|
|
|
obj.current = current;
|
|
|
|
//this.hasMarkertap=true;
|
|
|
|
}
|
|
|
|
this.setData(obj)
|
|
|
|
},
|
|
|
|
hasInRegionFlag: false,
|
|
|
|
hasInRegion() {//定位是否在地图视野内
|
|
|
|
let map = this.mapData;
|
|
|
|
if (!map.region.northeast.latitude || !map.region.northeast.longitude) {//未获得视野
|
|
|
|
if (this.mapDataLast) {
|
|
|
|
this.mapData = this.mapDataLast
|
|
|
|
}
|
|
|
|
return {flag: false, msg: '未获得视野', map: map, mapDataLast: this.mapDataLast};
|
|
|
|
}
|
|
|
|
if (!map.region.southwest.latitude || !map.region.southwest.longitude) {//未获得视野
|
|
|
|
if (this.mapDataLast) {
|
|
|
|
this.mapData = this.mapDataLast
|
|
|
|
}
|
|
|
|
return {flag: false, msg: '未获得视野', map: map, mapDataLast: this.mapDataLast};
|
|
|
|
}
|
|
|
|
this.mapDataLast = JSON.parse(JSON.stringify(this.mapData));
|
|
|
|
if (this.hasInRegionFlag) return {flag: true, msg: '二次获取'};
|
|
|
|
if (!this.user.latitude) return {flag: false, msg: '用户无定位'};//用户无定位
|
|
|
|
//if(this.user.latitude==def_latitude && this.user.longitude==def_longitude) return false;//默认位置
|
|
|
|
///判断定位 首次 进入视野
|
|
|
|
if ((this.user.latitude > map.region.southwest.latitude
|
|
|
|
&& this.user.longitude > map.region.southwest.longitude
|
|
|
|
&& this.user.latitude < map.region.northeast.latitude
|
|
|
|
&& this.user.longitude < map.region.northeast.longitude) || this.data.hasSuggestion) {
|
|
|
|
this.hasInRegionFlag = true;
|
|
|
|
return {flag: true, msg: '用户首次或搜索地标'};
|
|
|
|
} else {
|
|
|
|
//视野不匹配
|
|
|
|
this.mapCtx.getRegion({
|
|
|
|
success: (res) => {
|
|
|
|
console.log('hasInRegion.getRegion', res)
|
|
|
|
this.mapData.region = res
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return {flag: false, msg: '视野不匹配'};
|
|
|
|
},
|
|
|
|
async getMarkers() {
|
|
|
|
let cmap = this.data.map;
|
|
|
|
let map = this.mapData;
|
|
|
|
//console.log('getMarkers',map.region);
|
|
|
|
let region = this.hasInRegion();
|
|
|
|
console.log('this.hasInRegion', region)
|
|
|
|
if (!region.flag) {
|
|
|
|
return setTimeout(() => {
|
|
|
|
this.getMarkers();
|
|
|
|
}, 300)
|
|
|
|
}
|
|
|
|
let markers = [];
|
|
|
|
let param = {
|
|
|
|
lat: this.user.latitude == def_latitude ? '' : this.user.latitude,
|
|
|
|
lng: this.user.longitude == def_longitude ? '' : this.user.longitude,
|
|
|
|
offset: 0,
|
|
|
|
rows: 50,
|
|
|
|
distance: 100000,
|
|
|
|
map: JSON.stringify({...this.mapData.region, scale: this.mapData.scale >= 19 ? 20 : this.mapData.scale})
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
let now_sid = [];
|
|
|
|
App.Customer.SellerList(param).then(async res => {
|
|
|
|
//this.mapData.region.southwest.latitude='';
|
|
|
|
if (res.ret == 200) {
|
|
|
|
let sellersList = res.data.list;
|
|
|
|
let sellersLength = sellersList.length;
|
|
|
|
sellersList.forEach((seller, si) => {
|
|
|
|
now_sid.push(seller.id);
|
|
|
|
let hasMark = false;
|
|
|
|
if (this.sellersIds._indexOf(seller.id) < 0) {
|
|
|
|
// if(seller.distance || seller.distance===0){
|
|
|
|
// seller.distance=parseInt(seller.distance);
|
|
|
|
// if(seller.distance>1000){
|
|
|
|
// seller.distance=(seller.distance/1000).toFixed(2)+'km'
|
|
|
|
// }else{
|
|
|
|
// seller.distance+='m';
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
if (this.hasSellerConcat) {
|
|
|
|
this.sellersIds.push(seller.id);
|
|
|
|
}
|
|
|
|
hasMark = true;
|
|
|
|
}
|
|
|
|
if (hasMark) {
|
|
|
|
if (this.findSellerData) {
|
|
|
|
seller.findSellerParamObj = this.findSellerData.paramObj
|
|
|
|
}
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
marker.callout = {
|
|
|
|
content: ' ' + seller.sellername + ' ',
|
|
|
|
color: '#353535',
|
|
|
|
fontSize: 12,
|
|
|
|
borderWidth: 1,
|
|
|
|
borderColor: '#cccccc',
|
|
|
|
borderRadius: 50,
|
|
|
|
bgColor: '#fefefe',
|
|
|
|
padding: 5,
|
|
|
|
textAlign: 'left',
|
|
|
|
display: 'BYCLICK',
|
|
|
|
};
|
|
|
|
marker.calloutDisplay = 'BYCLICK';
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (x.id == 2) {//商家名
|
|
|
|
marker.callout.display = 'ALWAYS';
|
|
|
|
marker.calloutDisplay = 'ALWAYS';
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
markers.push(marker)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
console.log('接口报错了');
|
|
|
|
}
|
|
|
|
this.sellersNow = now_sid;
|
|
|
|
let obj = {
|
|
|
|
hasSellers: now_sid.length > 0,
|
|
|
|
hasGetSellersEnd: true,
|
|
|
|
hasSearchLimit: (tags.length > 0 || this.data.multiIndex[0] > 0) || this.findSellerData,
|
|
|
|
listMoreCount: res.data.flag
|
|
|
|
}
|
|
|
|
if (this.hasSellerConcat) {
|
|
|
|
obj.markers = this.data.markers.concat(markers);
|
|
|
|
} else {
|
|
|
|
obj.markers = markers;
|
|
|
|
}
|
|
|
|
obj.markers.forEach(mk => {
|
|
|
|
//mk.display='none';
|
|
|
|
if (now_sid._indexOf(mk.id) > -1) {
|
|
|
|
mk.display = '';
|
|
|
|
}
|
|
|
|
})
|
|
|
|
obj.markers = await this.setLocationMarker(obj.markers);
|
|
|
|
this.setData(obj)
|
|
|
|
if (now_sid.length > 0) {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.markertap({
|
|
|
|
markerId: now_sid._indexOf(this.activeSellerID) < 0 ? now_sid[0] : this.activeSellerID
|
|
|
|
}, true)
|
|
|
|
}, 100)
|
|
|
|
}
|
|
|
|
this.IsSetActivity();
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
//seller box 通知
|
|
|
|
sellerBoxEvent(e) {
|
|
|
|
wx.showTabBar();
|
|
|
|
},
|
|
|
|
moveToLocation() {
|
|
|
|
this.hasClickMoveToLocation = true
|
|
|
|
if (this.user.latitude == def_latitude && this.user.longitude == def_longitude) {
|
|
|
|
this.selectComponent('#getpos').getPos(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.sellersIds = []
|
|
|
|
this.sellers = []
|
|
|
|
let map = this.data.map;
|
|
|
|
map.latitude = this.user.latitude;
|
|
|
|
map.longitude = this.user.longitude;
|
|
|
|
map.scale = mapScale;
|
|
|
|
map.height = this.systemInfo.windowHeight - this.transverseViewHeight
|
|
|
|
let sdobj = {
|
|
|
|
map: map,
|
|
|
|
hasSuggestion: false,
|
|
|
|
hasGetSellersEnd: false,
|
|
|
|
}
|
|
|
|
if (!this.hasSellerConcat) {
|
|
|
|
sdobj.markers = []
|
|
|
|
}
|
|
|
|
this.setData(sdobj)
|
|
|
|
this.mapCtx.moveToLocation({
|
|
|
|
success: (res) => {
|
|
|
|
console.log('moveToLocation', res)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
bindMultiPickerChange(e) {
|
|
|
|
console.log(e);
|
|
|
|
let val = util.val(e);
|
|
|
|
this.setData({
|
|
|
|
multiIndex: val
|
|
|
|
})
|
|
|
|
this.hasSellerConcat = hasSellerConcat;
|
|
|
|
this.sellersIds = [];
|
|
|
|
if (val[0] > 0) {
|
|
|
|
this.hasSellerConcat = false;
|
|
|
|
} else {
|
|
|
|
if (!this.hasSellerConcat) {
|
|
|
|
this.setData({
|
|
|
|
markers: []
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getMarkers();
|
|
|
|
}, 0)
|
|
|
|
},
|
|
|
|
setSuggestion(suggestion) {
|
|
|
|
let map = this.data.map;
|
|
|
|
//let pos=DA.gcj02towgs84(suggestion.longitude,suggestion.latitude)
|
|
|
|
map.latitude = suggestion.latitude
|
|
|
|
map.longitude = suggestion.longitude
|
|
|
|
if (suggestion.type == -1) {//平台商户
|
|
|
|
this.activeSellerID = suggestion.id
|
|
|
|
map.scale = 20
|
|
|
|
} else {
|
|
|
|
map.scale = mapScale
|
|
|
|
}
|
|
|
|
this.sellersIds = []
|
|
|
|
this.sellers = []
|
|
|
|
let sdobj = {
|
|
|
|
map: map,
|
|
|
|
hasSuggestion: true,
|
|
|
|
suggestion: suggestion,
|
|
|
|
hasGetSellersEnd: false,
|
|
|
|
}
|
|
|
|
if (!this.hasSellerConcat) {
|
|
|
|
sdobj.markers = []
|
|
|
|
}
|
|
|
|
//this.findSellerData=null//清理搜索
|
|
|
|
this.setData(sdobj)
|
|
|
|
},
|
|
|
|
|
|
|
|
getClassNameFlag: true,
|
|
|
|
activeSellerID: '',
|
|
|
|
bindscroll(e) {
|
|
|
|
if (!this.getClassNameFlag) return;
|
|
|
|
this.getClassNameFlag = false;
|
|
|
|
let w = e.detail.scrollWidth / this.sellers.length;
|
|
|
|
let i = Math.round(e.detail.scrollLeft / w);
|
|
|
|
console.log(e.detail, this.sellers, i);
|
|
|
|
if (this.activeSellerID != this.sellers[i].id) {
|
|
|
|
this.activeSellerID = this.sellers[i];
|
|
|
|
this.markertap({
|
|
|
|
markerId: this.sellers[i].id
|
|
|
|
}, false)
|
|
|
|
}
|
|
|
|
let that = this;
|
|
|
|
setTimeout(function () {
|
|
|
|
that.getClassNameFlag = true;
|
|
|
|
}, 300)
|
|
|
|
},
|
|
|
|
bindtransition(e) {
|
|
|
|
if (this.hasMarkertap) {
|
|
|
|
this.hasMarkertap = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let i = e.detail.current
|
|
|
|
if (typeof this.data.markers[i] == 'undefined') return;
|
|
|
|
this.activeSellerID = this.data.markers[i].id
|
|
|
|
console.log('bindtransition', this.sellersNow, e.detail.current, this.sellersNow[e.detail.current], this.activeSellerID);
|
|
|
|
// this.activeSellerID=this.sellersNow[i];
|
|
|
|
// this.markertap({
|
|
|
|
// markerId:this.activeSellerID
|
|
|
|
// },false)
|
|
|
|
this.markertap({
|
|
|
|
markerId: this.activeSellerID
|
|
|
|
}, false)
|
|
|
|
},
|
|
|
|
gotoDetail(e) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/reserve/detail?id=' + util.attr(e, 'sid')
|
|
|
|
})
|
|
|
|
util.elog({sid: util.attr(e, 'sid')}, '点击橱窗中的商家,进入店铺详情')
|
|
|
|
},
|
|
|
|
IsSetActivity() {
|
|
|
|
let cmap = this.data.map;
|
|
|
|
App.Customer.IsSetActivity({lat: cmap.latitude, lng: cmap.longitude, distance: 50}).then(res => {
|
|
|
|
this.setData({
|
|
|
|
hasSetActivity: res.data == 1,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
a2lshow(e) {
|
|
|
|
//console.log('a2lshow',e)
|
|
|
|
let ds = this.selectComponent('#ds');
|
|
|
|
if (!ds) {
|
|
|
|
return setTimeout(() => {
|
|
|
|
this.a2lshow(e)
|
|
|
|
}, 500)
|
|
|
|
}
|
|
|
|
ds.setA2LHeight(e.type == 'hide' ? 0 : 40);
|
|
|
|
},
|
|
|
|
async setMapRegion() {
|
|
|
|
return new Promise((success, fail) => {
|
|
|
|
if (this.mapCtx) {
|
|
|
|
this.mapCtx.getRegion({
|
|
|
|
success: (res) => {
|
|
|
|
if (res.southwest.latitude) {
|
|
|
|
this.mapData.region = res
|
|
|
|
success()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail: () => {
|
|
|
|
fail()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
fail()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
async setLocationMarker(markers) {
|
|
|
|
try {
|
|
|
|
await this.setMapRegion();
|
|
|
|
} catch (e) {
|
|
|
|
this.timeoutGetMarkers()
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
|
|
|
let map = this.mapData;
|
|
|
|
let mks = []
|
|
|
|
let matchPosNum = 1
|
|
|
|
if (markers.length > 0) {
|
|
|
|
markers.forEach(mk => {
|
|
|
|
if (mk.id != 'location' && mk.id != 'locationMe'
|
|
|
|
&& mk.latitude > map.region.southwest.latitude
|
|
|
|
&& mk.longitude > map.region.southwest.longitude
|
|
|
|
&& mk.latitude < map.region.northeast.latitude
|
|
|
|
&& mk.longitude < map.region.northeast.longitude) {
|
|
|
|
mks.push(mk);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (mks.length - markers.length < 0) {
|
|
|
|
this.timeoutGetMarkers()
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.data.hasSuggestion) {
|
|
|
|
map = this.data.suggestion
|
|
|
|
mks.push({
|
|
|
|
id: 'location',
|
|
|
|
iconPath: "http://nosqn.colorcun.com/reserve/images/location.png" + cates_version,
|
|
|
|
latitude: map.latitude,
|
|
|
|
longitude: map.longitude,
|
|
|
|
width: 20,
|
|
|
|
height: 25,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
mks.push({
|
|
|
|
id: 'locationMe',
|
|
|
|
iconPath: "http://nosqn.colorcun.com/reserve/images/lme.png" + cates_version,
|
|
|
|
latitude: this.user.latitude,
|
|
|
|
longitude: this.user.longitude,
|
|
|
|
width: 18,
|
|
|
|
height: 30,
|
|
|
|
})
|
|
|
|
return mks;
|
|
|
|
},
|
|
|
|
tagsChange(e) {
|
|
|
|
if (this.data.listMoreCount < 1 && !this.data.hasSearchLimit) return
|
|
|
|
let id = util.attr(e, 'id');
|
|
|
|
let tags = this.data.tags;
|
|
|
|
let activeNum = 0;
|
|
|
|
tags.forEach(t => {
|
|
|
|
if (t.id == id) {
|
|
|
|
t.active = !t.active
|
|
|
|
}
|
|
|
|
if (t.active) {
|
|
|
|
activeNum++
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
tags: tags,
|
|
|
|
})
|
|
|
|
this.hasSellerConcat = hasSellerConcat;
|
|
|
|
this.sellersIds = [];
|
|
|
|
if (activeNum > 0) {
|
|
|
|
this.hasSellerConcat = false;
|
|
|
|
} else {
|
|
|
|
if (!this.hasSellerConcat) {
|
|
|
|
this.setData({
|
|
|
|
markers: []
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getMarkers();
|
|
|
|
}, 0)
|
|
|
|
|
|
|
|
},
|
|
|
|
caixiActive(e) {
|
|
|
|
console.log('caixiActive', e);
|
|
|
|
this.bindMultiPickerChange({
|
|
|
|
detail: {
|
|
|
|
value: [e.detail]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
caixiShow() {
|
|
|
|
if (this.data.listMoreCount < 1 && !this.data.hasSearchLimit) return
|
|
|
|
this.selectComponent('#caixi').show();
|
|
|
|
},
|
|
|
|
listEvent(e) {
|
|
|
|
let d = e.detail
|
|
|
|
console.log('listEvent', e);
|
|
|
|
if (d.type == "getListEnd") {
|
|
|
|
this.setData({
|
|
|
|
listMoreCount: d.total
|
|
|
|
});
|
|
|
|
} else if (d.type == 'caixiShow') {
|
|
|
|
this.caixiShow();
|
|
|
|
} else if (d.type == 'tagsChange') {
|
|
|
|
this.tagsChange(d.e);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
listShow() {
|
|
|
|
//this.selectComponent('#list').show();
|
|
|
|
if (!this.param.map) return;
|
|
|
|
this.movableChangeInit()
|
|
|
|
wx.navigateTo({
|
|
|
|
url: util.http_build_query({
|
|
|
|
lat: this.param.lat == def_latitude ? '' : this.param.lat,
|
|
|
|
lng: this.param.lng == def_longitude ? '' : this.param.lng,
|
|
|
|
map: this.param.map,
|
|
|
|
multiIndex: this.data.multiIndex,
|
|
|
|
tags: this.param.tags,
|
|
|
|
centre_pos: this.param.centre_pos,
|
|
|
|
hasSuggestion: this.data.hasSuggestion ? 1 : '',
|
|
|
|
keyword: this.data.hasSuggestion ? this.data.suggestion.title : '',
|
|
|
|
filterParams: this.filterParams ? JSON.stringify(this.filterParams) : null,
|
|
|
|
}, './indexList'),
|
|
|
|
success: res => {
|
|
|
|
// 通过eventChannel向被打开页面传送数据
|
|
|
|
if (this.findSellerData) {
|
|
|
|
res.eventChannel.emit('acceptDataFromMapPage', this.findSellerData)
|
|
|
|
}
|
|
|
|
res.eventChannel.on('findSellerData', findSellerData => {
|
|
|
|
console.log('findSellerData', findSellerData)
|
|
|
|
this.findSellerData = findSellerData
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getMarkers();
|
|
|
|
}, 0)
|
|
|
|
})
|
|
|
|
setTimeout(() => {
|
|
|
|
this.movableChangeInit()
|
|
|
|
this.hasListShow = false
|
|
|
|
}, 1500)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
setTSLocal() {
|
|
|
|
let map = this.data.map;
|
|
|
|
map.latitude = def_latitude
|
|
|
|
map.longitude = def_longitude
|
|
|
|
map.scale = mapScale
|
|
|
|
this.sellersIds = []
|
|
|
|
this.sellers = []
|
|
|
|
let sdobj = {
|
|
|
|
map: map,
|
|
|
|
hasGetSellersEnd: false,
|
|
|
|
hasSuggestion: false,
|
|
|
|
suggestion: {},
|
|
|
|
}
|
|
|
|
if (!this.hasSellerConcat) {
|
|
|
|
sdobj.markers = []
|
|
|
|
}
|
|
|
|
this.setData(sdobj)
|
|
|
|
},
|
|
|
|
findSellerData: null,
|
|
|
|
findSeller() {
|
|
|
|
if (this.data.listMoreCount < 1 && !this.data.hasSearchLimit) return
|
|
|
|
wx.navigateTo({
|
|
|
|
url: './findSeller',
|
|
|
|
success: res => {
|
|
|
|
// 通过eventChannel向被打开页面传送数据
|
|
|
|
if (this.findSellerData) {
|
|
|
|
res.eventChannel.emit('acceptDataFromMapPage', this.findSellerData)
|
|
|
|
}
|
|
|
|
res.eventChannel.on('findSellerData', findSellerData => {
|
|
|
|
console.log('findSellerData', findSellerData)
|
|
|
|
this.findSellerData = findSellerData
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getMarkers();
|
|
|
|
}, 0)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
boostEvent(e) {
|
|
|
|
util.elog(e.detail, '强提醒')
|
|
|
|
if (e.detail.act == 'hide') {
|
|
|
|
this.setData({
|
|
|
|
hasGetPos: true,
|
|
|
|
})
|
|
|
|
this.selectComponent('#getpos').getPos();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
elog(e) {
|
|
|
|
util.elog({attr: util.attr(e), detail: e.detail}, util.attr(e, 'ename') || '点击')
|
|
|
|
},
|
|
|
|
sbtrEvent(e) {
|
|
|
|
console.log(e);
|
|
|
|
if (e.detail.act == 'oncall') {
|
|
|
|
this.selectComponent('#as').show(e.detail.seller);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
movableY0: 99,
|
|
|
|
movableY1: 0,
|
|
|
|
hasListShow: false,
|
|
|
|
movableChangeInit() {
|
|
|
|
this.movableY0 = 99
|
|
|
|
this.movableY1 = 0
|
|
|
|
},
|
|
|
|
movableChange(e) {
|
|
|
|
if (this.hasListShow) return;
|
|
|
|
if (this.movableY0 == 99) {
|
|
|
|
this.movableY0 = e.detail.y
|
|
|
|
} else {
|
|
|
|
if (e.detail.y != this.movableY0) {
|
|
|
|
console.log('movableChange', '上拉');
|
|
|
|
this.listShow();
|
|
|
|
this.movableChangeInit()
|
|
|
|
this.hasListShow = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
filterShow() {
|
|
|
|
this.selectComponent('#filter').show(this.filterParams);
|
|
|
|
},
|
|
|
|
filterParams: null,
|
|
|
|
filterEvent(e) {
|
|
|
|
console.log('filterEvent', e)
|
|
|
|
if (e.detail.type == 'clean') {
|
|
|
|
this.filterParams = null
|
|
|
|
this.setData({
|
|
|
|
filterParams: null,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.filterParams = e.detail.data
|
|
|
|
this.setData({
|
|
|
|
filterParams: this.filterParams,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getMarkers();
|
|
|
|
}, 0)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}) |
...
|
...
|
|