var t = require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../@babel/runtime/regenerator")), e = require("../../@babel/runtime/helpers/asyncToGenerator"), o = getApp(), a = require("../../utils/login.js"); Page({ data: { markers: [], longitude: null, latitude: null, weather: {}, totop: !1, shop: {}, showshop: !1, zoomsize: 14, showLocation: !0 }, onLoad: function(t) { var e = this; wx.showLoading({ title: "" }), a.pageStart(o).then(function(t) { e.getuserLocation(); }); }, getuserLocation: function() { var o = this; return e(t.default.mark(function e() { var a; return t.default.wrap(function(t) { for (;;) switch (t.prev = t.next) { case 0: return t.next = 2, o.getlocation(); case 2: a = t.sent, console.log("result:", a), a && (o.latitude = a.latitude, o.longitude = a.longitude), o.getData(); case 6: case "end": return t.stop(); } }, e); }))(); }, latitude: null, longitude: null, onShareAppMessage: function() {}, tolocation: function() { var t = wx.createMapContext("map"); console.log("moveToLocation"), t.moveToLocation({ success: function(t) { console.log(t); }, fail: function(t) { wx.showModal({ title: "用户未授权", content: "请开启相关权限,以便更好使用小程序哦!", showCancel: !0, success: function(t) { t.confirm ? wx.openSetting({ success: function(t) { console.log("authSetting", t), t.authSetting || that.showLocationFail(); } }) : t.cancel; }, fail: function(t) { that.showLocationFail(); } }); } }); }, clickMaker: function(t) { wx.openLocation({ latitude: latitude, longitude: longitude, scale: 18 }); }, callUs: function() { if (!o.globalData.servicetel) return !1; wx.makePhoneCall({ phoneNumber: "" + o.globalData.servicetel }); }, getData: function() { var t = this; a.request(o.globalData.config.map, { longitude: this.longitude, latitude: this.latitude }).then(function(e) { wx.hideLoading(), 200 == e.code ? (e.data.list.forEach(function(t, e) { t.id = e, t.width = 32, t.height = 32, t.latitude = 1 * t.latitude, t.longitude = 1 * t.longitude, t.iconPath = "/img/location-blue.png", t.callout = { content: t.t_name }; }), t.setData({ weather: e.data.weather, markers: e.data.list, longitude: 1 * e.data.longitude, latitude: 1 * e.data.latitude, zoomsize: e.data.zoomsize })) : wx.showModal({ title: "提示", content: e.message, confirmColor: "#EF8176", cancelColor: "#999999" }); }).catch(function(t) { wx.hideLoading(); }); }, bindmarkertap: function(t) { console.log(t); this.data.markers.forEach(function(t) { t.iconPath = "/img/location-blue.png"; }); for (var e = 0; e < this.data.markers.length; e++) if (this.data.markers[e].id == t.detail.markerId) { console.log(e), this.data.markers[e].iconPath = "/img/location-red.png", this.data.markers[e].width = 50, this.data.markers[e].height = 50, this.setData({ shop: Object.assign({}, this.data.markers[e]), showshop: !0 }); break; } }, closeshop: function() { this.setData({ showshop: !1 }); }, changeTop: function() { this.setData({ totop: !this.data.totop }); }, getlocation: function() { return new Promise(function(t, e) { wx.getLocation({ type: "wgs84", success: function(e) { e.latitude, e.longitude; t(e); }, fail: function(e) { t(); } }); }); }, showLocationFail: function() { wx.showToast({ title: "位置失败", icon: "none", duration: 1e3 }); }, toMap: function() { wx.openLocation({ latitude: this.data.shop.latitude, longitude: this.data.shop.longitude, name: this.data.shop.t_name, address: this.data.shop.address }); } });