UNPKG

wb-positioning-jssdk

Version:

Produce universal library with webpack and es6

2 lines 24.6 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Positioning-jssdk",[],t):"object"==typeof exports?exports["Positioning-jssdk"]=t():e["Positioning-jssdk"]=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function r(e,t){return!t||"object"!==o(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=function(e){var t,n;return n=t=function(t){function n(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),c(e=r(this,(n.__proto__||Object.getPrototypeOf(n)).call(this)),"geo_success",function(t){e.startSuccess({code:1,msg:"gps定位启动"});var n=t.coords,o={isOutdoor:1,longitude:n.longitude,latitude:n.latitude,accuracy:n.accuracy,locType:"gps",timestamp:t.timestamp};e.onSuccessGps(o)}),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(n,e),function(e,t,n){t&&i(e.prototype,t),n&&i(e,n)}(n,[{key:"checkGPS",value:function(){"geolocation"in navigator&&(this.initGps=!0,this.initSuccess())}},{key:"startGpsSearch",value:function(){console.log("jinru gps"),n.gpsWatchId=navigator.geolocation.watchPosition(this.geo_success,n.geo_error,{enableHighAccuracy:!0})}},{key:"stopGpsSearch",value:function(){console.log("qingchu"),navigator.geolocation.clearWatch(n.gpsWatchId),this.stopLocationComplete({code:1,msg:"gps定位停止"})}}],[{key:"geo_error",value:function(e){throw e}}]),n}(),c(t,"gpsWatchId",null),n};t.default=s,e.exports=t.default},function(e,t){!function(t,n){e.exports=function(e,t){function n(t,n,o){e.WeixinJSBridge?WeixinJSBridge.invoke(t,i(n),function(e){a(t,e,o)}):s(t,o)}function o(t,n,o){e.WeixinJSBridge?WeixinJSBridge.on(t,function(e){o&&o.trigger&&o.trigger(e),a(t,e,n)}):s(t,o||n)}function i(e){return(e=e||{}).appId=P.appId,e.verifyAppId=P.appId,e.verifySignType="sha1",e.verifyTimestamp=P.timestamp+"",e.verifyNonceStr=P.nonceStr,e.verifySignature=P.signature,e}function r(e){return{timeStamp:e.timestamp+"",nonceStr:e.nonceStr,package:e.package,paySign:e.paySign,signType:e.signType||"SHA1"}}function a(e,t,n){"openEnterpriseChat"==e&&(t.errCode=t.err_code),delete t.err_code,delete t.err_desc,delete t.err_detail;var o=t.errMsg;o||(o=t.err_msg,delete t.err_msg,o=function(e,t){var n=e,o=p[n];o&&(n=o);var i="ok";if(t){var r=t.indexOf(":");"confirm"==(i=t.substring(r+1))&&(i="ok"),"failed"==i&&(i="fail"),-1!=i.indexOf("failed_")&&(i=i.substring(7)),-1!=i.indexOf("fail_")&&(i=i.substring(5)),"access denied"!=(i=(i=i.replace(/_/g," ")).toLowerCase())&&"no permission to execute"!=i||(i="permission denied"),"config"==n&&"function not exist"==i&&(i="ok"),""==i&&(i="fail")}return t=n+":"+i}(e,o),t.errMsg=o),(n=n||{})._complete&&(n._complete(t),delete n._complete),o=t.errMsg||"",P.debug&&!n.isInnerInvoke&&alert(JSON.stringify(t));var i=o.indexOf(":");switch(o.substring(i+1)){case"ok":n.success&&n.success(t);break;case"cancel":n.cancel&&n.cancel(t);break;default:n.fail&&n.fail(t)}n.complete&&n.complete(t)}function c(e){if(e){for(var t=0,n=e.length;t<n;++t){var o=e[t],i=f[o];i&&(e[t]=i)}return e}}function s(e,t){if(!(!P.debug||t&&t.isInnerInvoke)){var n=p[e];n&&(e=n),t&&t._complete&&delete t._complete,console.log('"'+e+'",',t||"")}}function u(){return(new Date).getTime()}function l(t){b&&(e.WeixinJSBridge?t():g.addEventListener&&g.addEventListener("WeixinJSBridgeReady",t,!1))}function d(){C.invoke||(C.invoke=function(t,n,o){e.WeixinJSBridge&&WeixinJSBridge.invoke(t,i(n),o)},C.on=function(t,n){e.WeixinJSBridge&&WeixinJSBridge.on(t,n)})}if(!e.jWeixin){var f={config:"preVerifyJSAPI",onMenuShareTimeline:"menu:share:timeline",onMenuShareAppMessage:"menu:share:appmessage",onMenuShareQQ:"menu:share:qq",onMenuShareWeibo:"menu:share:weiboApp",onMenuShareQZone:"menu:share:QZone",previewImage:"imagePreview",getLocation:"geoLocation",openProductSpecificView:"openProductViewWithPid",addCard:"batchAddCard",openCard:"batchViewCard",chooseWXPay:"getBrandWCPayRequest",openEnterpriseRedPacket:"getRecevieBizHongBaoRequest",startSearchBeacons:"startMonitoringBeacons",stopSearchBeacons:"stopMonitoringBeacons",onSearchBeacons:"onBeaconsInRange",consumeAndShareCard:"consumedShareCard",openAddress:"editAddress"},p=function(){var e={};for(var t in f)e[f[t]]=t;return e}(),g=e.document,m=g.title,h=navigator.userAgent.toLowerCase(),y=navigator.platform.toLowerCase(),v=!(!y.match("mac")&&!y.match("win")),S=-1!=h.indexOf("wxdebugger"),b=-1!=h.indexOf("micromessenger"),w=-1!=h.indexOf("android"),_=-1!=h.indexOf("iphone")||-1!=h.indexOf("ipad"),I=function(){var e=h.match(/micromessenger\/(\d+\.\d+\.\d+)/)||h.match(/micromessenger\/(\d+\.\d+)/);return e?e[1]:""}(),k={initStartTime:u(),initEndTime:0,preVerifyStartTime:0,preVerifyEndTime:0},T={version:1,appId:"",initTime:0,preVerifyTime:0,networkType:"",isPreVerifyOk:1,systemType:_?1:w?2:-1,clientVersion:I,url:encodeURIComponent(location.href)},P={},M={_completes:[]},O={state:0,data:{}};l(function(){k.initEndTime=u()});var x=!1,L=[],C={config:function(e){P=e,s("config",e);var t=!1!==P.check;l(function(){if(t)n(f.config,{verifyJsApiList:c(P.jsApiList)},function(){M._complete=function(e){k.preVerifyEndTime=u(),O.state=1,O.data=e},M.success=function(e){T.isPreVerifyOk=0},M.fail=function(e){M._fail?M._fail(e):O.state=-1};var e=M._completes;return e.push(function(){!function(e){if(!(v||S||P.debug||I<"6.0.2"||T.systemType<0)){var t=new Image;T.appId=P.appId,T.initTime=k.initEndTime-k.initStartTime,T.preVerifyTime=k.preVerifyEndTime-k.preVerifyStartTime,C.getNetworkType({isInnerInvoke:!0,success:function(e){T.networkType=e.networkType;var n="https://open.weixin.qq.com/sdk/report?v="+T.version+"&o="+T.isPreVerifyOk+"&s="+T.systemType+"&c="+T.clientVersion+"&a="+T.appId+"&n="+T.networkType+"&i="+T.initTime+"&p="+T.preVerifyTime+"&u="+T.url;t.src=n}})}}()}),M.complete=function(t){for(var n=0,o=e.length;n<o;++n)e[n]();M._completes=[]},M}()),k.preVerifyStartTime=u();else{O.state=1;for(var e=M._completes,o=0,i=e.length;o<i;++o)e[o]();M._completes=[]}}),d()},ready:function(e){0!=O.state?e():(M._completes.push(e),!b&&P.debug&&e())},error:function(e){I<"6.0.2"||(-1==O.state?e(O.data):M._fail=e)},checkJsApi:function(e){n("checkJsApi",{jsApiList:c(e.jsApiList)},(e._complete=function(e){if(w){var t=e.checkResult;t&&(e.checkResult=JSON.parse(t))}e=function(e){var t=e.checkResult;for(var n in t){var o=p[n];o&&(t[o]=t[n],delete t[n])}return e}(e)},e))},onMenuShareTimeline:function(e){o(f.onMenuShareTimeline,{complete:function(){n("shareTimeline",{title:e.title||m,desc:e.title||m,img_url:e.imgUrl||"",link:e.link||location.href,type:e.type||"link",data_url:e.dataUrl||""},e)}},e)},onMenuShareAppMessage:function(e){o(f.onMenuShareAppMessage,{complete:function(t){"favorite"===t.scene?n("sendAppMessage",{title:e.title||m,desc:e.desc||"",link:e.link||location.href,img_url:e.imgUrl||"",type:e.type||"link",data_url:e.dataUrl||""}):n("sendAppMessage",{title:e.title||m,desc:e.desc||"",link:e.link||location.href,img_url:e.imgUrl||"",type:e.type||"link",data_url:e.dataUrl||""},e)}},e)},onMenuShareQQ:function(e){o(f.onMenuShareQQ,{complete:function(){n("shareQQ",{title:e.title||m,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareWeibo:function(e){o(f.onMenuShareWeibo,{complete:function(){n("shareWeiboApp",{title:e.title||m,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareQZone:function(e){o(f.onMenuShareQZone,{complete:function(){n("shareQZone",{title:e.title||m,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},updateTimelineShareData:function(e){n("updateTimelineShareData",{title:e.title,link:e.link,imgUrl:e.imgUrl},e)},updateAppMessageShareData:function(e){n("updateAppMessageShareData",{title:e.title,desc:e.desc,link:e.link,imgUrl:e.imgUrl},e)},startRecord:function(e){n("startRecord",{},e)},stopRecord:function(e){n("stopRecord",{},e)},onVoiceRecordEnd:function(e){o("onVoiceRecordEnd",e)},playVoice:function(e){n("playVoice",{localId:e.localId},e)},pauseVoice:function(e){n("pauseVoice",{localId:e.localId},e)},stopVoice:function(e){n("stopVoice",{localId:e.localId},e)},onVoicePlayEnd:function(e){o("onVoicePlayEnd",e)},uploadVoice:function(e){n("uploadVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadVoice:function(e){n("downloadVoice",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},translateVoice:function(e){n("translateVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},chooseImage:function(e){n("chooseImage",{scene:"1|2",count:e.count||9,sizeType:e.sizeType||["original","compressed"],sourceType:e.sourceType||["album","camera"]},(e._complete=function(e){if(w){var t=e.localIds;try{t&&(e.localIds=JSON.parse(t))}catch(e){}}},e))},getLocation:function(e){},previewImage:function(e){n(f.previewImage,{current:e.current,urls:e.urls},e)},uploadImage:function(e){n("uploadImage",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadImage:function(e){n("downloadImage",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},getLocalImgData:function(e){!1===x?(x=!0,n("getLocalImgData",{localId:e.localId},(e._complete=function(e){if(x=!1,L.length>0){var t=L.shift();wx.getLocalImgData(t)}},e))):L.push(e)},getNetworkType:function(e){n("getNetworkType",{},(e._complete=function(e){e=function(e){var t=e.errMsg;e.errMsg="getNetworkType:ok";var n=e.subtype;if(delete e.subtype,n)e.networkType=n;else{var o=t.indexOf(":"),i=t.substring(o+1);switch(i){case"wifi":case"edge":case"wwan":e.networkType=i;break;default:e.errMsg="getNetworkType:fail"}}return e}(e)},e))},openLocation:function(e){n("openLocation",{latitude:e.latitude,longitude:e.longitude,name:e.name||"",address:e.address||"",scale:e.scale||28,infoUrl:e.infoUrl||""},e)},getLocation:function(e){e=e||{},n(f.getLocation,{type:e.type||"wgs84"},(e._complete=function(e){delete e.type},e))},hideOptionMenu:function(e){n("hideOptionMenu",{},e)},showOptionMenu:function(e){n("showOptionMenu",{},e)},closeWindow:function(e){n("closeWindow",{},e=e||{})},hideMenuItems:function(e){n("hideMenuItems",{menuList:e.menuList},e)},showMenuItems:function(e){n("showMenuItems",{menuList:e.menuList},e)},hideAllNonBaseMenuItem:function(e){n("hideAllNonBaseMenuItem",{},e)},showAllNonBaseMenuItem:function(e){n("showAllNonBaseMenuItem",{},e)},scanQRCode:function(e){n("scanQRCode",{needResult:(e=e||{}).needResult||0,scanType:e.scanType||["qrCode","barCode"]},(e._complete=function(e){if(_){var t=e.resultStr;if(t){var n=JSON.parse(t);e.resultStr=n&&n.scan_code&&n.scan_code.scan_result}}},e))},openAddress:function(e){n(f.openAddress,{},(e._complete=function(e){e=function(e){return e.postalCode=e.addressPostalCode,delete e.addressPostalCode,e.provinceName=e.proviceFirstStageName,delete e.proviceFirstStageName,e.cityName=e.addressCitySecondStageName,delete e.addressCitySecondStageName,e.countryName=e.addressCountiesThirdStageName,delete e.addressCountiesThirdStageName,e.detailInfo=e.addressDetailInfo,delete e.addressDetailInfo,e}(e)},e))},openProductSpecificView:function(e){n(f.openProductSpecificView,{pid:e.productId,view_type:e.viewType||0,ext_info:e.extInfo},e)},addCard:function(e){for(var t=e.cardList,o=[],i=0,r=t.length;i<r;++i){var a=t[i],c={card_id:a.cardId,card_ext:a.cardExt};o.push(c)}n(f.addCard,{card_list:o},(e._complete=function(e){var t=e.card_list;if(t){for(var n=0,o=(t=JSON.parse(t)).length;n<o;++n){var i=t[n];i.cardId=i.card_id,i.cardExt=i.card_ext,i.isSuccess=!!i.is_succ,delete i.card_id,delete i.card_ext,delete i.is_succ}e.cardList=t,delete e.card_list}},e))},chooseCard:function(e){n("chooseCard",{app_id:P.appId,location_id:e.shopId||"",sign_type:e.signType||"SHA1",card_id:e.cardId||"",card_type:e.cardType||"",card_sign:e.cardSign,time_stamp:e.timestamp+"",nonce_str:e.nonceStr},(e._complete=function(e){e.cardList=e.choose_card_info,delete e.choose_card_info},e))},openCard:function(e){for(var t=e.cardList,o=[],i=0,r=t.length;i<r;++i){var a=t[i],c={card_id:a.cardId,code:a.code};o.push(c)}n(f.openCard,{card_list:o},e)},consumeAndShareCard:function(e){n(f.consumeAndShareCard,{consumedCardId:e.cardId,consumedCode:e.code},e)},chooseWXPay:function(e){n(f.chooseWXPay,r(e),e)},openEnterpriseRedPacket:function(e){n(f.openEnterpriseRedPacket,r(e),e)},startSearchBeacons:function(e){n(f.startSearchBeacons,{ticket:e.ticket},e)},stopSearchBeacons:function(e){n(f.stopSearchBeacons,{},e)},onSearchBeacons:function(e){o(f.onSearchBeacons,e)},openEnterpriseChat:function(e){n("openEnterpriseChat",{useridlist:e.userIds,chatname:e.groupName},e)},launchMiniProgram:function(e){n("launchMiniProgram",{targetAppId:e.targetAppId,path:function(e){if("string"==typeof e&&e.length>0){var t=e.split("?")[0],n=e.split("?")[1];return t+=".html",void 0!==n?t+"?"+n:t}}(e.path),envVersion:e.envVersion},e)},miniProgram:{navigateBack:function(e){e=e||{},l(function(){n("invokeMiniProgramAPI",{name:"navigateBack",arg:{delta:e.delta||1}},e)})},navigateTo:function(e){l(function(){n("invokeMiniProgramAPI",{name:"navigateTo",arg:{url:e.url}},e)})},redirectTo:function(e){l(function(){n("invokeMiniProgramAPI",{name:"redirectTo",arg:{url:e.url}},e)})},switchTab:function(e){l(function(){n("invokeMiniProgramAPI",{name:"switchTab",arg:{url:e.url}},e)})},reLaunch:function(e){l(function(){n("invokeMiniProgramAPI",{name:"reLaunch",arg:{url:e.url}},e)})},postMessage:function(e){l(function(){n("invokeMiniProgramAPI",{name:"postMessage",arg:e.data||{}},e)})},getEnv:function(t){l(function(){t({miniprogram:"miniprogram"===e.__wxjs_environment})})}}},B=1,j={};return g.addEventListener("error",function(e){if(!w){var t=e.target,n=t.tagName,o=t.src;if(("IMG"==n||"VIDEO"==n||"AUDIO"==n||"SOURCE"==n)&&-1!=o.indexOf("wxlocalresource://")){e.preventDefault(),e.stopPropagation();var i=t["wx-id"];if(i||(i=B++,t["wx-id"]=i),j[i])return;j[i]=!0,wx.ready(function(){wx.getLocalImgData({localId:o,success:function(e){t.src=e.localData}})})}}},!0),g.addEventListener("load",function(e){if(!w){var t=e.target,n=t.tagName;if(t.src,"IMG"==n||"VIDEO"==n||"AUDIO"==n||"SOURCE"==n){var o=t["wx-id"];o&&(j[o]=!1)}}},!0),t&&(e.wx=e.jWeixin=C),C}}(t)}(window)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e){return e&&e.__esModule?e:{default:e}}(n(1));function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){a(e,t,n[t])})}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function s(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){var t="url=".concat(encodeURIComponent(window.location.href.split("#")[0])),n="ios",i=[],a=null,l=navigator.userAgent.toLowerCase();return/iphone|ipad|ipod/.test(l)?n="ios":/android/.test(l)&&(n="android"),function(l){function d(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,d),s(this,(d.__proto__||Object.getPrototypeOf(d)).call(this))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(d,e),function(e,t,n){t&&c(e.prototype,t),n&&c(e,n)}(d,[{key:"getSignature",value:function(){var e=this;console.log("请求签名"),window.onunload=function(){o.default.stopSearchBeacons()},fetch("https://map.parkbobo.com/location/weixin/v1/jsSdkSign",{method:"PUT",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t}).then(function(e){return e.json()}).then(function(t){e.configWx(t.data),e.initIbeacon=!0,e.initSuccess()}).catch(function(t){e.initError(t)})}},{key:"configWx",value:function(e){var t=this;o.default.config({debug:!1,appId:e.appid,timestamp:e.timestamp,nonceStr:e.nonceStr,signature:e.signature,beta:!0,jsApiList:["openWXDeviceLib","closeWXDeviceLib","onWXDeviceBluetoothStateChange","startSearchBeacons","stopSearchBeacons","onSearchBeacons","startRecord","stopRecord","translateVoice","onMenuShareAppMessage","getLocation"]}),o.default.error(function(e){t.initError(e)})}},{key:"stopIbeaconSearch",value:function(){var e=this;o.default.stopSearchBeacons({complete:function(){console.log("停止蓝牙"),e.stopLocationComplete({code:0,msg:"蓝牙停止"})}})}},{key:"startIbeaconSearch",value:function(){var e=this;console.log("进入蓝牙"),o.default.ready(function(){var t=Date.now(),n=!1,r=void 0;window.addEventListener("devicemotion",function(){Date.now()-t>=80&&(t=Date.now(),!1===n&&o.default.stopSearchBeacons({complete:function(){console.log("启动蓝牙搜索"),i=[],e.searchIbeacon()},fail:function(e){console.log("stop fail",e)}}),n=!0,r&&clearTimeout(r),r=setTimeout(function(){n=!1,o.default.stopSearchBeacons()},500))}),e.initGps?e.onSearchBeaconsWithGps():e.onSearchBeacons()})}},{key:"searchIbeacon",value:function(){var e=this;o.default.startSearchBeacons({ticket:"",complete:function(t){console.log("开启成功",t),e.startSuccess({code:0,msg:"室内定位启动,".concat(t.errMsg)});var n=t.errMsg;if("startSearchBeacons:already started"===n)return o.default.stopSearchBeacons(function(){e.searchIbeacon()});"startSearchBeacons:system unsupported"===n&&e.searchIbeacon(),"startSearchBeacons:bluetooth power off"===n?e.startLocationError("蓝牙未打开,请打开蓝牙后,重新打开页面"):"startSearchBeacons:location service disable"===n&&e.startLocationError("地理位置服务未打开")},fail:function(e){console.log("开启失败",e)}})}},{key:"onSearchBeacons",value:function(){var e=this;o.default.onSearchBeacons({complete:function(t){e.getIbeaconPoints(t)}})}},{key:"onSearchBeaconsWithGps",value:function(){var e=this;console.log("进入蓝牙定时搜索"),o.default.onSearchBeacons({complete:function(t){e.getIbeaconPoints(t),e.currentLocation="ibeacon",a&&clearTimeout(a),a=setTimeout(function(){console.log("定时器执行",e),e.currentLocation="gps"},5e3)}})}},{key:"getIbeaconPoints",value:function(e){var t=this,o=e.beacons&&e.beacons.filter(function(e){return 0!=e.rssi}).map(function(e){return{rssi:e.rssi,device:"".concat(e.major,"_").concat(e.minor)}});if(0===o.length);else{o=JSON.stringify([o]);var i="mapId=".concat(this.mapId,"&datajson=").concat(o,"\n &interval=").concat(500,"&type=wx_").concat(n);fetch("https://map.parkbobo.com/location/weka/v1/classify",{method:"PUT",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i}).then(function(e){return e.json()}).then(function(e){if(0==e.code){var n=e.data,o=t.setPolygonLocation(n),i=r({isOutdoor:0,longitude:n.lon,latitude:n.lat,buildingId:n.building,level:n.level,fiducialLat:n.fiducialLat,fiducialLon:n.fiducialLon,locType:"ibeacon"},o);t.onSuccessIbeacon(i)}}).catch(function(e){console.log(e)})}}},{key:"setPolygonLocation",value:function(e){if(i.length<3)return i.push(e),{polygonLon:0,polygonLat:0};i.push(e);var t=i&&i.map(function(e,t){return r({},e,{timestamp:(new Date).getTime()+2e3*t})}),n=this.polygonV2(t);return i.shift(),n}},{key:"polygonV2",value:function(e){for(var t=0,n=0,o=0,i=0;i<e.length;i++)t+=e[i].timestamp,n+=e[i].lon*e[i].timestamp,o+=e[i].lat*e[i].timestamp;return{polygonLon:n/t,polygonLat:o/t}}}]),d}()};t.default=l,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o,i=r(n(2));function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=new((0,r(n(0)).default)(o=(0,i.default)(o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c(this,"initIbeacon",!1),c(this,"initGps",!1),c(this,"ibeaconCoords",null),c(this,"gpsCoords",null),c(this,"locType",[])}return function(e,t,n){t&&a(e.prototype,t),n&&a(e,n)}(e,[{key:"init",value:function(e){var t=e.timeout,n=e.locType,o=e.mapId,i=e.complete,r=void 0===i?function(){}:i,a=e.error,c=void 0===a?function(){}:a;this.mapId=o,this.timeout=t,this.locType=n,this.initComplete=r,this.initError=c,n&&n.includes("gps")&&this.checkGPS(),n&&n.includes("ibeacon")&&this.getSignature()}},{key:"initSuccess",value:function(){this.locType.includes("ibeacon")&&!this.initIbeacon||this.locType.includes("gps")&&!this.initGps||this.initComplete()}},{key:"startLocation",value:function(e){var t=e.complete,n=void 0===t?function(){}:t,o=e.error,i=void 0===o?function(){}:o;this.startLocationComplete=n,this.startLocationError=i,this.locType&&this.locType.includes("gps")&&this.startGpsSearch(),this.locType&&this.locType.includes("ibeacon")&&this.startIbeaconSearch()}},{key:"startSuccess",value:function(e){this.startLocationComplete(e)}},{key:"stopLocation",value:function(e){var t=e.complete,n=void 0===t?function(){}:t;e.error;this.stopLocationComplete=n,this.locType&&this.locType.includes("gps")&&this.stopGpsSearch(),this.locType&&this.locType.includes("ibeacon")&&this.stopIbeaconSearch()}},{key:"onLocation",value:function(e){var t=e.complete,n=void 0===t?function(){}:t;e.error;this.onLocationComplete=n}},{key:"onSuccessGps",value:function(e){this.gpsCoords=e,this.initIbeacon&&"ibeacon"===this.currentLocation||this.onLocationComplete(this.gpsCoords)}},{key:"onSuccessIbeacon",value:function(e){this.ibeaconCoords=e,this.onLocationComplete(this.ibeaconCoords)}}]),e}())||o)||o);t.default=s,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e){return e&&e.__esModule?e:{default:e}}(n(3)).default;t.default=o,e.exports=t.default}])}); //# sourceMappingURL=Positioning-jssdk.min.js.map