system-page-add-address-google.6ee3cd57.js 8.2 KB

1
  1. (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["system-page-add-address-google"],{"0160":function(e,t,a){"use strict";var n=a("ea38"),s=a.n(n);s.a},2299:function(e,t,a){"use strict";a.r(t);var n=a("6907"),s=a("bcb4");for(var c in s)["default"].indexOf(c)<0&&function(e){a.d(t,e,(function(){return s[e]}))}(c);var o=a("73c8");for(var c in o)["default"].indexOf(c)<0&&function(e){a.d(t,e,(function(){return o[e]}))}(c);a("0160");var i=a("828b");s["default"].__module="renderScript";var l=Object(i["a"])(o["default"],n["b"],n["c"],!1,null,"9769c90a",null,!1,n["a"],s["default"]);t["default"]=l.exports},6907:function(e,t,a){"use strict";a.d(t,"b",(function(){return n})),a.d(t,"c",(function(){return s})),a.d(t,"a",(function(){}));var n=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("custom-page",{attrs:{"custom-navbar":!0,transparentNavbar:!0}},[a("v-uni-view",{staticClass:"content"},[a("v-uni-input",{wxsProps:{"change:inputValue":"inputValue"},staticClass:"controls",attrs:{id:"searchInput",type:"text",placeholder:"Search for places",inputValue:e.inputValue,"change:inputValue":e.renderScript.searchPlace},on:{confirm:function(t){arguments[0]=t=e.$handleEvent(t),e.searchPlace.apply(void 0,arguments)}},model:{value:e.inputValue,callback:function(t){e.inputValue=t},expression:"inputValue"}}),a("div",{ref:"maps",wxsProps:{"change:serviceLatLng":"serviceLatLng"},staticClass:"map",attrs:{id:"renderScript",serviceLatLng:e.serviceLatLng,"change:serviceLatLng":e.renderScript.receiveMsg}}),a("div",{staticClass:"places-list"},e._l(e.placesList,(function(t,n){return a("v-uni-view",{key:n,staticClass:"place-item",on:{click:function(a){arguments[0]=a=e.$handleEvent(a),e.selectPlace(t)}}},[a("v-uni-view",{staticStyle:{display:"flex","align-items":"center"}},[a("v-uni-view",{staticClass:"tn-icon-location icon",class:t.formatted_address==e.formatted_address?"selectIcon":""}),a("v-uni-view",{staticStyle:{padding:"10rpx 0","flex-grow":"1","border-bottom":"1px solid #dadada"}},[a("v-uni-view",{staticClass:"place-item-top",class:t.formatted_address==e.formatted_address?"selectAddress":""},[e._v(e._s(t["name"]))]),a("v-uni-view",{staticClass:"place-item-bottom"},[e._v(e._s(t.formatted_address))])],1)],1)],1)})),1)],1)],1)},s=[]},"73c8":function(e,t,a){"use strict";a.r(t);var n=a("e8b4"),s=a.n(n);for(var c in n)["default"].indexOf(c)<0&&function(e){a.d(t,e,(function(){return n[e]}))}(c);t["default"]=s.a},bcb4:function(e,t,a){"use strict";a.r(t);var n=a("c5bc"),s=a.n(n);for(var c in n)["default"].indexOf(c)<0&&function(e){a.d(t,e,(function(){return n[e]}))}(c);t["default"]=s.a},c5bc:function(e,t,a){"use strict";a("6a54"),Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,a("fd3c"),a("64aa"),a("bf0f"),a("2797"),a("e838"),a("aa9c"),a("d4b5");var n=a("419c"),s={data:function(){return{map:{},receiveLocalData:{lat:23.02882,lng:113.14278},name:"",formatted_address:"",lat:0,lng:0,mapIsReady:!1,markers:[],placesList:[]}},mounted:function(){var e=document.createElement("script");e.src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBtp-DquN2FxcDlfBxTMw34y1RSgxaL9nc&language=zh-CN&callback=initMap&libraries=places",window.initMap=function(){},document.head.appendChild(e)},methods:{initMap:function(){console.log("initMap"),this.map=new google.maps.Map(document.getElementById("renderScript"),{center:{lat:this.receiveLocalData.lat,lng:this.receiveLocalData.lng},zoom:16}),this.mapIsReady=!0,this.addMarker(this.receiveLocalData.lat,this.receiveLocalData.lng)},receiveMsg:function(e){var t=this,a=e.lat,n=e.lng;a=Number(a),n=Number(n),console.log("服务层传递过来的经纬度",a,n),this.mapIsReady?this.addMarker(a,n):(t.map=new google.maps.Map(document.getElementById("renderScript"),{center:{lat:a,lng:n},zoom:16}),t.mapIsReady=!0,t.addMarker(a,n),t.map.addListener("click",(function(e){var a=e.latLng.lat(),n=e.latLng.lng();a=Number(a),n=Number(n),console.log("点击地图获取的经纬度",a,n),t.addMarker(a,n)})))},addMarker:function(e,t){this.markers.forEach((function(e){e.setMap(null)})),this.markers=[];var a=new google.maps.Marker({position:{lat:e,lng:t},map:this.map});this.getAddress(e,t,a)},getAddress:function(e,t,a){var n=this,s=new google.maps.Geocoder,c={lat:parseFloat(e),lng:parseFloat(t)};s.geocode({location:c},(function(s,c){if("OK"===c)if(s[0]){console.log(s[0]);var o=s[0].address_components[1].long_name,i=s[0].formatted_address;n.name=o,n.formatted_address=i,n.lat=e,n.lng=t;var l=document.createElement("div"),r=document.createElement("h3");r.textContent=n.name;var d=document.createElement("p");d.textContent=n.formatted_address;var u=document.createElement("button");u.textContent="确定",u.style.marginTop="5px",u.style.marginBottom="5px",u.addEventListener("click",(function(){n.confirmAddress()})),l.appendChild(r),l.appendChild(d),l.appendChild(u);var p=new google.maps.InfoWindow({content:l});n.markers.push(a),p.open(n.map,a)}else console.log("No results found");else console.log("Geocoder failed due to: "+c)}))},confirmAddress:function(){var e={name:this.name,address:this.formatted_address,lat:this.lat,lng:this.lng};console.log("点击确定按钮",e);var t=JSON.stringify(e),a="/system-page/add-address/index?addressString="+t;(0,n.navPage)(a)},searchPlace:function(e){console.log("搜索的地点",e);var t=this,a=new google.maps.places.PlacesService(t.map);a.textSearch({query:e},(function(e,a){if(console.log("搜索结果",e),console.log("搜索状态",a),console.log("google.maps.places.PlacesServiceStatus.OK",google.maps.places.PlacesServiceStatus.OK),a===google.maps.places.PlacesServiceStatus.OK){t.placesList=e,console.log("placesList",t.placesList);var n=document.querySelector(".places-list"),s=document.querySelectorAll(".place-item");s.length&&s.forEach((function(e){e.remove()})),t.placesList.forEach((function(e){var a=document.createElement("div"),s=document.createElement("div"),c=document.createElement("div"),o=document.createElement("div");a.className="place-item",s.className="place-item-top",c.className="place-item-bottom",o.className="tn-icon-location icon",o.style.marginRight="20rpx",o.style.visibility="hidden",s.textContent=e.name,c.textContent=e.formatted_address,a.appendChild(o),a.appendChild(s),a.appendChild(c),a.addEventListener("click",(function(){t.selectPlace(e)})),n.appendChild(a)}))}}))},selectPlace:function(e){console.log("选中的地点",e),this.name=e.name,this.formatted_address=e.formatted_address,this.lat=e.geometry.location.lat(),this.lng=e.geometry.location.lng(),this.addMarker(this.lat,this.lng)}}};t.default=s},e8b4:function(e,t,a){"use strict";a("6a54");var n=a("f5bd").default;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,a("64aa");var s=n(a("2634")),c=n(a("2fdc")),o={data:function(){return{inputValue:"",geocoder:null,lat:0,lng:0,addressInfo:{},map:null,markers:[],placesList:[],formatted_address:"",finalAddressInfo:{name:"",address:"",lat:0,lng:0},serviceLatLng:{lat:0,lng:0}}},onLoad:function(e){var t=this;return(0,c.default)((0,s.default)().mark((function a(){return(0,s.default)().wrap((function(a){while(1)switch(a.prev=a.next){case 0:e.lat&&e.lng&&(t.lat=Number(e.lat),t.lng=Number(e.lng),setTimeout((function(){t.serviceLatLng={lat:t.lat,lng:t.lng}}),1500));case 1:case"end":return a.stop()}}),a)})))()},methods:{searchPlace:function(){},receiveRenderData:function(e){console.log("接收到的数据",e)}}};t.default=o},ea38:function(e,t,a){var n=a("ecc9");n.__esModule&&(n=n.default),"string"===typeof n&&(n=[[e.i,n,""]]),n.locals&&(e.exports=n.locals);var s=a("967d").default;s("0ade945f",n,!0,{sourceMap:!1,shadowMode:!1})},ecc9:function(e,t,a){var n=a("c86c");t=n(!1),t.push([e.i,".content[data-v-9769c90a]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:95vh;width:100vw;padding-bottom:5vh}uni-input[data-v-9769c90a]{height:40px;font-size:16px;border:1px solid #ccc;border-radius:5px;z-index:5;background-color:#fff}.controls[data-v-9769c90a]{width:80%;margin:auto;height:40px}.map[data-v-9769c90a]{height:55vh;width:100vw;margin-bottom:3vh}.places-list[data-v-9769c90a]{width:90vw;padding:0 %?30?%;flex-grow:1;overflow-y:auto}.place-item-bottom[data-v-9769c90a]{font-size:%?22?%;color:#999}.selectAddress[data-v-9769c90a]{color:#4297ff}.icon[data-v-9769c90a]{margin-right:%?20?%;visibility:hidden}.selectIcon[data-v-9769c90a]{visibility:unset}",""]),e.exports=t}}]);