{"remainingRequest":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/vue-loader/lib/index.js??vue-loader-options!/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/src/components/o_gps.vue?vue&type=script&lang=js&","dependencies":[{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/src/components/o_gps.vue","mtime":1740130327258},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/thread-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/babel-loader/lib/index.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/vue-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport wx from \"weixin-js-sdk\";\nimport Constant from \"@/Constant.js\";\nexport default {\n name: \"o-gps\",\n props: [\"id\"],\n computed: {\n field: function() {\n let formData = this.$parent.findField(this.id);\n formData.position=formData.value;\n if(formData.position) {\n formData.position = JSON.parse(formData.position)\n }\n return this.$parent.findField(this.id);\n }\n },\n mounted() {\n window['onClickGetGps'] = (res)=> {\n this.onClickGetGps(res)\n }\n let value = this.field.value\n if(!value) {\n this.getCurrentPosition()\n }\n },\n\n data: function() {\n return {\n Constant,\n currentPosition:'',\n center: {\n lng: 113.261503, \n lat: 23.131377\n },\n zoom: 9,\n isShow:false,\n currentP: ''\n };\n },\n\n methods: {\n handler ({BMap}) {\n //以下不要删除先\n // let field = this.field\n // let ua = window.navigator.userAgent;\n // if(!field.value && ua.indexOf(\"myApps\") == -1 && (ua.toLowerCase().indexOf(\"wxwork\") == -1 && ua.toLowerCase().indexOf(\"weixin\") == -1)) {\n // let that = this;\t// 设置一个临时变量指向vue实例,因为在百度地图回调里使用this,指向的不是vue实例;\n // let geolocation = new BMap.Geolocation();\n // geolocation.getCurrentPosition(function(res){\n // let lat = res.latitude;\n // let lng = res.longitude;\n // // wgs84转百度坐标系\n // let ssws=that.wgs84togcj02(lng, lat);\n // ssws = that.gcj02tobd09(ssws[0] , ssws[1] );\n // //解决定位偏移\n // let newLat = ssws[1] - 0.000160;\n // let newLng = ssws[0] - 0.000160;\n // let bdPoint = new BMap.Point(newLng.toFixed(6), newLat.toFixed(6));\n // let geoc = new BMap.Geocoder();\n // //坐标逆解析为地址\n // geoc.getLocation(bdPoint, (rs) => {\n // that.field.position = {\n // latitude: newLat.toFixed(6),\n // longitude: newLng.toFixed(6),\n // address: rs.address,\n // }\n // let data = JSON.stringify(that.field.position);\n // that.field.value = data;\n // });\n // })\n // }\n },\n \n onClickGetGps(res){\n let currentfieldId = localStorage.getItem(\"currentGpsFieldId\");\n let list = this.$parent.getAllFields();\n let datas = JSON.parse(res);\n let latitude = datas.latitude; // 纬度,浮点数,范围为 90 ~ -90\n let longitude = datas.longitude; // 经度,浮点数,范围为 180 ~ -180。\n let bdPoint = new BMap.Point(longitude,latitude);\n let geoc = new BMap.Geocoder();\n for(let i=0; i= 0) { //嗨办公\n this.getLocal({\n type: 'wgs84',\n result: (res) => {\n onClickGetGps(res);\n }\n });\n }else if (ua.toLowerCase().indexOf(\"wxwork\") >= 0 || ua.toLowerCase().indexOf(\"weixin\") >= 0){ \n let _url = location.href.split(\"#\")[0];\n this.$api.getWeixinApi(\n encodeURIComponent(_url),\n { \n onSucess: response => {\n let that = this;\n wx.config({\n debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。\n appId: response.data.data.appId, // 必填,公众号的唯一标识\n timestamp: response.data.data.timestamp, // 必填,生成签名的时间戳\n nonceStr: response.data.data.nonceStr, // 必填,生成签名的随机串\n signature: response.data.data.signature, // 必填,签名,见附录1\n jsApiList: [\n \"checkJsApi\",\n \"getLocation\",\n ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2\n });\n \n wx.getLocation({\n success: function (res) {\n that.currentPosition = res;\n let lat = res.latitude;\n let lng = res.longitude;\n // wgs84转百度坐标系\n let ssws=that.wgs84togcj02(lng, lat);\n ssws = that.gcj02tobd09(ssws[0] , ssws[1] );\n //解决定位偏移\n let newLat = ssws[1] - 0.000160;\n let newLng = ssws[0] - 0.000160;\n let bdPoint = new BMap.Point(newLng.toFixed(6), newLat.toFixed(6));\n\n // let bdPoint = new BMap.Point(res.longitude, res.latitude);\n let geoc = new BMap.Geocoder();\n //坐标逆解析为地址\n geoc.getLocation(bdPoint, (rs) => {\n that.field.position = {\n latitude: newLat.toFixed(6),\n longitude: newLng.toFixed(6),\n address: rs.address,\n }\n let data = JSON.stringify(that.field.position);\n that.field.value = data;\n });\n },\n cancel: function () {\n alert('用户拒绝授权获取地理位置');\n }\n });\n }\n }\n );\n }else {\n // let _this = this\n // var geolocation = new BMap.Geolocation();\n // geolocation.getCurrentPosition(function(r) {\n // if (this.getStatus() == BMAP_STATUS_SUCCESS) {\n // if(r.accuracy==null){\n // alert('您已拒绝地理位置授权');\n // //用户决绝地理位置授权\n // return;\n // }else{\n // const myGeo = new BMap.Geocoder()\n // myGeo.getLocation(new BMap.Point(r.point.lng, r.point.lat), data => {\n // alert('33');\n // })\n // }\n // }\n // })\n \n // if (navigator.geolocation) {\n // let options = {\n // enableHighAccuracy: true,\n // timeout: 5000,\n // maximumAge: 1000\n // }\n // navigator.geolocation.getCurrentPosition(onSuccess,onError,options);\n // function onSuccess(position) {\n // alert(\"keyi\")\n // //经度\n // longitude = position.coords.longitude;\n\n // //纬度\n // latitude = position.coords.latitude;\n // }\n\n // function onError(error) {\n // switch (error.code) {\n // case 1:\n // alert(\"位置服务被拒绝\");\n // break;\n\n // case 2:\n // alert(\"暂时获取不到位置信息\");\n // break;\n\n // case 3:\n // alert(\"获取信息超时\");\n // break;\n\n // case 4:\n // alert(\"未知错误\");\n // break;\n // }\n // }\n // } else {\n // alert('Geolocation is not supported by this browser.')\n // }\n }\n },\n\n getLocal(callback) {\n let that = this;\n let u = navigator.userAgent;\n let isiOS = !!u.match(/\\(i[^;]+;( U;)? CPU.+Mac OS X/);\n let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端\n if(isiOS){\n let result = callback.result;\n callback.result = result.toString();\n window.webkit.messageHandlers.getLocation.postMessage(callback);\n }else if(isAndroid){\n let _native = top.nativeAPI ? top.nativeAPI : nativeAPI;\n _native.getLocation({\n type: 'wgs84', // 默认为 wgs84 的 gps 坐标\n success: function (res) {\n let datas = JSON.parse(res);\n let latitude = datas.latitude; // 纬度,浮点数,范围为 90 ~ -90\n let longitude = datas.longitude; // 经度,浮点数,范围为 180 ~ -180。\n let bdPoint = new BMap.Point(longitude,latitude);\n let geoc = new BMap.Geocoder();\n //坐标逆解析为地址\n geoc.getLocation(bdPoint, function(rs){\n let addComp = rs.addressComponents;\n let locationName = addComp.province+ addComp.city + addComp.district + addComp.street + addComp.streetNumber;\n that.field.position = {\n latitude: latitude,\n longitude: longitude,\n address: locationName,\n }\n let data = JSON.stringify(that.field.position);\n that.field.value = data;\n });\n }\n });\n }\n },\n\n //地图定位精确方法\n /**\n * WGS84转GCj02\n * @param lng\n * @param lat\n * @returns {*[]}\n */\n wgs84togcj02(lng, lat) {\n let that=this\n // let x_PI = 3.14159265358979324 * 3000.0 / 180.0;\n let PI = 3.1415926535897932384626;\n let a = 6378245.0;\n let ee = 0.00669342162296594323;\n if (that.out_of_china(lng, lat)) {\n return [lng, lat]\n }else {\n let dlat = that.transformlat(lng - 105.0, lat - 35.0);\n let dlng = that.transformlng(lng - 105.0, lat - 35.0);\n let radlat = lat / 180.0 * PI;\n let magic = Math.sin(radlat);\n magic = 1 - ee * magic * magic;\n let sqrtmagic = Math.sqrt(magic);\n dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);\n dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);\n let mglat = Number(lat) + Number(dlat);\n let mglng = Number(lng) + Number(dlng);\n return [mglng, mglat]\n }\n },\n /**\n * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换\n * 即谷歌、高德 转 百度\n * @param lng\n * @param lat\n * @returns {*[]}\n */\n gcj02tobd09(lng, lat) {\n // let that = this\n let x_PI = 3.14159265358979324 * 3000.0 / 180.0;\n // let PI = 3.1415926535897932384626;\n // let a = 6378245.0;\n // let ee = 0.00669342162296594323;\n let z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI);\n let theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_PI);\n let bd_lng = z * Math.cos(theta) + 0.0065;\n let bd_lat = z * Math.sin(theta) + 0.006;\n return [bd_lng, bd_lat]\n },\n \n transformlat(lng, lat) {\n // let x_PI = 3.14159265358979324 * 3000.0 / 180.0;\n let PI = 3.1415926535897932384626;\n // let a = 6378245.0;\n // let ee = 0.00669342162296594323;\n let ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));\n ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;\n ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;\n ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;\n return ret\n },\n \n transformlng(lng, lat) {\n // let x_PI = 3.14159265358979324 * 3000.0 / 180.0;\n let PI = 3.1415926535897932384626;\n // let a = 6378245.0;\n // let ee = 0.00669342162296594323;\n let ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));\n ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;\n ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;\n ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;\n return ret\n },\n \n /**\n * 判断是否在国内,不在国内则不做偏移\n * @param lng\n * @param lat\n * @returns {boolean}\n */\n out_of_china(lng, lat) {\n return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false);\n },\n \n }\n};\n",null]}