t-comm
Version:
专业、稳定、纯粹的工具库
57 lines (54 loc) • 2.02 kB
JavaScript
import { LocationFlag } from '../location-interface.mjs';
// import { post } from '../../network/post';
// 用特权sdk获取lbs地址
var TipSdkLocation = /** @class */function () {
function TipSdkLocation() {}
TipSdkLocation.prototype.getLocation = function (options) {
return new Promise(function (resolve, reject) {
var _a;
if (!options.fetchTipSdkLBSRequest) {
reject();
return;
}
(_a = options.fetchTipSdkLBSRequest) === null || _a === void 0 ? void 0 : _a.call(options).then(function (response) {
var _a, _b;
// }))
// post({
// url: 'https://a.igame.qq.com/pmdtrpc.commcgi.user.user/GetUserLbsInfo',
// showMsgToast: false,
// timeout: options.timeout,
// }).then((response) => {
if (response.lbsinfo) {
if (((_a = response.lbsinfo.gpsinfo) === null || _a === void 0 ? void 0 : _a.lat) && response.lbsinfo.gpsinfo.lng) {
var location_1 = {
lat: parseFloat("".concat(response.lbsinfo.gpsinfo.lat)),
lng: parseFloat("".concat(response.lbsinfo.gpsinfo.lng))
};
resolve({
location: location_1,
flag: LocationFlag.LocationSuccess
});
} else if (((_b = response.lbsinfo.netinfo) === null || _b === void 0 ? void 0 : _b.iplat) && response.lbsinfo.netinfo.iplng) {
var location_2 = {
lat: parseFloat("".concat(response.lbsinfo.netinfo.iplat)),
lng: parseFloat("".concat(response.lbsinfo.netinfo.iplng))
};
resolve({
location: location_2,
flag: LocationFlag.LocationIpSuccess
});
} else {
reject();
}
} else {
reject();
}
})["catch"](function (error) {
console.log('GetUserLbsInfo', error);
reject();
});
});
};
return TipSdkLocation;
}();
export { TipSdkLocation as default };