t-comm
Version:
专业、稳定、纯粹的工具库
66 lines (59 loc) • 2.27 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
var _createClass = require('@babel/runtime/helpers/createClass');
var location_locationInterface = require('../location-interface.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
// import { configWx } from '../../tools/weixin';
// 用微信sdk获取lbs定位
var WechatSdkLocation = /*#__PURE__*/function () {
function WechatSdkLocation() {
_classCallCheck__default["default"](this, WechatSdkLocation);
}
return _createClass__default["default"](WechatSdkLocation, [{
key: "getLocation",
value: function getLocation(options) {
return new Promise(function (resolve, reject) {
var _a;
if (!options.configWx) {
reject();
return;
}
var locationSuccessFlag = false;
(_a = options.configWx) === null || _a === void 0 ? void 0 : _a.call(options, ['getLocation', 'openLocation'], []).then(function (wx) {
var tmp = {
type: 'gcj02',
success: function success(res) {
var location = {
lat: parseFloat(res.latitude),
lng: parseFloat(res.longitude)
};
resolve({
location: location,
flag: location_locationInterface.LocationFlag.LocationSuccess
});
locationSuccessFlag = true;
},
fail: function fail(error) {
console.log('WechatSdkLocation', error);
reject();
locationSuccessFlag = false;
},
complete: function complete() {
if (!locationSuccessFlag) {
reject();
}
}
};
wx.getLocation(tmp);
})["catch"](function (error) {
console.log('WechatSdkLocation', error);
reject();
});
});
}
}]);
}();
exports["default"] = WechatSdkLocation;