适配小程序代码结构
This commit is contained in:
58
unpackage/dist/dev/mp-weixin/uni_modules/json-gps/js_sdk/gps.js
vendored
Normal file
58
unpackage/dist/dev/mp-weixin/uni_modules/json-gps/js_sdk/gps.js
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../common/vendor.js");
|
||||
class Gps {
|
||||
constructor(arg) {
|
||||
this.lock = false;
|
||||
}
|
||||
async getLocation(param = {
|
||||
type: "wgs84"
|
||||
}) {
|
||||
return new Promise(async (callback) => {
|
||||
if (this.lock) {
|
||||
callback(false);
|
||||
return false;
|
||||
}
|
||||
this.lock = true;
|
||||
common_vendor.index.getLocation({
|
||||
...param,
|
||||
success: (res) => {
|
||||
this.lock = false;
|
||||
callback(res);
|
||||
},
|
||||
fail: async (err) => {
|
||||
common_vendor.index.showToast({
|
||||
title: "定位获取失败",
|
||||
icon: "none"
|
||||
});
|
||||
common_vendor.index.__f__("error", "at uni_modules/json-gps/js_sdk/gps.js:30", JSON.stringify(err));
|
||||
callback(false);
|
||||
if (err.errMsg == "getLocation:fail auth deny") {
|
||||
common_vendor.index.showModal({
|
||||
content: "应用无定位权限",
|
||||
confirmText: "前往设置",
|
||||
complete: (e) => {
|
||||
if (e.confirm) {
|
||||
common_vendor.index.openSetting({
|
||||
success(res) {
|
||||
common_vendor.index.__f__("log", "at uni_modules/json-gps/js_sdk/gps.js:46", res.authSetting);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.lock = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (err.errMsg == "getLocation:fail:ERROR_NOCELL&WIFI_LOCATIONSWITCHOFF") {
|
||||
common_vendor.index.showModal({
|
||||
content: "未开启定位权限,请前往手机系统设置中开启",
|
||||
showCancel: false,
|
||||
confirmText: "知道了"
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.Gps = Gps;
|
||||
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/uni_modules/json-gps/js_sdk/gps.js.map
|
||||
Reference in New Issue
Block a user