From fe23b60be622d36291eba9849da82dda80ae3604 Mon Sep 17 00:00:00 2001 From: handongxun Date: Fri, 13 Mar 2020 14:06:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20map=20API=20getCenterLocation,getRegion?= =?UTF-8?q?=20=E4=B8=8D=E5=9B=9E=E8=B0=83=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/api/context/create-map-context.js | 18 ++++-------------- .../app-plus/service/framework/app.js | 11 ++++++++--- src/shared/callback.js | 7 ++++--- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/core/service/api/context/create-map-context.js b/src/core/service/api/context/create-map-context.js index 74dfd64ca..466de917f 100644 --- a/src/core/service/api/context/create-map-context.js +++ b/src/core/service/api/context/create-map-context.js @@ -18,7 +18,7 @@ UniServiceJSBridge.subscribe('onMapMethodCallback', ({ callback.invoke(callbackId, data) }) -const methods = ['getCenterLocation', 'getScale', 'getRegion'] +const methods = ['getCenterLocation', 'getScale', 'getRegion', 'includePoints', 'translateMarker'] export class MapContext { constructor (id, pageVm) { @@ -29,14 +29,6 @@ export class MapContext { moveToLocation () { operateMapPlayer(this.id, this.pageVm, 'moveToLocation') } - - includePoints (args) { - operateMapPlayer(this.id, this.pageVm, 'includePoints', args) - } - - translateMarker (args) { - operateMapPlayer(this.id, this.pageVm, 'translateMarker', args) - } } MapContext.prototype.$getAppMap = function () { @@ -44,11 +36,9 @@ MapContext.prototype.$getAppMap = function () { } methods.forEach(function (method) { - MapContext.prototype[method] = callback.warp(function (options, callbackId) { - operateMapPlayer(this.id, this.pageVm, method, { - options, - callbackId - }) + MapContext.prototype[method] = callback.warp(function (options, callbackId) { + options.callbackId = callbackId + operateMapPlayer(this.id, this.pageVm, method, options) }) }) diff --git a/src/platforms/app-plus/service/framework/app.js b/src/platforms/app-plus/service/framework/app.js index a46c88f01..198179609 100644 --- a/src/platforms/app-plus/service/framework/app.js +++ b/src/platforms/app-plus/service/framework/app.js @@ -2,7 +2,11 @@ import { callAppHook } from 'uni-core/service/plugins/util' -import initOn from 'uni-core/service/bridge/on' +import initOn from 'uni-core/service/bridge/on' + +import { + requireNativePlugin +} from '../bridge' import { NETWORK_TYPES @@ -54,7 +58,8 @@ export function getApp ({ ) } -function initGlobalListeners () { +function initGlobalListeners () { + const globalEvent = requireNativePlugin('globalEvent') const emit = UniServiceJSBridge.emit // splashclosed 时开始监听 backbutton @@ -84,7 +89,7 @@ function initGlobalListeners () { }) }) - plus.globalEvent.addEventListener('uistylechange', function (event) { + globalEvent.addEventListener('uistylechange', function (event) { publish('onUIStyleChange', { style: event.uistyle }) diff --git a/src/shared/callback.js b/src/shared/callback.js index 6f141cab8..84ea60eec 100644 --- a/src/shared/callback.js +++ b/src/shared/callback.js @@ -10,9 +10,10 @@ function warp (fn) { complete: options.complete } const data = Object.assign({}, options) - delete data.success - delete data.fail - delete data.complete + // TODO 下版重构 nvue h5 callback + // delete data.success + // delete data.fail + // delete data.complete const res = fn.bind(this)(data, callbackId) if (res) { invoke(callbackId, res) -- GitLab