@tarojs/taro-h5 3.4.0-beta.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/ad/index.js +4 -0
- package/dist/api/ai/facial.js +5 -0
- package/dist/api/ai/index.js +2 -0
- package/dist/api/ai/visual.js +3 -0
- package/dist/api/alipay/index.js +3 -0
- package/dist/api/base/crypto.js +3 -0
- package/dist/api/base/debug.js +4 -0
- package/dist/api/base/index.js +17 -0
- package/dist/api/base/performance.js +4 -0
- package/dist/api/base/system/index.js +2 -0
- package/dist/api/base/system/info.js +57 -0
- package/dist/api/base/system/network.js +63 -0
- package/dist/api/base/update.js +4 -0
- package/dist/api/base/weapp/app-event.js +18 -0
- package/dist/api/base/weapp/life-cycle.js +4 -0
- package/dist/api/canvas/CanvasContext.js +191 -0
- package/dist/api/canvas/canvasGetImageData.js +25 -0
- package/dist/api/canvas/canvasPutImageData.js +22 -0
- package/dist/api/canvas/canvasToTempFilePath.js +22 -0
- package/dist/api/canvas/createCanvasContext.js +16 -0
- package/dist/api/canvas/index.js +8 -0
- package/dist/api/cloud/index.js +17 -0
- package/dist/api/data-analysis/index.js +5 -0
- package/dist/api/device/accelerometer.js +83 -0
- package/dist/api/device/accessibility.js +3 -0
- package/dist/api/device/battery.js +4 -0
- package/dist/api/device/bluetooth-ble.js +18 -0
- package/dist/api/device/bluetooth-peripheral.js +5 -0
- package/dist/api/device/bluetooth.js +15 -0
- package/dist/api/device/calendar.js +4 -0
- package/dist/api/device/clipboard.js +65 -0
- package/dist/api/device/compass.js +64 -0
- package/dist/api/device/contact.js +4 -0
- package/dist/api/device/crypto.js +3 -0
- package/dist/api/device/gyroscope.js +6 -0
- package/dist/api/device/iBeacon.js +9 -0
- package/dist/api/device/index.js +22 -0
- package/dist/api/device/keyboard.js +6 -0
- package/dist/api/device/memory.js +4 -0
- package/dist/api/device/motion.js +81 -0
- package/dist/api/device/nfc.js +9 -0
- package/dist/api/device/phone.js +24 -0
- package/dist/api/device/scan.js +6 -0
- package/dist/api/device/screen.js +8 -0
- package/dist/api/device/vibrate.js +35 -0
- package/dist/api/device/wifi.js +12 -0
- package/dist/api/ext/index.js +4 -0
- package/dist/api/files/index.js +10 -0
- package/dist/api/framework/index.js +7 -0
- package/dist/api/index.js +24 -0
- package/dist/api/location/chooseLocation.js +93 -0
- package/dist/api/location/index.js +13 -0
- package/dist/api/location/style.css +79 -0
- package/dist/api/media/audio/index.js +88 -0
- package/dist/api/media/background-audio.js +11 -0
- package/dist/api/media/camera.js +3 -0
- package/dist/api/media/editor.js +18 -0
- package/dist/api/media/image/chooseImage.js +74 -0
- package/dist/api/media/image/getImageInfo.js +31 -0
- package/dist/api/media/image/index.js +9 -0
- package/dist/api/media/image/previewImage.js +67 -0
- package/dist/api/media/index.js +13 -0
- package/dist/api/media/live.js +4 -0
- package/dist/api/media/map.js +3 -0
- package/dist/api/media/media-recorder.js +3 -0
- package/dist/api/media/recorder.js +5 -0
- package/dist/api/media/video/index.js +74 -0
- package/dist/api/media/video-decoder.js +3 -0
- package/dist/api/media/video-processing.js +3 -0
- package/dist/api/media/voip.js +16 -0
- package/dist/api/navigate/index.js +6 -0
- package/dist/api/network/download.js +124 -0
- package/dist/api/network/index.js +7 -0
- package/dist/api/network/mdns.js +12 -0
- package/dist/api/network/request/index.js +125 -0
- package/dist/api/network/tcp.js +3 -0
- package/dist/api/network/udp.js +3 -0
- package/dist/api/network/upload.js +151 -0
- package/dist/api/network/utils.js +65 -0
- package/dist/api/network/websocket/index.js +70 -0
- package/dist/api/network/websocket/socketTask.js +63 -0
- package/dist/api/open-api/account.js +3 -0
- package/dist/api/open-api/address.js +3 -0
- package/dist/api/open-api/authorize.js +4 -0
- package/dist/api/open-api/card.js +4 -0
- package/dist/api/open-api/channels-live.js +8 -0
- package/dist/api/open-api/customer-service.js +3 -0
- package/dist/api/open-api/facial.js +6 -0
- package/dist/api/open-api/favorites.js +4 -0
- package/dist/api/open-api/group.js +3 -0
- package/dist/api/open-api/index.js +18 -0
- package/dist/api/open-api/invoice.js +4 -0
- package/dist/api/open-api/license-plate.js +3 -0
- package/dist/api/open-api/login.js +5 -0
- package/dist/api/open-api/red-package.js +3 -0
- package/dist/api/open-api/settings.js +4 -0
- package/dist/api/open-api/soter.js +5 -0
- package/dist/api/open-api/subscribe-message.js +3 -0
- package/dist/api/open-api/user-info.js +4 -0
- package/dist/api/open-api/werun.js +4 -0
- package/dist/api/payment/index.js +4 -0
- package/dist/api/route/index.js +3 -0
- package/dist/api/share/index.js +12 -0
- package/dist/api/storage/background-fetch.js +6 -0
- package/dist/api/storage/index.js +157 -0
- package/dist/api/swan/index.js +26 -0
- package/dist/api/taro.js +47 -0
- package/dist/api/ui/animation/index.js +284 -0
- package/dist/api/ui/background.js +4 -0
- package/dist/api/ui/custom-component.js +3 -0
- package/dist/api/ui/fonts.js +3 -0
- package/dist/api/ui/index.js +12 -0
- package/dist/api/ui/interaction/actionSheet.js +188 -0
- package/dist/api/ui/interaction/index.js +268 -0
- package/dist/api/ui/interaction/modal.js +207 -0
- package/dist/api/ui/interaction/toast.js +195 -0
- package/dist/api/ui/menu.js +3 -0
- package/dist/api/ui/navigation-bar/index.js +42 -0
- package/dist/api/ui/pull-down-refresh.js +26 -0
- package/dist/api/ui/scroll/index.js +83 -0
- package/dist/api/ui/sticky.js +3 -0
- package/dist/api/ui/tab-bar.js +282 -0
- package/dist/api/ui/window.js +31 -0
- package/dist/api/utils/handler.js +80 -0
- package/dist/api/utils/index.js +148 -0
- package/dist/api/worker/index.js +3 -0
- package/dist/api/wxml/index.js +6 -0
- package/dist/api/wxml/nodesRef.js +42 -0
- package/dist/api/wxml/selectorQuery.js +201 -0
- package/dist/index.cjs.js +7852 -11638
- package/dist/index.js +4 -0
- package/dist/taroApis.js +1 -1
- package/dist/types/type.js +2 -0
- package/package.json +14 -16
- package/src/api/ad/index.ts +5 -0
- package/src/api/ai/facial.ts +6 -0
- package/src/api/ai/index.ts +2 -0
- package/src/api/ai/visual.ts +4 -0
- package/src/api/alipay/index.ts +4 -0
- package/src/api/base/crypto.ts +4 -0
- package/src/api/base/debug.ts +5 -0
- package/src/api/base/index.ts +23 -0
- package/src/api/base/performance.ts +5 -0
- package/src/api/base/system/index.ts +2 -0
- package/src/api/base/system/info.ts +64 -0
- package/src/api/base/system/network.ts +70 -0
- package/src/api/base/update.ts +5 -0
- package/src/api/base/weapp/app-event.ts +19 -0
- package/src/api/base/weapp/life-cycle.ts +5 -0
- package/src/api/canvas/CanvasContext.ts +233 -0
- package/src/api/canvas/canvasGetImageData.ts +27 -0
- package/src/api/canvas/canvasPutImageData.ts +24 -0
- package/src/api/canvas/canvasToTempFilePath.ts +24 -0
- package/src/api/canvas/createCanvasContext.ts +18 -0
- package/src/api/canvas/index.ts +10 -0
- package/src/api/cloud/index.ts +27 -0
- package/src/api/data-analysis/index.ts +6 -0
- package/src/api/device/accelerometer.ts +87 -0
- package/src/api/device/accessibility.ts +4 -0
- package/src/api/device/battery.ts +5 -0
- package/src/api/device/bluetooth-ble.ts +19 -0
- package/src/api/device/bluetooth-peripheral.ts +6 -0
- package/src/api/device/bluetooth.ts +16 -0
- package/src/api/device/calendar.ts +5 -0
- package/src/api/device/clipboard.ts +67 -0
- package/src/api/device/compass.ts +67 -0
- package/src/api/device/contact.ts +5 -0
- package/src/api/device/crypto.ts +4 -0
- package/src/api/device/gyroscope.ts +7 -0
- package/src/api/device/iBeacon.ts +10 -0
- package/src/api/device/index.ts +22 -0
- package/src/api/device/keyboard.ts +7 -0
- package/src/api/device/memory.ts +5 -0
- package/src/api/device/motion.ts +85 -0
- package/src/api/device/nfc.ts +10 -0
- package/src/api/device/phone.ts +30 -0
- package/src/api/device/scan.ts +7 -0
- package/src/api/device/screen.ts +9 -0
- package/src/api/device/vibrate.ts +36 -0
- package/src/api/device/wifi.ts +13 -0
- package/src/api/ext/index.ts +5 -0
- package/src/api/files/index.ts +11 -0
- package/src/api/framework/index.ts +10 -0
- package/src/api/index.ts +25 -0
- package/src/api/location/chooseLocation.ts +106 -0
- package/src/api/location/index.ts +19 -0
- package/src/api/location/style.css +8 -8
- package/src/api/media/audio/index.ts +105 -0
- package/src/api/media/background-audio.ts +12 -0
- package/src/api/media/camera.ts +4 -0
- package/src/api/media/editor.ts +29 -0
- package/src/api/media/image/chooseImage.ts +78 -0
- package/src/api/media/image/getImageInfo.ts +35 -0
- package/src/api/media/image/index.ts +13 -0
- package/src/api/media/image/previewImage.ts +80 -0
- package/src/api/media/index.ts +13 -0
- package/src/api/media/live.ts +5 -0
- package/src/api/media/map.ts +4 -0
- package/src/api/media/media-recorder.ts +4 -0
- package/src/api/media/recorder.ts +6 -0
- package/src/api/media/video/index.ts +82 -0
- package/src/api/media/video-decoder.ts +4 -0
- package/src/api/media/video-processing.ts +4 -0
- package/src/api/media/voip.ts +17 -0
- package/src/api/navigate/index.ts +7 -0
- package/src/api/{fileTransfer/downloadFile.js → network/download.ts} +16 -27
- package/src/api/network/index.ts +7 -0
- package/src/api/network/mdns.ts +13 -0
- package/src/api/{request/index.js → network/request/index.ts} +9 -6
- package/src/api/network/tcp.ts +4 -0
- package/src/api/network/udp.ts +4 -0
- package/src/api/{fileTransfer/uploadFile.js → network/upload.ts} +28 -32
- package/src/api/{fileTransfer/utils.js → network/utils.ts} +0 -0
- package/src/api/network/websocket/index.ts +88 -0
- package/src/api/{webSocket/socketTask.js → network/websocket/socketTask.ts} +17 -7
- package/src/api/open-api/account.ts +4 -0
- package/src/api/open-api/address.ts +4 -0
- package/src/api/open-api/authorize.ts +5 -0
- package/src/api/open-api/card.ts +5 -0
- package/src/api/open-api/channels-live.ts +9 -0
- package/src/api/open-api/customer-service.ts +4 -0
- package/src/api/open-api/facial.ts +7 -0
- package/src/api/open-api/favorites.ts +5 -0
- package/src/api/open-api/group.ts +4 -0
- package/src/api/open-api/index.ts +18 -0
- package/src/api/open-api/invoice.ts +5 -0
- package/src/api/open-api/license-plate.ts +4 -0
- package/src/api/open-api/login.ts +6 -0
- package/src/api/open-api/red-package.ts +4 -0
- package/src/api/open-api/settings.ts +5 -0
- package/src/api/open-api/soter.ts +6 -0
- package/src/api/open-api/subscribe-message.ts +4 -0
- package/src/api/open-api/user-info.ts +5 -0
- package/src/api/open-api/werun.ts +5 -0
- package/src/api/payment/index.ts +5 -0
- package/src/api/route/index.ts +10 -0
- package/src/api/share/index.ts +13 -0
- package/src/api/storage/background-fetch.ts +7 -0
- package/src/api/storage/index.ts +181 -0
- package/src/api/swan/index.ts +31 -0
- package/src/{taro/index.js → api/taro.ts} +89 -104
- package/src/api/{createAnimation/index.js → ui/animation/index.ts} +52 -41
- package/src/api/ui/background.ts +5 -0
- package/src/api/ui/custom-component.ts +4 -0
- package/src/api/ui/fonts.ts +4 -0
- package/src/api/ui/index.ts +12 -0
- package/src/api/ui/interaction/actionSheet.ts +212 -0
- package/src/api/{interactive/index.js → ui/interaction/index.ts} +95 -77
- package/src/api/ui/interaction/modal.ts +237 -0
- package/src/api/{interactive/toast.js → ui/interaction/toast.ts} +35 -33
- package/src/api/ui/menu.ts +4 -0
- package/src/api/ui/navigation-bar/index.ts +52 -0
- package/src/api/ui/pull-down-refresh.ts +27 -0
- package/src/api/ui/scroll/index.ts +85 -0
- package/src/api/ui/sticky.ts +4 -0
- package/src/api/ui/tab-bar.ts +326 -0
- package/src/api/ui/window.ts +37 -0
- package/src/api/utils/handler.ts +105 -0
- package/src/api/utils/{index.js → index.ts} +36 -115
- package/src/api/worker/index.ts +4 -0
- package/src/api/wxml/index.ts +9 -0
- package/src/api/wxml/nodesRef.ts +56 -0
- package/src/api/wxml/selectorQuery.ts +219 -0
- package/src/index.ts +6 -0
- package/src/types/api.d.ts +4 -0
- package/src/types/define.d.ts +2 -0
- package/{types → src/types}/index.d.ts +0 -0
- package/{types → src/types}/type.ts +1 -1
- package/src/api/accelerometer/index.js +0 -105
- package/src/api/audio/index.js +0 -137
- package/src/api/canvas/canvasGetImageData.js +0 -44
- package/src/api/canvas/canvasPutImageData.js +0 -45
- package/src/api/canvas/canvasToTempFilePath.js +0 -49
- package/src/api/canvas/createCanvasContext.js +0 -340
- package/src/api/canvas/index.js +0 -4
- package/src/api/clipboard/index.js +0 -113
- package/src/api/compass/index.js +0 -99
- package/src/api/createSelectorQuery/index.js +0 -193
- package/src/api/deviceMotion/index.js +0 -105
- package/src/api/fileTransfer/index.js +0 -2
- package/src/api/image/chooseImage.js +0 -87
- package/src/api/image/getImageInfo.js +0 -74
- package/src/api/image/index.js +0 -7
- package/src/api/image/previewImage.js +0 -94
- package/src/api/index.js +0 -29
- package/src/api/interactive/actionSheet.js +0 -214
- package/src/api/interactive/modal.js +0 -256
- package/src/api/location/chooseLocation.js +0 -143
- package/src/api/location/index.js +0 -5
- package/src/api/navigationBar/index.js +0 -57
- package/src/api/open/index.js +0 -5
- package/src/api/others/index.js +0 -43
- package/src/api/pullDownRefresh/index.js +0 -51
- package/src/api/scroll/index.js +0 -99
- package/src/api/storage/index.js +0 -211
- package/src/api/system/index.js +0 -9
- package/src/api/system/info.js +0 -36
- package/src/api/system/network.js +0 -68
- package/src/api/tabBar/index.js +0 -402
- package/src/api/unsupportedApi/index.js +0 -278
- package/src/api/vibrate/index.js +0 -49
- package/src/api/video/index.js +0 -87
- package/src/api/webSocket/index.js +0 -103
- package/src/api/window/index.js +0 -38
- package/src/index.cjs.js +0 -11
- package/src/index.js +0 -6
package/src/api/others/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { fromByteArray, toByteArray } from 'base64-js'
|
|
2
|
-
import { shouldBeObject, getParameterError } from '../utils'
|
|
3
|
-
|
|
4
|
-
export function arrayBufferToBase64 (arrayBuffer) {
|
|
5
|
-
return fromByteArray(arrayBuffer)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function base64ToArrayBuffer (base64) {
|
|
9
|
-
return toByteArray(base64)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function makePhoneCall (options) {
|
|
13
|
-
// options must be an Object
|
|
14
|
-
const isObject = shouldBeObject(options)
|
|
15
|
-
if (!isObject.res) {
|
|
16
|
-
const res = { errMsg: `makePhoneCall${isObject.msg}` }
|
|
17
|
-
console.error(res.errMsg)
|
|
18
|
-
return Promise.reject(res)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { phoneNumber, success, fail, complete } = options
|
|
22
|
-
const res = { errMsg: 'makePhoneCall:ok' }
|
|
23
|
-
|
|
24
|
-
if (typeof phoneNumber !== 'string') {
|
|
25
|
-
res.errMsg = getParameterError({
|
|
26
|
-
name: 'makePhoneCall',
|
|
27
|
-
para: 'phoneNumber',
|
|
28
|
-
correct: 'String',
|
|
29
|
-
wrong: phoneNumber
|
|
30
|
-
})
|
|
31
|
-
console.error(res.errMsg)
|
|
32
|
-
typeof fail === 'function' && fail(res)
|
|
33
|
-
typeof complete === 'function' && complete(res)
|
|
34
|
-
return Promise.reject(res)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
window.location.href = `tel:${phoneNumber}`
|
|
38
|
-
|
|
39
|
-
typeof success === 'function' && success(res)
|
|
40
|
-
typeof complete === 'function' && complete(res)
|
|
41
|
-
|
|
42
|
-
return Promise.resolve(res)
|
|
43
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
/**
|
|
3
|
-
* 开始下拉刷新。调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
|
|
4
|
-
* @param {Object} object 参数
|
|
5
|
-
*/
|
|
6
|
-
const startPullDownRefresh = function (object = {}) {
|
|
7
|
-
return new Promise((resolve, reject) => {
|
|
8
|
-
const { success, fail, complete } = object
|
|
9
|
-
const res = {}
|
|
10
|
-
Taro.eventCenter.trigger('__taroStartPullDownRefresh', {
|
|
11
|
-
successHandler: () => {
|
|
12
|
-
success && success(res)
|
|
13
|
-
complete && complete()
|
|
14
|
-
resolve(res)
|
|
15
|
-
},
|
|
16
|
-
errorHandler: () => {
|
|
17
|
-
fail && fail(res)
|
|
18
|
-
complete && complete()
|
|
19
|
-
reject(res)
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 停止当前页面下拉刷新。
|
|
27
|
-
* @param {Object} object 参数
|
|
28
|
-
*/
|
|
29
|
-
const stopPullDownRefresh = function (object = {}) {
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
const { success, fail, complete } = object
|
|
32
|
-
const res = {}
|
|
33
|
-
Taro.eventCenter.trigger('__taroStopPullDownRefresh', {
|
|
34
|
-
successHandler: () => {
|
|
35
|
-
success && success(res)
|
|
36
|
-
complete && complete()
|
|
37
|
-
resolve(res)
|
|
38
|
-
},
|
|
39
|
-
errorHandler: () => {
|
|
40
|
-
fail && fail(res)
|
|
41
|
-
complete && complete()
|
|
42
|
-
reject(res)
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
startPullDownRefresh,
|
|
50
|
-
stopPullDownRefresh
|
|
51
|
-
}
|
package/src/api/scroll/index.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { getTimingFunc, easeInOut } from '../utils/index'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {object} PageScrollToParam pageScrollTo参数
|
|
5
|
-
* @property {number} scrollTop 滚动到页面的目标位置,单位 px
|
|
6
|
-
* @property {string} selector 选择器, css selector
|
|
7
|
-
* @property {number} [duration=300] 滚动动画的时长,单位 ms
|
|
8
|
-
* @property {function} [success] 接口调用成功的回调函数
|
|
9
|
-
* @property {function} [fail] 接口调用失败的回调函数
|
|
10
|
-
* @property {function} [complete] 接口调用结束的回调函数(调用成功、失败都会执行)
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
let scrollFunc
|
|
14
|
-
let timer
|
|
15
|
-
const FRAME_DURATION = 17
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 将页面滚动到目标位置
|
|
19
|
-
* @param {PageScrollToParam} object 参数
|
|
20
|
-
*/
|
|
21
|
-
export const pageScrollTo = ({ scrollTop, selector, duration = 300, success, fail, complete }) => {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
try {
|
|
24
|
-
if (scrollTop === undefined && !selector) {
|
|
25
|
-
throw Error('"scrollTop" 或 "selector" 需要其之一')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let el
|
|
29
|
-
if (document.querySelector('.taro-tabbar__tabbar') === null) {
|
|
30
|
-
// 没设置tabbar
|
|
31
|
-
el = window
|
|
32
|
-
} else {
|
|
33
|
-
// 有设置tabbar
|
|
34
|
-
el = document.querySelector('.taro-tabbar__panel') || window
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!scrollFunc) {
|
|
38
|
-
if (el === window) {
|
|
39
|
-
scrollFunc = pos => {
|
|
40
|
-
if (pos === undefined) {
|
|
41
|
-
return window.pageYOffset
|
|
42
|
-
} else {
|
|
43
|
-
window.scrollTo(0, pos)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
scrollFunc = pos => {
|
|
48
|
-
if (pos === undefined) {
|
|
49
|
-
return el.scrollTop
|
|
50
|
-
} else {
|
|
51
|
-
el.scrollTop = pos
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (scrollTop && selector) {
|
|
58
|
-
console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector')
|
|
59
|
-
}
|
|
60
|
-
const from = scrollFunc()
|
|
61
|
-
let to
|
|
62
|
-
if (typeof scrollTop === 'number') {
|
|
63
|
-
to = scrollTop
|
|
64
|
-
} else {
|
|
65
|
-
to = document.querySelector(selector).offsetTop
|
|
66
|
-
}
|
|
67
|
-
const delta = to - from
|
|
68
|
-
|
|
69
|
-
const frameCnt = duration / FRAME_DURATION
|
|
70
|
-
const easeFunc = getTimingFunc(easeInOut, frameCnt)
|
|
71
|
-
|
|
72
|
-
const scroll = (frame = 0) => {
|
|
73
|
-
const dest = from + delta * easeFunc(frame)
|
|
74
|
-
scrollFunc(dest)
|
|
75
|
-
if (frame < frameCnt) {
|
|
76
|
-
timer && clearTimeout(timer)
|
|
77
|
-
timer = setTimeout(() => {
|
|
78
|
-
scroll(frame + 1)
|
|
79
|
-
}, FRAME_DURATION)
|
|
80
|
-
} else {
|
|
81
|
-
const res = {
|
|
82
|
-
errMsg: 'pageScrollTo:ok'
|
|
83
|
-
}
|
|
84
|
-
success && success(res)
|
|
85
|
-
complete && complete()
|
|
86
|
-
resolve(res)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
scroll()
|
|
90
|
-
} catch (e) {
|
|
91
|
-
const res = {
|
|
92
|
-
errMsg: `pageScrollTo:fail ${e.message}`
|
|
93
|
-
}
|
|
94
|
-
fail && fail(res)
|
|
95
|
-
complete && complete()
|
|
96
|
-
reject(res)
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
}
|
package/src/api/storage/index.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { shouldBeObject, getParameterError } from '../utils'
|
|
2
|
-
|
|
3
|
-
function setStorage (options) {
|
|
4
|
-
// options must be an Object
|
|
5
|
-
const isObject = shouldBeObject(options)
|
|
6
|
-
if (!isObject.res) {
|
|
7
|
-
const res = { errMsg: `setStorage${isObject.msg}` }
|
|
8
|
-
console.error(res.errMsg)
|
|
9
|
-
return Promise.reject(res)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const { key, data, success, fail, complete } = options
|
|
13
|
-
const res = { errMsg: 'setStorage:ok' }
|
|
14
|
-
|
|
15
|
-
if (typeof key !== 'string') {
|
|
16
|
-
res.errMsg = getParameterError({
|
|
17
|
-
name: 'setStorage',
|
|
18
|
-
para: 'key',
|
|
19
|
-
correct: 'String',
|
|
20
|
-
wrong: key
|
|
21
|
-
})
|
|
22
|
-
console.error(res.errMsg)
|
|
23
|
-
typeof fail === 'function' && fail(res)
|
|
24
|
-
typeof complete === 'function' && complete(res)
|
|
25
|
-
return Promise.reject(res)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
setStorageSync(key, data)
|
|
29
|
-
|
|
30
|
-
typeof success === 'function' && success(res)
|
|
31
|
-
typeof complete === 'function' && complete(res)
|
|
32
|
-
|
|
33
|
-
return Promise.resolve(res)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function setStorageSync (key, data = '') {
|
|
37
|
-
if (typeof key !== 'string') {
|
|
38
|
-
console.error(getParameterError({
|
|
39
|
-
name: 'setStorage',
|
|
40
|
-
correct: 'String',
|
|
41
|
-
wrong: key
|
|
42
|
-
}))
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const type = typeof data
|
|
47
|
-
let obj = {}
|
|
48
|
-
|
|
49
|
-
if (type === 'symbol') {
|
|
50
|
-
obj = { data: '' }
|
|
51
|
-
} else {
|
|
52
|
-
obj = { data }
|
|
53
|
-
}
|
|
54
|
-
localStorage.setItem(key, JSON.stringify(obj))
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getStorage (options) {
|
|
58
|
-
// options must be an Object
|
|
59
|
-
const isObject = shouldBeObject(options)
|
|
60
|
-
if (!isObject.res) {
|
|
61
|
-
const res = { errMsg: `getStorage${isObject.msg}` }
|
|
62
|
-
console.error(res.errMsg)
|
|
63
|
-
return Promise.reject(res)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const { key, success, fail, complete } = options
|
|
67
|
-
const res = { errMsg: 'getStorage:ok' }
|
|
68
|
-
|
|
69
|
-
if (typeof key !== 'string') {
|
|
70
|
-
res.errMsg = getParameterError({
|
|
71
|
-
name: 'getStorage',
|
|
72
|
-
para: 'key',
|
|
73
|
-
correct: 'String',
|
|
74
|
-
wrong: key
|
|
75
|
-
})
|
|
76
|
-
console.error(res.errMsg)
|
|
77
|
-
typeof fail === 'function' && fail(res)
|
|
78
|
-
typeof complete === 'function' && complete(res)
|
|
79
|
-
return Promise.reject(res)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const { result, data } = getItem(key)
|
|
83
|
-
if (result) {
|
|
84
|
-
res.data = data
|
|
85
|
-
} else {
|
|
86
|
-
res.errMsg = 'getStorage:fail data not found'
|
|
87
|
-
typeof fail === 'function' && fail(res)
|
|
88
|
-
typeof complete === 'function' && complete(res)
|
|
89
|
-
return Promise.reject(res)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
typeof success === 'function' && success(res)
|
|
93
|
-
typeof complete === 'function' && complete(res)
|
|
94
|
-
|
|
95
|
-
return Promise.resolve(res)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function getStorageSync (key) {
|
|
99
|
-
if (typeof key !== 'string') {
|
|
100
|
-
console.error(getParameterError({
|
|
101
|
-
name: 'getStorage',
|
|
102
|
-
correct: 'String',
|
|
103
|
-
wrong: key
|
|
104
|
-
}))
|
|
105
|
-
return
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const res = getItem(key)
|
|
109
|
-
if (res.result) return res.data
|
|
110
|
-
|
|
111
|
-
return ''
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function getItem (key) {
|
|
115
|
-
let item
|
|
116
|
-
try {
|
|
117
|
-
item = JSON.parse(localStorage.getItem(key))
|
|
118
|
-
} catch (e) {}
|
|
119
|
-
|
|
120
|
-
// 只返回使用 Taro.setStorage API 存储的数据
|
|
121
|
-
if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
|
|
122
|
-
return { result: true, data: item.data }
|
|
123
|
-
} else {
|
|
124
|
-
return { result: false }
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function getStorageInfo (options = {}) {
|
|
129
|
-
const { success, complete } = options
|
|
130
|
-
const res = { errMsg: 'getStorageInfo:ok' }
|
|
131
|
-
|
|
132
|
-
const info = getStorageInfoSync()
|
|
133
|
-
|
|
134
|
-
Object.assign(res, info)
|
|
135
|
-
|
|
136
|
-
success && success(res)
|
|
137
|
-
complete && complete(res)
|
|
138
|
-
|
|
139
|
-
return Promise.resolve(res)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getStorageInfoSync () {
|
|
143
|
-
const res = {}
|
|
144
|
-
res.keys = Object.keys(localStorage)
|
|
145
|
-
res.limitSize = null
|
|
146
|
-
res.currentSize = null
|
|
147
|
-
return res
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function removeStorage (options) {
|
|
151
|
-
// options must be an Object
|
|
152
|
-
const isObject = shouldBeObject(options)
|
|
153
|
-
if (!isObject.res) {
|
|
154
|
-
const res = { errMsg: `removeStorage${isObject.msg}` }
|
|
155
|
-
console.error(res.errMsg)
|
|
156
|
-
return Promise.reject(res)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const { key, success, fail, complete } = options
|
|
160
|
-
const res = { errMsg: 'removeStorage:ok' }
|
|
161
|
-
|
|
162
|
-
if (typeof key !== 'string') {
|
|
163
|
-
res.errMsg = getParameterError({
|
|
164
|
-
name: 'removeStorage',
|
|
165
|
-
para: 'key',
|
|
166
|
-
correct: 'String',
|
|
167
|
-
wrong: key
|
|
168
|
-
})
|
|
169
|
-
console.error(res.errMsg)
|
|
170
|
-
typeof fail === 'function' && fail(res)
|
|
171
|
-
typeof complete === 'function' && complete(res)
|
|
172
|
-
return Promise.reject(res)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
removeStorageSync(key)
|
|
176
|
-
|
|
177
|
-
success && success(res)
|
|
178
|
-
complete && complete(res)
|
|
179
|
-
|
|
180
|
-
return Promise.resolve(res)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function removeStorageSync (key) {
|
|
184
|
-
if (typeof key !== 'string') {
|
|
185
|
-
console.error(getParameterError({
|
|
186
|
-
name: 'removeStorage',
|
|
187
|
-
correct: 'String',
|
|
188
|
-
wrong: key
|
|
189
|
-
}))
|
|
190
|
-
return
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
localStorage.removeItem(key)
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function clearStorage () {
|
|
197
|
-
localStorage.clear()
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export {
|
|
201
|
-
setStorage,
|
|
202
|
-
setStorageSync,
|
|
203
|
-
getStorage,
|
|
204
|
-
getStorageSync,
|
|
205
|
-
getStorageInfo,
|
|
206
|
-
getStorageInfoSync,
|
|
207
|
-
removeStorage,
|
|
208
|
-
removeStorageSync,
|
|
209
|
-
clearStorage,
|
|
210
|
-
clearStorage as clearStorageSync
|
|
211
|
-
}
|
package/src/api/system/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { getSystemInfo, getSystemInfoSync } from './info'
|
|
2
|
-
import { getNetworkType, onNetworkStatusChange } from './network'
|
|
3
|
-
import { processOpenapi } from '../utils'
|
|
4
|
-
|
|
5
|
-
export const scanCode = processOpenapi('scanQRCode', { needResult: 1 }, res => ({
|
|
6
|
-
errMsg: res.errMsg === 'scanQRCode:ok' ? 'scanCode:ok' : res.errMsg,
|
|
7
|
-
result: res.resultStr
|
|
8
|
-
}))
|
|
9
|
-
export { getSystemInfo, getSystemInfoSync, getNetworkType, onNetworkStatusChange }
|
package/src/api/system/info.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import MobileDetect from 'mobile-detect'
|
|
2
|
-
|
|
3
|
-
function getSystemInfoSync () {
|
|
4
|
-
const md = new MobileDetect(navigator.userAgent)
|
|
5
|
-
|
|
6
|
-
const info = {
|
|
7
|
-
brand: md.mobile(), // 手机品牌
|
|
8
|
-
model: md.mobile(), // 手机型号
|
|
9
|
-
system: md.os(), // 操作系统版本
|
|
10
|
-
pixelRatio: window.devicePixelRatio, // 设备像素比
|
|
11
|
-
screenWidth: window.screen.width, // 屏幕宽度
|
|
12
|
-
screenHeight: window.screen.height, // 屏幕高度
|
|
13
|
-
windowWidth: document.documentElement.clientWidth, // 可使用窗口宽度
|
|
14
|
-
windowHeight: document.documentElement.clientHeight, // 可使用窗口高度
|
|
15
|
-
version: '', // 微信版本号
|
|
16
|
-
statusBarHeight: '', // 状态栏的高度
|
|
17
|
-
platform: navigator.platform, // 客户端平台
|
|
18
|
-
language: navigator.language, // 微信设置的语言
|
|
19
|
-
fontSizeSetting: '', // 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px
|
|
20
|
-
SDKVersion: '' // 客户端基础库版本
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return info
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getSystemInfo (options = {}) {
|
|
27
|
-
const { success, complete } = options
|
|
28
|
-
return new Promise(resolve => {
|
|
29
|
-
const info = getSystemInfoSync()
|
|
30
|
-
typeof success === 'function' && success(info)
|
|
31
|
-
typeof complete === 'function' && complete(info)
|
|
32
|
-
resolve(info)
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { getSystemInfoSync, getSystemInfo }
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
function getConnection () {
|
|
2
|
-
return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function getNetworkType (options = {}) {
|
|
6
|
-
const connection = getConnection()
|
|
7
|
-
const { success, complete } = options
|
|
8
|
-
const res = {
|
|
9
|
-
errMsg: 'getNetworkType:ok'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// 浏览器不支持获取网络状态
|
|
13
|
-
if (!connection) {
|
|
14
|
-
res.networkType = 'unknown'
|
|
15
|
-
typeof success === 'function' && success(res)
|
|
16
|
-
typeof complete === 'function' && complete(res)
|
|
17
|
-
return Promise.resolve(res)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let type = 'unknown'
|
|
21
|
-
|
|
22
|
-
// Supports only the navigator.connection.type value which doesn't match the latest spec.
|
|
23
|
-
// https://www.davidbcalhoun.com/2010/using-navigator-connection-android/
|
|
24
|
-
if (!isNaN(Number(connection.type))) {
|
|
25
|
-
switch (connection.type) {
|
|
26
|
-
case connection.WIFI:
|
|
27
|
-
type = 'wifi'
|
|
28
|
-
break
|
|
29
|
-
case connection.CELL_3G:
|
|
30
|
-
type = '3g'
|
|
31
|
-
break
|
|
32
|
-
case connection.CELL_2G:
|
|
33
|
-
type = '2g'
|
|
34
|
-
break
|
|
35
|
-
default:
|
|
36
|
-
// ETHERNET, UNKNOWN
|
|
37
|
-
type = 'unknown'
|
|
38
|
-
}
|
|
39
|
-
} else if (connection.type) {
|
|
40
|
-
// Only supports the type value.
|
|
41
|
-
type = connection.type
|
|
42
|
-
} else if (connection.effectiveType) {
|
|
43
|
-
// effectiveType
|
|
44
|
-
type = connection.effectiveType
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
res.networkType = type
|
|
48
|
-
typeof success === 'function' && success(res)
|
|
49
|
-
typeof complete === 'function' && complete(res)
|
|
50
|
-
return Promise.resolve(res)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function onNetworkStatusChange (cb) {
|
|
54
|
-
const connection = getConnection()
|
|
55
|
-
if (connection) {
|
|
56
|
-
connection.addEventListener('change', function () {
|
|
57
|
-
getNetworkType()
|
|
58
|
-
.then(res => {
|
|
59
|
-
const { networkType } = res
|
|
60
|
-
const isConnected = networkType !== 'none'
|
|
61
|
-
const obj = { isConnected, networkType }
|
|
62
|
-
cb(obj)
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { getNetworkType, onNetworkStatusChange }
|