@tarojs/taro-h5 3.3.13 → 3.3.17
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/index.cjs.js +6134 -8352
- package/dist/index.js +9044 -0
- package/dist/taroApis.js +1 -1
- package/package.json +9 -9
- 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 +230 -0
- package/src/api/canvas/canvasGetImageData.ts +29 -0
- package/src/api/canvas/canvasPutImageData.ts +26 -0
- package/src/api/canvas/canvasToTempFilePath.ts +26 -0
- package/src/api/canvas/createCanvasContext.ts +20 -0
- package/src/api/canvas/{index.js → index.ts} +9 -3
- package/src/api/cloud/index.ts +27 -0
- package/src/api/data-analysis/index.ts +6 -0
- package/src/api/device/accelerometer.ts +89 -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 +74 -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 +92 -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 +99 -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 +80 -0
- package/src/api/{image → media/image}/getImageInfo.js +0 -0
- package/src/api/media/image/index.ts +13 -0
- package/src/api/{image → media/image}/previewImage.js +4 -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 -25
- 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 -30
- package/src/api/{fileTransfer/utils.js → network/utils.ts} +0 -0
- package/src/api/{webSocket/index.js → network/websocket/index.ts} +50 -57
- package/src/api/{webSocket/socketTask.js → network/websocket/socketTask.ts} +16 -6
- 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 +193 -0
- package/src/api/swan/index.ts +31 -0
- package/src/{taro/index.js → api/taro.ts} +133 -149
- package/src/api/{createAnimation/index.js → ui/animation/index.ts} +26 -14
- 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} +102 -90
- 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 +32 -0
- package/src/api/{scroll/index.js → ui/scroll/index.ts} +16 -28
- 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} +24 -87
- package/src/api/worker/index.ts +4 -0
- package/src/api/wxml/index.ts +9 -0
- package/src/api/{createSelectorQuery/index.js → wxml/selectorQuery.ts} +86 -59
- 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/clipboard/index.js +0 -113
- package/src/api/compass/index.js +0 -99
- 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/index.js +0 -7
- 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/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 -424
- 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/window/index.js +0 -38
- package/src/index.cjs.js +0 -11
- package/src/index.js +0 -6
package/src/api/tabBar/index.js
DELETED
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
import { shouleBeObject, getParameterError, isValidColor, successHandler, errorHandler } from '../utils'
|
|
3
|
-
|
|
4
|
-
let tabConf
|
|
5
|
-
let App
|
|
6
|
-
|
|
7
|
-
export function initTabBarApis (_App = {}) {
|
|
8
|
-
tabConf = _App.state.__tabs
|
|
9
|
-
App = _App
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 为 tabBar 某一项的右上角添加文本
|
|
14
|
-
* @param {Object} options
|
|
15
|
-
* @param {number} options.index tabBar 的哪一项,从左边算起
|
|
16
|
-
* @param {string} options.text 显示的文本,超过 4 个字符则显示成 ...
|
|
17
|
-
* @param {function} [options.success] 接口调用成功的回调函数
|
|
18
|
-
* @param {function} [options.fail] 接口调用失败的回调函数
|
|
19
|
-
* @param {function} [options.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
|
|
20
|
-
*/
|
|
21
|
-
export function setTabBarBadge (options = {}) {
|
|
22
|
-
// options must be an Object
|
|
23
|
-
const isObject = shouleBeObject(options)
|
|
24
|
-
if (!isObject.res) {
|
|
25
|
-
const res = { errMsg: `setTabBarBadge${isObject.msg}` }
|
|
26
|
-
console.error(res.errMsg)
|
|
27
|
-
return Promise.reject(res)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const {
|
|
31
|
-
index,
|
|
32
|
-
text,
|
|
33
|
-
success,
|
|
34
|
-
fail,
|
|
35
|
-
complete
|
|
36
|
-
} = options
|
|
37
|
-
const res = { errMsg: 'setTabBarBadge:ok' }
|
|
38
|
-
|
|
39
|
-
if (typeof index !== 'number') {
|
|
40
|
-
res.errMsg = getParameterError({
|
|
41
|
-
name: 'setTabBarBadge',
|
|
42
|
-
para: 'index',
|
|
43
|
-
correct: 'Number',
|
|
44
|
-
wrong: index
|
|
45
|
-
})
|
|
46
|
-
console.error(res.errMsg)
|
|
47
|
-
return errorHandler(fail, complete)(res)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (typeof text !== 'string') {
|
|
51
|
-
res.errMsg = getParameterError({
|
|
52
|
-
name: 'setTabBarBadge',
|
|
53
|
-
para: 'text',
|
|
54
|
-
correct: 'String',
|
|
55
|
-
wrong: text
|
|
56
|
-
})
|
|
57
|
-
console.error(res.errMsg)
|
|
58
|
-
return errorHandler(fail, complete)(res)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
Taro.eventCenter.trigger('__taroSetTabBarBadge', {
|
|
62
|
-
index,
|
|
63
|
-
text,
|
|
64
|
-
successHandler: successHandler(success, complete),
|
|
65
|
-
errorHandler: errorHandler(fail, complete)
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
return successHandler(success, complete)(res)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 移除 tabBar 某一项右上角的文本
|
|
73
|
-
* @param {Object} options
|
|
74
|
-
* @param {number} options.index tabBar 的哪一项,从左边算起
|
|
75
|
-
* @param {function} [options.success] 接口调用成功的回调函数
|
|
76
|
-
* @param {function} [options.fail] 接口调用失败的回调函数
|
|
77
|
-
* @param {function} [options.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
|
|
78
|
-
*/
|
|
79
|
-
export function removeTabBarBadge (options = {}) {
|
|
80
|
-
// options must be an Object
|
|
81
|
-
const isObject = shouleBeObject(options)
|
|
82
|
-
if (!isObject.res) {
|
|
83
|
-
const res = { errMsg: `removeTabBarBadge${isObject.msg}` }
|
|
84
|
-
console.error(res.errMsg)
|
|
85
|
-
return Promise.reject(res)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const {
|
|
89
|
-
index,
|
|
90
|
-
success,
|
|
91
|
-
fail,
|
|
92
|
-
complete
|
|
93
|
-
} = options
|
|
94
|
-
const res = { errMsg: 'removeTabBarBadge:ok' }
|
|
95
|
-
|
|
96
|
-
if (typeof index !== 'number') {
|
|
97
|
-
res.errMsg = getParameterError({
|
|
98
|
-
name: 'removeTabBarBadge',
|
|
99
|
-
para: 'index',
|
|
100
|
-
correct: 'Number',
|
|
101
|
-
wrong: index
|
|
102
|
-
})
|
|
103
|
-
console.error(res.errMsg)
|
|
104
|
-
return errorHandler(fail, complete)(res)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
Taro.eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
108
|
-
index,
|
|
109
|
-
successHandler: successHandler(success, complete),
|
|
110
|
-
errorHandler: errorHandler(fail, complete)
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
return successHandler(success, complete)(res)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 显示 tabBar 某一项的右上角的红点
|
|
118
|
-
* @param {Object} options
|
|
119
|
-
* @param {number} options.index tabBar 的哪一项,从左边算起
|
|
120
|
-
* @param {function} [options.success] 接口调用成功的回调函数
|
|
121
|
-
* @param {function} [options.fail] 接口调用失败的回调函数
|
|
122
|
-
* @param {function} [options.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
|
|
123
|
-
*/
|
|
124
|
-
export function showTabBarRedDot (options = {}) {
|
|
125
|
-
// options must be an Object
|
|
126
|
-
const isObject = shouleBeObject(options)
|
|
127
|
-
if (!isObject.res) {
|
|
128
|
-
const res = { errMsg: `showTabBarRedDot${isObject.msg}` }
|
|
129
|
-
console.error(res.errMsg)
|
|
130
|
-
return Promise.reject(res)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const {
|
|
134
|
-
index,
|
|
135
|
-
success,
|
|
136
|
-
fail,
|
|
137
|
-
complete
|
|
138
|
-
} = options
|
|
139
|
-
const res = { errMsg: 'showTabBarRedDot:ok' }
|
|
140
|
-
|
|
141
|
-
if (typeof index !== 'number') {
|
|
142
|
-
res.errMsg = getParameterError({
|
|
143
|
-
name: 'showTabBarRedDot',
|
|
144
|
-
para: 'index',
|
|
145
|
-
correct: 'Number',
|
|
146
|
-
wrong: index
|
|
147
|
-
})
|
|
148
|
-
console.error(res.errMsg)
|
|
149
|
-
return errorHandler(fail, complete)(res)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
Taro.eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
153
|
-
index,
|
|
154
|
-
successHandler: successHandler(success, complete),
|
|
155
|
-
errorHandler: errorHandler(fail, complete)
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
return successHandler(success, complete)(res)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* 隐藏 tabBar 某一项的右上角的红点
|
|
163
|
-
* @param {Object} options
|
|
164
|
-
* @param {number} options.index tabBar 的哪一项,从左边算起
|
|
165
|
-
* @param {function} [options.success] 接口调用成功的回调函数
|
|
166
|
-
* @param {function} [options.fail] 接口调用失败的回调函数
|
|
167
|
-
* @param {function} [options.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
|
|
168
|
-
*/
|
|
169
|
-
export function hideTabBarRedDot (options = {}) {
|
|
170
|
-
// options must be an Object
|
|
171
|
-
const isObject = shouleBeObject(options)
|
|
172
|
-
if (!isObject.res) {
|
|
173
|
-
const res = { errMsg: `hideTabBarRedDot${isObject.msg}` }
|
|
174
|
-
console.error(res.errMsg)
|
|
175
|
-
return Promise.reject(res)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const {
|
|
179
|
-
index,
|
|
180
|
-
success,
|
|
181
|
-
fail,
|
|
182
|
-
complete
|
|
183
|
-
} = options
|
|
184
|
-
const res = { errMsg: 'hideTabBarRedDot:ok' }
|
|
185
|
-
|
|
186
|
-
if (typeof index !== 'number') {
|
|
187
|
-
res.errMsg = getParameterError({
|
|
188
|
-
name: 'hideTabBarRedDot',
|
|
189
|
-
para: 'index',
|
|
190
|
-
correct: 'Number',
|
|
191
|
-
wrong: index
|
|
192
|
-
})
|
|
193
|
-
console.error(res.errMsg)
|
|
194
|
-
return errorHandler(fail, complete)(res)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
Taro.eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
198
|
-
index,
|
|
199
|
-
successHandler: successHandler(success, complete),
|
|
200
|
-
errorHandler: errorHandler(fail, complete)
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
return successHandler(success, complete)(res)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* 显示 tabBar
|
|
208
|
-
* @param {Object} options
|
|
209
|
-
* @param {boolean} [options.animation=false] 是否需要动画效果
|
|
210
|
-
* @param {function} [options.success] 接口调用成功的回调函数
|
|
211
|
-
* @param {function} [options.fail] 接口调用失败的回调函数
|
|
212
|
-
* @param {function} [options.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
|
|
213
|
-
*/
|
|
214
|
-
export function showTabBar (options = {}) {
|
|
215
|
-
// options must be an Object
|
|
216
|
-
const isObject = shouleBeObject(options)
|
|
217
|
-
if (!isObject.res) {
|
|
218
|
-
const res = { errMsg: `showTabBar${isObject.msg}` }
|
|
219
|
-
console.error(res.errMsg)
|
|
220
|
-
return Promise.reject(res)
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const {
|
|
224
|
-
animation,
|
|
225
|
-
success,
|
|
226
|
-
fail,
|
|
227
|
-
complete
|
|
228
|
-
} = options
|
|
229
|
-
|
|
230
|
-
const res = { errMsg: 'showTabBar:ok' }
|
|
231
|
-
|
|
232
|
-
if (options.hasOwnProperty('animation') && typeof animation !== 'boolean') {
|
|
233
|
-
res.errMsg = getParameterError({
|
|
234
|
-
name: 'showTabBar',
|
|
235
|
-
para: 'animation',
|
|
236
|
-
correct: 'Boolean',
|
|
237
|
-
wrong: animation
|
|
238
|
-
})
|
|
239
|
-
console.error(res.errMsg)
|
|
240
|
-
return errorHandler(fail, complete)(res)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
Taro.eventCenter.trigger('__taroShowTabBar', {
|
|
244
|
-
animation,
|
|
245
|
-
successHandler: successHandler(success, complete),
|
|
246
|
-
errorHandler: errorHandler(success, complete)
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
return successHandler(success, complete)(res)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* 隐藏 tabBar
|
|
254
|
-
* @param {Object} options
|
|
255
|
-
* @param {boolean} [options.animation=false] 是否需要动画效果
|
|
256
|
-
* @param {function} [options.success] 接口调用成功的回调函数
|
|
257
|
-
* @param {function} [options.fail] 接口调用失败的回调函数
|
|
258
|
-
* @param {function} [options.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
|
|
259
|
-
*/
|
|
260
|
-
export function hideTabBar (options = {}) {
|
|
261
|
-
// options must be an Object
|
|
262
|
-
const isObject = shouleBeObject(options)
|
|
263
|
-
if (!isObject.res) {
|
|
264
|
-
const res = { errMsg: `hideTabBar${isObject.msg}` }
|
|
265
|
-
console.error(res.errMsg)
|
|
266
|
-
return Promise.reject(res)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const {
|
|
270
|
-
animation,
|
|
271
|
-
success,
|
|
272
|
-
fail,
|
|
273
|
-
complete
|
|
274
|
-
} = options
|
|
275
|
-
|
|
276
|
-
const res = { errMsg: 'hideTabBar:ok' }
|
|
277
|
-
|
|
278
|
-
if (options.hasOwnProperty('animation') && typeof animation !== 'boolean') {
|
|
279
|
-
res.errMsg = getParameterError({
|
|
280
|
-
name: 'hideTabBar',
|
|
281
|
-
para: 'animation',
|
|
282
|
-
correct: 'Boolean',
|
|
283
|
-
wrong: animation
|
|
284
|
-
})
|
|
285
|
-
console.error(res.errMsg)
|
|
286
|
-
return errorHandler(fail, complete)(res)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
Taro.eventCenter.trigger('__taroHideTabBar', {
|
|
290
|
-
animation,
|
|
291
|
-
successHandler: successHandler(success, complete),
|
|
292
|
-
errorHandler: errorHandler(success, complete)
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
return successHandler(success, complete)(res)
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* 动态设置 tabBar 的整体样式
|
|
300
|
-
* @param {Object} options
|
|
301
|
-
* @param {string} options.color tab 上的文字默认颜色,HexColor
|
|
302
|
-
* @param {string} options.selectedColor tab 上的文字选中时的颜色,HexColor
|
|
303
|
-
* @param {string} options.backgroundColor tab 的背景色,HexColor
|
|
304
|
-
* @param {'black'|'white'} options.borderStyle tabBar上边框的颜色, 仅支持 black/white
|
|
305
|
-
* @param {function} [options.success] 接口调用成功的回调函数
|
|
306
|
-
* @param {function} [options.fail] 接口调用失败的回调函数
|
|
307
|
-
* @param {function} [options.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
|
|
308
|
-
*/
|
|
309
|
-
export function setTabBarStyle (options = {}) {
|
|
310
|
-
// options must be an Object
|
|
311
|
-
const isObject = shouleBeObject(options)
|
|
312
|
-
if (!isObject.res) {
|
|
313
|
-
const res = { errMsg: `setTabBarStyle${isObject.msg}` }
|
|
314
|
-
console.error(res.errMsg)
|
|
315
|
-
return Promise.reject(res)
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const {
|
|
319
|
-
color,
|
|
320
|
-
selectedColor,
|
|
321
|
-
backgroundColor,
|
|
322
|
-
borderStyle,
|
|
323
|
-
success,
|
|
324
|
-
fail,
|
|
325
|
-
complete
|
|
326
|
-
} = options
|
|
327
|
-
const res = { errMsg: 'setTabBarStyle:ok' }
|
|
328
|
-
|
|
329
|
-
let errMsg
|
|
330
|
-
if (color && !isValidColor(color)) {
|
|
331
|
-
errMsg = 'color'
|
|
332
|
-
} else if (selectedColor && !isValidColor(selectedColor)) {
|
|
333
|
-
errMsg = 'selectedColor'
|
|
334
|
-
} else if (backgroundColor && !isValidColor(backgroundColor)) {
|
|
335
|
-
errMsg = 'backgroundColor'
|
|
336
|
-
} else if (borderStyle && !/^(black|white)$/.test(borderStyle)) {
|
|
337
|
-
errMsg = 'borderStyle'
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (errMsg) {
|
|
341
|
-
res.errMsg = `setTabBarStyle:fail invalid ${errMsg}`
|
|
342
|
-
return errorHandler(fail, complete)(res)
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (!tabConf) {
|
|
346
|
-
res.errMsg = 'setTabBarStyle:fail'
|
|
347
|
-
return Promise.reject(res)
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const obj = {}
|
|
351
|
-
if (color) obj.color = color
|
|
352
|
-
if (selectedColor) obj.selectedColor = selectedColor
|
|
353
|
-
if (backgroundColor) obj.backgroundColor = backgroundColor
|
|
354
|
-
if (borderStyle) obj.borderStyle = borderStyle
|
|
355
|
-
|
|
356
|
-
const temp = Object.assign({}, tabConf, obj)
|
|
357
|
-
App.setState && App.setState({ __tabs: temp })
|
|
358
|
-
|
|
359
|
-
return successHandler(success, complete)(res)
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* 动态设置 tabBar 某一项的内容
|
|
364
|
-
* @param {Object} options
|
|
365
|
-
* @param {number} options.index tabBar 的哪一项,从左边算起
|
|
366
|
-
* @param {string} [options.text] tab 上的按钮文字
|
|
367
|
-
* @param {string} [options.iconPath] 图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片
|
|
368
|
-
* @param {string} [options.selectedIconPath] 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效
|
|
369
|
-
* @param {function} [options.success] 接口调用成功的回调函数
|
|
370
|
-
* @param {function} [options.fail] 接口调用失败的回调函数
|
|
371
|
-
* @param {function} [options.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
|
|
372
|
-
*/
|
|
373
|
-
export function setTabBarItem (options = {}) {
|
|
374
|
-
// options must be an Object
|
|
375
|
-
const isObject = shouleBeObject(options)
|
|
376
|
-
if (!isObject.res) {
|
|
377
|
-
const res = { errMsg: `setTabBarItem${isObject.msg}` }
|
|
378
|
-
console.error(res.errMsg)
|
|
379
|
-
return Promise.reject(res)
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
const {
|
|
383
|
-
index,
|
|
384
|
-
text,
|
|
385
|
-
iconPath,
|
|
386
|
-
selectedIconPath,
|
|
387
|
-
success,
|
|
388
|
-
fail,
|
|
389
|
-
complete
|
|
390
|
-
} = options
|
|
391
|
-
const res = { errMsg: 'setTabBarItem:ok' }
|
|
392
|
-
|
|
393
|
-
if (typeof index !== 'number') {
|
|
394
|
-
res.errMsg = getParameterError({
|
|
395
|
-
name: 'setTabBarItem',
|
|
396
|
-
para: 'index',
|
|
397
|
-
correct: 'Number',
|
|
398
|
-
wrong: index
|
|
399
|
-
})
|
|
400
|
-
console.error(res.errMsg)
|
|
401
|
-
return errorHandler(fail, complete)(res)
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
if (
|
|
405
|
-
!tabConf ||
|
|
406
|
-
!tabConf.list ||
|
|
407
|
-
!tabConf.list[index]
|
|
408
|
-
) {
|
|
409
|
-
res.errMsg = 'setTabBarItem:fail tabbar item not found'
|
|
410
|
-
return errorHandler(fail, complete)(res)
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
const obj = {}
|
|
414
|
-
if (text) obj.text = text
|
|
415
|
-
if (iconPath) obj.iconPath = iconPath
|
|
416
|
-
if (selectedIconPath) obj.selectedIconPath = selectedIconPath
|
|
417
|
-
|
|
418
|
-
const temp = Object.assign({}, tabConf)
|
|
419
|
-
temp.list[index] = Object.assign({}, temp.list[index], obj)
|
|
420
|
-
|
|
421
|
-
App.setState && App.setState({ __tabs: temp })
|
|
422
|
-
|
|
423
|
-
return successHandler(success, complete)(res)
|
|
424
|
-
}
|