UNPKG

t-comm

Version:

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

51 lines (48 loc) 1.55 kB
import { LocationFlag } from '../location-interface.mjs'; // import { configWx } from '../../tools/weixin'; // 用微信sdk获取lbs定位 var WechatSdkLocation = /** @class */function () { function WechatSdkLocation() {} WechatSdkLocation.prototype.getLocation = function (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: 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(); }); }); }; return WechatSdkLocation; }(); export { WechatSdkLocation as default };