diff --git a/src/platforms/app-plus/service/api/device/bluetooth.js b/src/platforms/app-plus/service/api/device/bluetooth.js index 1db40be896f52001e91874bf16468bb88cf2c293..b2d7429e77e3e39f26f1d23c558ed26c3fa6eaaf 100644 --- a/src/platforms/app-plus/service/api/device/bluetooth.js +++ b/src/platforms/app-plus/service/api/device/bluetooth.js @@ -3,10 +3,10 @@ import { warpPlusMethod } from '../util' -export const onBluetoothDeviceFound = warpPlusEvent(plus.bluetooth, 'onBluetoothDeviceFound') -export const onBluetoothAdapterStateChange = warpPlusEvent(plus.bluetooth, 'onBluetoothAdapterStateChange') -export const onBLEConnectionStateChange = warpPlusEvent(plus.bluetooth, 'onBLEConnectionStateChange') -export const onBLECharacteristicValueChange = warpPlusEvent(plus.bluetooth, 'onBLECharacteristicValueChange') +export const onBluetoothDeviceFound = warpPlusEvent('bluetooth', 'onBluetoothDeviceFound') +export const onBluetoothAdapterStateChange = warpPlusEvent('bluetooth', 'onBluetoothAdapterStateChange') +export const onBLEConnectionStateChange = warpPlusEvent('bluetooth', 'onBLEConnectionStateChange') +export const onBLECharacteristicValueChange = warpPlusEvent('bluetooth', 'onBLECharacteristicValueChange') function toUpperCase (options = {}) { const deviceId = options.deviceId @@ -20,19 +20,19 @@ function toUpperCase (options = {}) { return options } -export const openBluetoothAdapter = warpPlusMethod(plus.bluetooth, 'openBluetoothAdapter') -export const closeBluetoothAdapter = warpPlusMethod(plus.bluetooth, 'closeBluetoothAdapter') -export const getBluetoothAdapterState = warpPlusMethod(plus.bluetooth, 'getBluetoothAdapterState') -export const startBluetoothDevicesDiscovery = warpPlusMethod(plus.bluetooth, 'startBluetoothDevicesDiscovery', toUpperCase) -export const stopBluetoothDevicesDiscovery = warpPlusMethod(plus.bluetooth, 'stopBluetoothDevicesDiscovery') -export const getBluetoothDevices = warpPlusMethod(plus.bluetooth, 'getBluetoothDevices') -export const getConnectedBluetoothDevices = warpPlusMethod(plus.bluetooth, 'getConnectedBluetoothDevices', toUpperCase) -export const createBLEConnection = warpPlusMethod(plus.bluetooth, 'createBLEConnection', toUpperCase) -export const closeBLEConnection = warpPlusMethod(plus.bluetooth, 'closeBLEConnection', toUpperCase) -export const getBLEDeviceServices = warpPlusMethod(plus.bluetooth, 'getBLEDeviceServices', toUpperCase) -export const getBLEDeviceCharacteristics = warpPlusMethod(plus.bluetooth, 'getBLEDeviceCharacteristics', toUpperCase) -export const notifyBLECharacteristicValueChange = warpPlusMethod(plus.bluetooth, 'notifyBLECharacteristicValueChange', toUpperCase) -export const readBLECharacteristicValue = warpPlusMethod(plus.bluetooth, 'readBLECharacteristicValue', toUpperCase) -export const writeBLECharacteristicValue = warpPlusMethod(plus.bluetooth, 'writeBLECharacteristicValue', toUpperCase) -export const setBLEMTU = warpPlusMethod(plus.bluetooth, 'setBLEMTU', toUpperCase) -export const getBLEDeviceRSSI = warpPlusMethod(plus.bluetooth, 'getBLEDeviceRSSI', toUpperCase) +export const openBluetoothAdapter = warpPlusMethod('bluetooth', 'openBluetoothAdapter') +export const closeBluetoothAdapter = warpPlusMethod('bluetooth', 'closeBluetoothAdapter') +export const getBluetoothAdapterState = warpPlusMethod('bluetooth', 'getBluetoothAdapterState') +export const startBluetoothDevicesDiscovery = warpPlusMethod('bluetooth', 'startBluetoothDevicesDiscovery', toUpperCase) +export const stopBluetoothDevicesDiscovery = warpPlusMethod('bluetooth', 'stopBluetoothDevicesDiscovery') +export const getBluetoothDevices = warpPlusMethod('bluetooth', 'getBluetoothDevices') +export const getConnectedBluetoothDevices = warpPlusMethod('bluetooth', 'getConnectedBluetoothDevices', toUpperCase) +export const createBLEConnection = warpPlusMethod('bluetooth', 'createBLEConnection', toUpperCase) +export const closeBLEConnection = warpPlusMethod('bluetooth', 'closeBLEConnection', toUpperCase) +export const getBLEDeviceServices = warpPlusMethod('bluetooth', 'getBLEDeviceServices', toUpperCase) +export const getBLEDeviceCharacteristics = warpPlusMethod('bluetooth', 'getBLEDeviceCharacteristics', toUpperCase) +export const notifyBLECharacteristicValueChange = warpPlusMethod('bluetooth', 'notifyBLECharacteristicValueChange', toUpperCase) +export const readBLECharacteristicValue = warpPlusMethod('bluetooth', 'readBLECharacteristicValue', toUpperCase) +export const writeBLECharacteristicValue = warpPlusMethod('bluetooth', 'writeBLECharacteristicValue', toUpperCase) +export const setBLEMTU = warpPlusMethod('bluetooth', 'setBLEMTU', toUpperCase) +export const getBLEDeviceRSSI = warpPlusMethod('bluetooth', 'getBLEDeviceRSSI', toUpperCase) diff --git a/src/platforms/app-plus/service/api/device/ibeacon.js b/src/platforms/app-plus/service/api/device/ibeacon.js index 484738758eef20a709f0209a60398073a4450653..fea7f01e0137b247c84ded15457fe7ce8cf8a7f5 100644 --- a/src/platforms/app-plus/service/api/device/ibeacon.js +++ b/src/platforms/app-plus/service/api/device/ibeacon.js @@ -3,9 +3,9 @@ import { warpPlusMethod } from '../util' -export const onBeaconUpdate = warpPlusEvent(plus.ibeacon, 'onBeaconUpdate') -export const onBeaconServiceChange = warpPlusEvent(plus.ibeacon, 'onBeaconServiceChange') +export const onBeaconUpdate = warpPlusEvent('ibeacon', 'onBeaconUpdate') +export const onBeaconServiceChange = warpPlusEvent('ibeacon', 'onBeaconServiceChange') -export const getBeacons = warpPlusMethod(plus.ibeacon, 'getBeacons') -export const startBeaconDiscovery = warpPlusMethod(plus.ibeacon, 'startBeaconDiscovery') -export const stopBeaconDiscovery = warpPlusMethod(plus.ibeacon, 'stopBeaconDiscovery') +export const getBeacons = warpPlusMethod('ibeacon', 'getBeacons') +export const startBeaconDiscovery = warpPlusMethod('ibeacon', 'startBeaconDiscovery') +export const stopBeaconDiscovery = warpPlusMethod('ibeacon', 'stopBeaconDiscovery') diff --git a/src/platforms/app-plus/service/api/file/file.js b/src/platforms/app-plus/service/api/file/file.js index 791997e89df0cf03c6063c1f46952aa5d6fa6b89..3b741663f35337b57cce1d81da44b99482614723 100644 --- a/src/platforms/app-plus/service/api/file/file.js +++ b/src/platforms/app-plus/service/api/file/file.js @@ -74,7 +74,7 @@ export function getSavedFileList (options, callbackId) { }, errorCallback) } -export const getFileInfo = warpPlusMethod(plus.io, 'getFileInfo') +export const getFileInfo = warpPlusMethod('io', 'getFileInfo') export function getSavedFileInfo ({ filePath diff --git a/src/platforms/app-plus/service/api/media/get-image-info.js b/src/platforms/app-plus/service/api/media/get-image-info.js index 28a7b62dbbcd00c2a7240ffaf426cd0f75b6bbda..fde0e30b111f724200a31b315f84084510d1e0a0 100644 --- a/src/platforms/app-plus/service/api/media/get-image-info.js +++ b/src/platforms/app-plus/service/api/media/get-image-info.js @@ -2,4 +2,4 @@ import { warpPlusMethod } from '../util' -export const getImageInfo = warpPlusMethod(plus.io, 'getImageInfo') +export const getImageInfo = warpPlusMethod('io', 'getImageInfo') diff --git a/src/platforms/app-plus/service/api/util.js b/src/platforms/app-plus/service/api/util.js index 3de146bc635fb868beb00a16962560a9dd3663d5..4fca9e143750ed6ba03ddda0cff954146766caf5 100644 --- a/src/platforms/app-plus/service/api/util.js +++ b/src/platforms/app-plus/service/api/util.js @@ -4,7 +4,8 @@ import { export { isTabBarPage -} from '../bridge' +} + from '../bridge' export function callApiSync (api, args, name, alias) { const ret = api(args) @@ -155,16 +156,19 @@ const outOfChina = function (lng, lat) { } export function getScreenInfo () { - const { resolutionWidth, resolutionHeight } = plus.screen.getCurrentSize() + const { + resolutionWidth, + resolutionHeight + } = plus.screen.getCurrentSize() return { screenWidth: Math.round(resolutionWidth), screenHeight: Math.round(resolutionHeight) } } -export function warpPlusEvent (origin, name) { +export function warpPlusEvent (module, name) { return function (callbackId) { - origin[name](function (data) { + plus[module][name](function (data) { if (data) { delete data.code delete data.message @@ -184,12 +188,12 @@ export function warpPlusErrorCallback (callbackId, neme, errMsg) { } } -export function warpPlusMethod (origin, name, before) { +export function warpPlusMethod (module, name, before) { return function (options, callbackId) { if (typeof before === 'function') { options = before(options) } - origin[name](Object.assign(options, { + plus[module][name](Object.assign(options, { success (data = {}) { delete data.code delete data.message @@ -210,4 +214,4 @@ export function getFileName (path) { export function getExtName (path) { const array = path.split('.') return array.length > 1 ? '.' + array[array.length - 1] : '' -} +}