You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
366 lines
13 KiB
366 lines
13 KiB
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
function step(op) {
|
|
if (f) throw new TypeError("Generator is already executing.");
|
|
while (_) try {
|
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
switch (op[0]) {
|
|
case 0: case 1: t = op; break;
|
|
case 4: _.label++; return { value: op[1], done: false };
|
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
default:
|
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
if (t[2]) _.ops.pop();
|
|
_.trys.pop(); continue;
|
|
}
|
|
op = body.call(thisArg, _);
|
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
}
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var promise_wx_api_1 = require("../../../../utils/promise-wx-api");
|
|
var type1MarkerIcons = [
|
|
{ name: '1', value: '../../images/jiancedian1.png' },
|
|
{ name: '3', value: '../../images/jiancedian2.png' },
|
|
{ name: '5', value: '../../images/jiancedian3.png' },
|
|
{ name: '99', value: '../../images/jiancedian4.png' }
|
|
];
|
|
var type2MarkerIcons = [
|
|
{ name: '1', value: '../../images/jiezhongdian1.png' },
|
|
{ name: '3', value: '../../images/jiezhongdian2.png' },
|
|
{ name: '5', value: '../../images/jiezhongdian3.png' },
|
|
{ name: '99', value: '../../images/jiezhongdian4.png' }
|
|
];
|
|
var noAvailableVaccinesIcon = '../../images/wuyimiao.png';
|
|
function getMarkerIconPath(type, marker) {
|
|
var iconPath = '';
|
|
if (type == '1') {
|
|
type1MarkerIcons.forEach(function (item) {
|
|
if (item.name == marker.kmNum) {
|
|
iconPath = item.value;
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
type2MarkerIcons.forEach(function (item) {
|
|
if (item.name == marker.kmNum) {
|
|
iconPath = item.value;
|
|
}
|
|
if (marker.noAvailableVaccines == '1') {
|
|
iconPath = noAvailableVaccinesIcon;
|
|
}
|
|
});
|
|
}
|
|
return iconPath;
|
|
}
|
|
Page({
|
|
data: {
|
|
type: '1',
|
|
longitude: 120.37914,
|
|
latitude: 36.088408,
|
|
mapScale: 14.35,
|
|
markers: [],
|
|
markerList: [],
|
|
mapCircles: [],
|
|
shrink: true,
|
|
scrollInto: 'item-0'
|
|
},
|
|
onLoad: function (options) {
|
|
var _this = this;
|
|
if (options.type) {
|
|
this.setData({
|
|
type: options.type
|
|
});
|
|
}
|
|
this.mapCtx = wx.createMapContext("device-map");
|
|
this.showMyPosition().then(function (res) {
|
|
_this.getMapData();
|
|
});
|
|
},
|
|
addMarkers: function () {
|
|
var _this = this;
|
|
var marker = {
|
|
id: 0,
|
|
iconPath: '',
|
|
width: 50,
|
|
height: 50,
|
|
callout: {
|
|
content: '',
|
|
color: "#fff",
|
|
fontSize: 16,
|
|
borderWidth: 2,
|
|
borderRadius: 12,
|
|
bgColor: "#393d48cc",
|
|
padding: 6,
|
|
display: "BYCLICK",
|
|
textAlign: "center"
|
|
},
|
|
};
|
|
this.data.markerList.forEach(function (markerPoint) {
|
|
var markerIcon = getMarkerIconPath(_this.data.type, markerPoint);
|
|
var markerId = markerPoint.markerId, name = markerPoint.name, longitude = markerPoint.longitude, latitude = markerPoint.latitude;
|
|
var newMarker = Object.assign({}, marker, {
|
|
id: markerId,
|
|
longitude: parseFloat(longitude),
|
|
latitude: parseFloat(latitude),
|
|
iconPath: markerIcon,
|
|
callout: {
|
|
content: name,
|
|
color: "#666666",
|
|
fontSize: 14,
|
|
borderWidth: 2,
|
|
borderRadius: 4,
|
|
bgColor: "#ffffff",
|
|
padding: 6,
|
|
display: "BYCLICK",
|
|
textAlign: "center"
|
|
},
|
|
});
|
|
_this.data.markers.push(newMarker);
|
|
});
|
|
this.setData({
|
|
markers: this.data.markers
|
|
});
|
|
},
|
|
bindClickMap: function (e) {
|
|
this.resetCallOut();
|
|
},
|
|
bindmarkertap: function (e) {
|
|
console.log('点击标记点', e.detail);
|
|
this.setData({
|
|
scrollInto: 'item-' + e.detail.markerId
|
|
});
|
|
this.resetCallOut();
|
|
},
|
|
bindcallouttap: function (e) {
|
|
console.log('点击自定义气泡', e.detail);
|
|
this.data.markerList.forEach(function (item) {
|
|
if (item.markerId == e.detail.markerId) {
|
|
wx.showModal({
|
|
title: "\u62E8\u6253" + item.mobile,
|
|
content: '',
|
|
cancelColor: '#29B9A5',
|
|
confirmColor: '#29B9A5',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
wx.makePhoneCall({
|
|
phoneNumber: item.mobile,
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
},
|
|
resetCallOut: function () {
|
|
console.log('resetCallOut');
|
|
this.data.markers.forEach(function (item) {
|
|
item.callout.display = "BYCLICK";
|
|
});
|
|
this.setData({
|
|
markers: this.data.markers
|
|
});
|
|
},
|
|
clearCallOut: function () {
|
|
console.log('clearCallOut');
|
|
this.data.markers.forEach(function (item) {
|
|
item.callout.display = "none";
|
|
});
|
|
this.setData({
|
|
markers: this.data.markers
|
|
});
|
|
},
|
|
clearMarkers: function () {
|
|
console.log('clearMarkers');
|
|
if (this.data.markerList.length > 0) {
|
|
var arr_1 = [];
|
|
this.data.markerList.forEach(function (item) {
|
|
arr_1.push(item.markerId);
|
|
});
|
|
this.setData({
|
|
markerList: [],
|
|
markers: []
|
|
});
|
|
this.mapCtx.removeMarkers({
|
|
markerIds: arr_1,
|
|
fail: function (err) {
|
|
console.log(err);
|
|
}
|
|
});
|
|
}
|
|
},
|
|
moveToLocation: function (latitude, longitude, scale) {
|
|
if (scale === void 0) { scale = 14.35; }
|
|
if (typeof latitude == 'string') {
|
|
latitude = parseFloat(latitude);
|
|
}
|
|
if (typeof longitude == 'string') {
|
|
longitude = parseFloat(longitude);
|
|
}
|
|
this.mapCtx.moveToLocation({
|
|
latitude: latitude,
|
|
longitude: longitude
|
|
});
|
|
var that = this;
|
|
this.mapCtx.getScale({
|
|
success: function (res) {
|
|
if (res.scale != 14.35) {
|
|
that.setData({
|
|
mapScale: scale
|
|
});
|
|
}
|
|
console.log('getMapScale: ', that.data.mapScale);
|
|
}
|
|
});
|
|
console.log('moveToLocaltion: ', latitude, longitude);
|
|
},
|
|
showMyPosition: function () {
|
|
var _this = this;
|
|
return new Promise(function (resolve, reject) {
|
|
var that = _this;
|
|
wx.getLocation({
|
|
type: 'gcj02',
|
|
success: function (res) {
|
|
var latitude = res.latitude;
|
|
var longitude = res.longitude;
|
|
that.setData({
|
|
latitude: latitude,
|
|
longitude: longitude,
|
|
mapCircles: [
|
|
{
|
|
longitude: longitude,
|
|
latitude: latitude,
|
|
color: '#00000000',
|
|
fillColor: '#1885ff28',
|
|
radius: 1000,
|
|
strokeWidth: 1
|
|
}
|
|
]
|
|
});
|
|
resolve(true);
|
|
console.log('getLocation: gcj02 ', latitude, longitude);
|
|
},
|
|
fail: function (e) {
|
|
that.moveToLocation(that.data.latitude, that.data.longitude);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
getMapData: function (searchName) {
|
|
if (searchName === void 0) { searchName = ''; }
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var params, url, data;
|
|
return __generator(this, function (_a) {
|
|
switch (_a.label) {
|
|
case 0:
|
|
params = {
|
|
type: this.data.type,
|
|
longitude: this.data.longitude,
|
|
latitude: this.data.latitude,
|
|
name: searchName
|
|
};
|
|
url = 'epmetuser/appPoint/getMapInfoByPointType';
|
|
return [4, promise_wx_api_1.wxRequestPost(url, params, {})];
|
|
case 1:
|
|
data = (_a.sent()).data.data;
|
|
if (data.code == 0 && data.msg == 'success') {
|
|
this.setData({
|
|
markerList: data.data
|
|
});
|
|
}
|
|
console.log('11111', this.data.markerList);
|
|
this.addMarkers();
|
|
return [2];
|
|
}
|
|
});
|
|
});
|
|
},
|
|
onChangeType: function (e) {
|
|
this.setData({
|
|
type: e.currentTarget.dataset.type
|
|
}, function () {
|
|
wx.setNavigationBarTitle({
|
|
title: e.currentTarget.dataset.type == '1' ? '核酸检测地图' : '疫苗接种地图'
|
|
});
|
|
});
|
|
this.clearMarkers();
|
|
this.getMapData();
|
|
},
|
|
onSearch: function (e) {
|
|
console.log(e.detail.value);
|
|
this.clearMarkers();
|
|
this.getMapData(e.detail.value);
|
|
},
|
|
shrinkList: function () {
|
|
if (this.data.markerList.length == 0) {
|
|
return;
|
|
}
|
|
this.setData({
|
|
shrink: !this.data.shrink
|
|
});
|
|
},
|
|
toNavigate: function (e) {
|
|
var index = e.currentTarget.dataset.index;
|
|
var latitude = parseFloat(this.data.markerList[index].latitude);
|
|
var longitude = parseFloat(this.data.markerList[index].longitude);
|
|
var address = this.data.markerList[index].name;
|
|
wx.openLocation({
|
|
latitude: latitude,
|
|
longitude: longitude,
|
|
scale: 14,
|
|
address: address,
|
|
success: function (r) {
|
|
console.log(r);
|
|
}
|
|
});
|
|
},
|
|
toCallMobile: function (e) {
|
|
var mobile = e.currentTarget.dataset.mobile;
|
|
wx.showModal({
|
|
title: "\u62E8\u6253" + mobile,
|
|
content: '',
|
|
cancelColor: '#29B9A5',
|
|
confirmColor: '#29B9A5',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
wx.makePhoneCall({
|
|
phoneNumber: mobile,
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
selectItem: function (e) {
|
|
var index = e.currentTarget.dataset.index;
|
|
this.moveToLocation(this.data.markerList[index].latitude, this.data.markerList[index].longitude);
|
|
this.clearCallOut();
|
|
this.resetCallOut();
|
|
this.data.markers.forEach(function (item, markerIndex) {
|
|
if (markerIndex == index) {
|
|
item.callout.display = "ALWAYS";
|
|
}
|
|
});
|
|
this.setData({
|
|
markers: this.data.markers
|
|
});
|
|
console.log(this.data.markers);
|
|
}
|
|
});
|
|
|