UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

53 lines (46 loc) 1.77 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _typeof = require('@babel/runtime/helpers/typeof'); var msdk_msdk = require('../../msdk/msdk.js'); var location_locationInterface = require('../location-interface.js'); require('../../env/env.js'); require('../../loader/little-loader.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof); var SlugSdkLocation = /** @class */function () { function SlugSdkLocation() {} SlugSdkLocation.prototype.getLocation = function () { return new Promise(function (resolve, reject) { msdk_msdk.callJsBrowserAdapter().then(function () { if (_typeof__default["default"](window.customBrowserInterface) === 'object') { window.customBrowserInterface.getLocationInfo(function (result) { if ((result === null || result === void 0 ? void 0 : result.code) == 1) { var location_1 = { lat: result.latitude, lng: result.longitude }; resolve({ location: location_1, flag: location_locationInterface.LocationFlag.LocationSuccess }); } else { reject({ flag: result.code }); } }); } else { reject({ flag: location_locationInterface.LocationFlag.LocationFailed }); } })["catch"](function () { reject({ flag: location_locationInterface.LocationFlag.LocationFailed }); }); }); }; return SlugSdkLocation; }(); exports["default"] = SlugSdkLocation;