diff --git a/config/index.js b/config/index.js index 3f150af..45b994e 100644 --- a/config/index.js +++ b/config/index.js @@ -1,4 +1,4 @@ -const env = 'test'; +const env = 'dev'; const configs = { dev: { apiBaseUrl: 'https://warehouse.szjixun.cn/oa_backend', @@ -9,7 +9,7 @@ const configs = { h5Url: 'http://114.218.158.24:8042/#/' }, prod: { - apiBaseUrl: 'https://oa-a.szjixun.cn/#/', + apiBaseUrl: 'https://oa-a.szjixun.cn', h5Url: 'https://oa-a.szjixun.cn/#/' }, } diff --git a/unpackage/dist/dev/app-plus/app-service.js b/unpackage/dist/dev/app-plus/app-service.js index 638857c..776cffa 100644 --- a/unpackage/dist/dev/app-plus/app-service.js +++ b/unpackage/dist/dev/app-plus/app-service.js @@ -49,7 +49,7 @@ if (uni.restoreGlobal) { const onHide = /* @__PURE__ */ createHook(ON_HIDE); const onLaunch = /* @__PURE__ */ createHook(ON_LAUNCH); const onLoad = /* @__PURE__ */ createHook(ON_LOAD); - const env = "test"; + const env = "dev"; const configs = { dev: { apiBaseUrl: "https://warehouse.szjixun.cn/oa_backend", @@ -60,14 +60,110 @@ if (uni.restoreGlobal) { h5Url: "http://114.218.158.24:8042/#/" }, prod: { - apiBaseUrl: "https://oa-a.szjixun.cn/#/", + apiBaseUrl: "https://oa-a.szjixun.cn", h5Url: "https://oa-a.szjixun.cn/#/" } }; const config = configs[env]; + const sendWebWiew = (refValue, paramValue, callName = "onReceive") => { + if (!refValue) { + formatAppLog("error", "at utils/communicate/index.js:3", "evalJs: The reference to the webview is not provided or is null."); + return; + } + formatAppLog("log", "at utils/communicate/index.js:6", "测试", refValue.evalJs); + if (typeof refValue.evalJs !== "function") { + formatAppLog("error", "at utils/communicate/index.js:8", "evalJs: The evalJs method is not available on the provided reference."); + return; + } + try { + const jsonString = JSON.stringify(paramValue); + const jsCode = `window.${callName}(${jsonString})`; + refValue.evalJs(jsCode); + } catch (error) { + formatAppLog("error", "at utils/communicate/index.js:18", "evalJs: An error occurred while trying to stringify the parameter value or while invoking evalJs.", error); + } + }; const receiveWebView = (e2) => { return e2.detail.data[0]; }; + const location$1 = { + //检测是否开启系统定位权限 + hasLocationPermission() { + let system = uni.getSystemInfoSync(); + if (system.platform === "android") { + let context = plus.android.importClass("android.content.Context"); + let locationManager = plus.android.importClass("android.location.LocationManager"); + let main = plus.android.runtimeMainActivity(); + let service = main.getSystemService(context.LOCATION_SERVICE); + if (service.isProviderEnabled(locationManager.GPS_PROVIDER)) + return true; + else { + uni.showModal({ + title: "友情提示", + content: "请开启位置服务功能", + success: (e2) => { + if (e2.confirm) { + let Intent = plus.android.importClass("android.content.Intent"); + let Settings = plus.android.importClass("android.provider.Settings"); + let intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); + main.startActivity(intent); + } + } + }); + } + } else if (system.platform === "ios") { + let cllocationManger = plus.ios.import("CLLocationManager"); + let enable = cllocationManger.locationServicesEnabled(); + let status = cllocationManger.authorizationStatus(); + plus.ios.deleteObject(cllocationManger); + if (enable && status != 2) + return true; + else { + uni.showModal({ + title: "友情提示", + content: "请前往设置-定位服务打开定位服务功能", + success: (e2) => { + if (e2.confirm) { + let UIApplication = plus.ios.import("UIApplication"); + let application = UIApplication.sharedApplication(); + let NSURL = plus.ios.import("NSURL"); + let setting = NSURL.URLWithString("app-settings:"); + application.openURL(setting); + plus.ios.deleteObject(setting); + plus.ios.deleteObject(NSURL); + plus.ios.deleteObject(application); + } + } + }); + } + } + return false; + }, + /**开启后台持续获取定位功能 + * successCallBack:成功回调函数 + *failCallBack:失败回调函数 + *maximumAge:获取定位间隔时间 + */ + startLocationService(successCallBack = () => { + }, failCallBack = () => { + }, options) { + if (this.hasLocationPermission()) { + let locationWatcherId = plus.geolocation.watchPosition((position) => { + successCallBack({ + locationWatcherId, + position: position.coords + }); + }, function(e2) { + formatAppLog("log", "at utils/location.js:68", e2, "定位失败"); + failCallBack(e2); + }, options); + } + }, + //关闭定位功能 + closeLocationService(locationWatcherId) { + plus.geolocation.clearWatch(locationWatcherId); + } + }; uni; const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; @@ -96,10 +192,17 @@ if (uni.restoreGlobal) { const webViewObj = vue.ref(null); onLoad(() => { }); + const handleBackButton = () => { + sendWebWiew(webViewObj.value, { turnBack: 1 }); + }; + let LocationId2 = null; onShow(() => { + plus.key.addEventListener("backbutton", handleBackButton, false); uni.onNetworkStatusChange(networkStatusChange); }); onHide(() => { + plus.geolocation.clearWatch(LocationId2); + plus.key.removeEventListener("backbutton", handleBackButton, false); uni.offNetworkStatusChange(networkStatusChange); }); const webLoad = (e2) => { @@ -117,17 +220,15 @@ if (uni.restoreGlobal) { //webview的高度 }); const systemInfo = uni.getSystemInfoSync(); - uni.getLocation({ - type: "gcj02", - geocode: false, - isHighAccuracy: false, - success: async (res) => { - const jsonString = JSON.stringify({ ...res, systemInfo }); - webViewObj.value.evalJS(`window.onReceive(${jsonString})`); - }, - fail: (e3) => { - formatAppLog("log", "at pages/index/index.vue:111", e3); - } + LocationId2 = location$1.startLocationService((res) => { + const jsonString = JSON.stringify({ ...res.position, systemInfo }); + formatAppLog("log", "at pages/index/index.vue:96", "测试", jsonString); + webViewObj.value.evalJS(`window.onReceive(${jsonString})`); + }, () => { + }, { + geocode: true, + coordsType: "gcj02", + enableHighAccuracy: true }); } } @@ -479,7 +580,7 @@ if (uni.restoreGlobal) { function I(e2) { return e2 && "string" == typeof e2 ? JSON.parse(e2) : e2; } - const S = true, b = "app", A = I(define_process_env_UNI_SECURE_NETWORK_CONFIG_default), P = b, T = I('{\n "address": [\n "127.0.0.1",\n "192.168.56.1",\n "192.168.88.23"\n ],\n "debugPort": 9000,\n "initialLaunchType": "local",\n "servePort": 7000,\n "skipFiles": [\n "/**",\n "C:/Users/37363/Downloads/HBuilderX.4.08.2024040127/HBuilderX/plugins/unicloud/**/*.js"\n ]\n}\n'), C = I('[{"provider":"aliyun","spaceName":"oabase","spaceId":"mp-edf38b0d-bc9a-4e81-9a15-f55995ccca70","clientSecret":"ty1X79FB2pMuAQUzaQBKXA==","endpoint":"https://api.next.bspapp.com"}]') || []; + const S = true, b = "app", A = I(define_process_env_UNI_SECURE_NETWORK_CONFIG_default), P = b, T = I('{\n "address": [\n "127.0.0.1",\n "192.168.56.1",\n "192.168.88.49"\n ],\n "debugPort": 9001,\n "initialLaunchType": "local",\n "servePort": 7001,\n "skipFiles": [\n "/**",\n "C:/Users/37363/Downloads/HBuilderX.4.08.2024040127/HBuilderX/plugins/unicloud/**/*.js"\n ]\n}\n'), C = I('[{"provider":"aliyun","spaceName":"oabase","spaceId":"mp-edf38b0d-bc9a-4e81-9a15-f55995ccca70","clientSecret":"ty1X79FB2pMuAQUzaQBKXA==","endpoint":"https://api.next.bspapp.com"}]') || []; let O = ""; try { O = "__UNI__4796942";