diff --git a/components/worker/delivery.vue b/components/worker/delivery.vue index fc80877..3839fd5 100644 --- a/components/worker/delivery.vue +++ b/components/worker/delivery.vue @@ -844,6 +844,12 @@ // 获取用户位置 getUserLocation(item) { if (!this.ensureLogin()) return + if (!item || !item.workerId) return + // #ifdef APP-PLUS + if (typeof plus == 'undefined' || !plus.geolocation) { + return + } + // #endif let that = this; uni.getLocation({ type: 'gcj02', @@ -856,7 +862,8 @@ geolocation: that.latitude + ',' + that.longitude }, false, 'post', 'application/x-www-form-urlencoded').then((res) => {}) - } + }, + fail: () => {} }); }, onReachPage() { diff --git a/manifest.json b/manifest.json index ecbd5f5..8816b14 100644 --- a/manifest.json +++ b/manifest.json @@ -23,7 +23,8 @@ "modules" : { "Camera" : {}, "Bluetooth" : {}, - "Push" : {} + "Push" : {}, + "Geolocation" : {} }, /* 应用发布信息 */ "distribute" : { diff --git a/pages/worker/index.vue b/pages/worker/index.vue index cabe4bb..7e055fb 100644 --- a/pages/worker/index.vue +++ b/pages/worker/index.vue @@ -1146,6 +1146,12 @@ }, // 获取用户位置 getUserLocation(id) { + if (!id) return + // #ifdef APP-PLUS + if (typeof plus == 'undefined' || !plus.geolocation) { + return + } + // #endif let that = this; uni.getLocation({ type: 'gcj02', // 返回国测局坐标,用于微信小程序地图组件