@tarojs/taro-h5 3.5.0-alpha.12 → 3.5.0-alpha.13
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/base/index.js +4 -4
- package/dist/api/canvas/canvasGetImageData.js +1 -1
- package/dist/api/canvas/canvasPutImageData.js +1 -1
- package/dist/api/device/clipboard.js +1 -1
- package/dist/api/device/compass.js +1 -1
- package/dist/api/device/network.js +1 -1
- package/dist/api/device/phone.js +1 -1
- package/dist/api/index.js +2 -2
- package/dist/api/location/chooseLocation.js +1 -1
- package/dist/api/media/image/chooseImage.js +1 -1
- package/dist/api/media/image/index.js +1 -1
- package/dist/api/media/video/index.js +1 -1
- package/dist/api/network/request/index.js +1 -1
- package/dist/api/network/websocket/index.js +2 -2
- package/dist/api/route/index.js +1 -1
- package/dist/api/storage/index.js +1 -1
- package/dist/api/taro.js +2 -2
- package/dist/api/ui/index.js +1 -1
- package/dist/api/ui/interaction/index.js +3 -3
- package/dist/api/ui/navigation-bar/index.js +1 -1
- package/dist/api/ui/scroll/index.js +1 -1
- package/dist/api/ui/tab-bar.js +1 -1
- package/dist/api/wxml/selectorQuery.js +1 -1
- package/dist/index.cjs.js +1089 -1089
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1089 -1089
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +5 -5
- package/src/api/base/index.ts +4 -4
- package/src/api/canvas/canvasGetImageData.ts +2 -1
- package/src/api/canvas/canvasPutImageData.ts +2 -1
- package/src/api/canvas/canvasToTempFilePath.ts +1 -0
- package/src/api/canvas/createCanvasContext.ts +1 -0
- package/src/api/cloud/index.ts +1 -0
- package/src/api/device/accelerometer.ts +1 -0
- package/src/api/device/battery.ts +1 -0
- package/src/api/device/clipboard.ts +2 -1
- package/src/api/device/compass.ts +1 -1
- package/src/api/device/network.ts +1 -1
- package/src/api/device/phone.ts +2 -1
- package/src/api/device/vibrate.ts +1 -0
- package/src/api/index.ts +2 -3
- package/src/api/location/chooseLocation.ts +2 -1
- package/src/api/location/getLocation.ts +1 -0
- package/src/api/media/EditorContext.ts +1 -0
- package/src/api/media/audio/InnerAudioContext.ts +1 -0
- package/src/api/media/audio/index.ts +1 -0
- package/src/api/media/background-audio/BackgroundAudioManager.ts +1 -0
- package/src/api/media/image/chooseImage.ts +1 -1
- package/src/api/media/image/index.ts +1 -1
- package/src/api/media/video/index.ts +1 -1
- package/src/api/network/download.ts +1 -0
- package/src/api/network/request/index.ts +2 -1
- package/src/api/network/upload.ts +2 -1
- package/src/api/network/websocket/index.ts +2 -2
- package/src/api/route/index.ts +4 -4
- package/src/api/storage/index.ts +2 -1
- package/src/api/taro.ts +10 -10
- package/src/api/ui/fonts.ts +1 -0
- package/src/api/ui/index.ts +1 -1
- package/src/api/ui/interaction/index.ts +4 -3
- package/src/api/ui/navigation-bar/index.ts +1 -1
- package/src/api/ui/pull-down-refresh.ts +1 -0
- package/src/api/ui/scroll/index.ts +1 -1
- package/src/api/ui/tab-bar.ts +2 -1
- package/src/api/ui/window.ts +1 -0
- package/src/api/wxml/index.ts +1 -0
- package/src/api/wxml/selectorQuery.ts +2 -1
- package/src/utils/index.ts +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -240,6 +240,20 @@ const isVKSupport = temporarilyNotSupport('isVKSupport');
|
|
|
240
240
|
// 视觉算法
|
|
241
241
|
const createVKSession = temporarilyNotSupport('createVKSession');
|
|
242
242
|
|
|
243
|
+
// AliPay
|
|
244
|
+
const getOpenUserInfo = temporarilyNotSupport('getOpenUserInfo');
|
|
245
|
+
|
|
246
|
+
// 加密
|
|
247
|
+
const getUserCryptoManager = temporarilyNotSupport('getUserCryptoManager');
|
|
248
|
+
|
|
249
|
+
const setEnableDebug = temporarilyNotSupport('setEnableDebug');
|
|
250
|
+
const getRealtimeLogManager = temporarilyNotSupport('getRealtimeLogManager');
|
|
251
|
+
const getLogManager = temporarilyNotSupport('getLogManager');
|
|
252
|
+
|
|
253
|
+
// 性能
|
|
254
|
+
const reportPerformance = temporarilyNotSupport('reportPerformance');
|
|
255
|
+
const getPerformance = temporarilyNotSupport('getPerformance');
|
|
256
|
+
|
|
243
257
|
/*! *****************************************************************************
|
|
244
258
|
Copyright (c) Microsoft Corporation.
|
|
245
259
|
|
|
@@ -745,10 +759,6 @@ const getSystemInfo = (options = {}) => __awaiter(void 0, void 0, void 0, functi
|
|
|
745
759
|
const updateWeChatApp = temporarilyNotSupport('updateWeChatApp');
|
|
746
760
|
const getUpdateManager = temporarilyNotSupport('getUpdateManager');
|
|
747
761
|
|
|
748
|
-
// 生命周期
|
|
749
|
-
const getLaunchOptionsSync = temporarilyNotSupport('getLaunchOptionsSync');
|
|
750
|
-
const getEnterOptionsSync = temporarilyNotSupport('getEnterOptionsSync');
|
|
751
|
-
|
|
752
762
|
// 应用级事件
|
|
753
763
|
const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection');
|
|
754
764
|
const onThemeChange = temporarilyNotSupport('onThemeChange');
|
|
@@ -767,16 +777,9 @@ const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBeg
|
|
|
767
777
|
const offAppShow = temporarilyNotSupport('offAppShow');
|
|
768
778
|
const offAppHide = temporarilyNotSupport('offAppHide');
|
|
769
779
|
|
|
770
|
-
|
|
771
|
-
const
|
|
772
|
-
const
|
|
773
|
-
|
|
774
|
-
// 性能
|
|
775
|
-
const reportPerformance = temporarilyNotSupport('reportPerformance');
|
|
776
|
-
const getPerformance = temporarilyNotSupport('getPerformance');
|
|
777
|
-
|
|
778
|
-
// 加密
|
|
779
|
-
const getUserCryptoManager = temporarilyNotSupport('getUserCryptoManager');
|
|
780
|
+
// 生命周期
|
|
781
|
+
const getLaunchOptionsSync = temporarilyNotSupport('getLaunchOptionsSync');
|
|
782
|
+
const getEnterOptionsSync = temporarilyNotSupport('getEnterOptionsSync');
|
|
780
783
|
|
|
781
784
|
// TODO env 环境变量
|
|
782
785
|
const canIUse = temporarilyNotSupport('canIUse');
|
|
@@ -2230,6 +2233,51 @@ const getBackgroundAudioManager = () => new BackgroundAudioManager();
|
|
|
2230
2233
|
// 相机
|
|
2231
2234
|
const createCameraContext = temporarilyNotSupport('createCameraContext');
|
|
2232
2235
|
|
|
2236
|
+
/**
|
|
2237
|
+
* 获取图片信息。网络图片需先配置download域名才能生效。
|
|
2238
|
+
*/
|
|
2239
|
+
const getImageInfo = (options) => {
|
|
2240
|
+
// options must be an Object
|
|
2241
|
+
const isObject = shouldBeObject(options);
|
|
2242
|
+
if (!isObject.flag) {
|
|
2243
|
+
const res = { errMsg: `getImageInfo:fail ${isObject.msg}` };
|
|
2244
|
+
console.error(res.errMsg);
|
|
2245
|
+
return Promise.reject(res);
|
|
2246
|
+
}
|
|
2247
|
+
const getBase64Image = (image) => {
|
|
2248
|
+
try {
|
|
2249
|
+
const canvas = document.createElement('canvas');
|
|
2250
|
+
canvas.width = image.width;
|
|
2251
|
+
canvas.height = image.height;
|
|
2252
|
+
const ctx = canvas.getContext('2d');
|
|
2253
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
2254
|
+
return canvas.toDataURL('image/png');
|
|
2255
|
+
}
|
|
2256
|
+
catch (e) {
|
|
2257
|
+
console.error('getImageInfo:get base64 fail', e);
|
|
2258
|
+
}
|
|
2259
|
+
};
|
|
2260
|
+
const { src, success, fail, complete } = options;
|
|
2261
|
+
const handle = new MethodHandler({ name: 'getImageInfo', success, fail, complete });
|
|
2262
|
+
return new Promise((resolve, reject) => {
|
|
2263
|
+
const image = new Image();
|
|
2264
|
+
image.crossOrigin = '';
|
|
2265
|
+
image.onload = () => {
|
|
2266
|
+
handle.success({
|
|
2267
|
+
width: image.naturalWidth,
|
|
2268
|
+
height: image.naturalHeight,
|
|
2269
|
+
path: getBase64Image(image) || src
|
|
2270
|
+
}, resolve);
|
|
2271
|
+
};
|
|
2272
|
+
image.onerror = (e) => {
|
|
2273
|
+
handle.fail({
|
|
2274
|
+
errMsg: e.message
|
|
2275
|
+
}, reject);
|
|
2276
|
+
};
|
|
2277
|
+
image.src = src;
|
|
2278
|
+
});
|
|
2279
|
+
};
|
|
2280
|
+
|
|
2233
2281
|
/**
|
|
2234
2282
|
* previewImage api基于开源的React组件[react-wx-images-viewer](https://github.com/react-ld/react-wx-images-viewer)开发,感谢!
|
|
2235
2283
|
*/
|
|
@@ -2296,51 +2344,6 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
2296
2344
|
return handle.success();
|
|
2297
2345
|
});
|
|
2298
2346
|
|
|
2299
|
-
/**
|
|
2300
|
-
* 获取图片信息。网络图片需先配置download域名才能生效。
|
|
2301
|
-
*/
|
|
2302
|
-
const getImageInfo = (options) => {
|
|
2303
|
-
// options must be an Object
|
|
2304
|
-
const isObject = shouldBeObject(options);
|
|
2305
|
-
if (!isObject.flag) {
|
|
2306
|
-
const res = { errMsg: `getImageInfo:fail ${isObject.msg}` };
|
|
2307
|
-
console.error(res.errMsg);
|
|
2308
|
-
return Promise.reject(res);
|
|
2309
|
-
}
|
|
2310
|
-
const getBase64Image = (image) => {
|
|
2311
|
-
try {
|
|
2312
|
-
const canvas = document.createElement('canvas');
|
|
2313
|
-
canvas.width = image.width;
|
|
2314
|
-
canvas.height = image.height;
|
|
2315
|
-
const ctx = canvas.getContext('2d');
|
|
2316
|
-
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
2317
|
-
return canvas.toDataURL('image/png');
|
|
2318
|
-
}
|
|
2319
|
-
catch (e) {
|
|
2320
|
-
console.error('getImageInfo:get base64 fail', e);
|
|
2321
|
-
}
|
|
2322
|
-
};
|
|
2323
|
-
const { src, success, fail, complete } = options;
|
|
2324
|
-
const handle = new MethodHandler({ name: 'getImageInfo', success, fail, complete });
|
|
2325
|
-
return new Promise((resolve, reject) => {
|
|
2326
|
-
const image = new Image();
|
|
2327
|
-
image.crossOrigin = '';
|
|
2328
|
-
image.onload = () => {
|
|
2329
|
-
handle.success({
|
|
2330
|
-
width: image.naturalWidth,
|
|
2331
|
-
height: image.naturalHeight,
|
|
2332
|
-
path: getBase64Image(image) || src
|
|
2333
|
-
}, resolve);
|
|
2334
|
-
};
|
|
2335
|
-
image.onerror = (e) => {
|
|
2336
|
-
handle.fail({
|
|
2337
|
-
errMsg: e.message
|
|
2338
|
-
}, reject);
|
|
2339
|
-
};
|
|
2340
|
-
image.src = src;
|
|
2341
|
-
});
|
|
2342
|
-
};
|
|
2343
|
-
|
|
2344
2347
|
/**
|
|
2345
2348
|
* 从本地相册选择图片或使用相机拍照。
|
|
2346
2349
|
*/
|
|
@@ -3249,6 +3252,32 @@ const hideShareMenu = temporarilyNotSupport('hideShareMenu');
|
|
|
3249
3252
|
const getShareInfo = temporarilyNotSupport('getShareInfo');
|
|
3250
3253
|
const authPrivateMessage = temporarilyNotSupport('authPrivateMessage');
|
|
3251
3254
|
|
|
3255
|
+
const setPageInfo = temporarilyNotSupport('setPageInfo');
|
|
3256
|
+
// 百度小程序 AI 相关
|
|
3257
|
+
const ocrIdCard = temporarilyNotSupport('ocrIdCard');
|
|
3258
|
+
const ocrBankCard = temporarilyNotSupport('ocrBankCard');
|
|
3259
|
+
const ocrDrivingLicense = temporarilyNotSupport('ocrDrivingLicense');
|
|
3260
|
+
const ocrVehicleLicense = temporarilyNotSupport('ocrVehicleLicense');
|
|
3261
|
+
const textReview = temporarilyNotSupport('textReview');
|
|
3262
|
+
const textToAudio = temporarilyNotSupport('textToAudio');
|
|
3263
|
+
const imageAudit = temporarilyNotSupport('imageAudit');
|
|
3264
|
+
const advancedGeneralIdentify = temporarilyNotSupport('advancedGeneralIdentify');
|
|
3265
|
+
const objectDetectIdentify = temporarilyNotSupport('objectDetectIdentify');
|
|
3266
|
+
const carClassify = temporarilyNotSupport('carClassify');
|
|
3267
|
+
const dishClassify = temporarilyNotSupport('dishClassify');
|
|
3268
|
+
const logoClassify = temporarilyNotSupport('logoClassify');
|
|
3269
|
+
const animalClassify = temporarilyNotSupport('animalClassify');
|
|
3270
|
+
const plantClassify = temporarilyNotSupport('plantClassify');
|
|
3271
|
+
// 用户信息
|
|
3272
|
+
const getSwanId = temporarilyNotSupport('getSwanId');
|
|
3273
|
+
// 百度收银台支付
|
|
3274
|
+
const requestPolymerPayment = temporarilyNotSupport('requestPolymerPayment');
|
|
3275
|
+
// 打开小程序
|
|
3276
|
+
const navigateToSmartGameProgram = temporarilyNotSupport('navigateToSmartGameProgram');
|
|
3277
|
+
const navigateToSmartProgram = temporarilyNotSupport('navigateToSmartProgram');
|
|
3278
|
+
const navigateBackSmartProgram = temporarilyNotSupport('navigateBackSmartProgram');
|
|
3279
|
+
const preloadSubPackage = temporarilyNotSupport('preloadSubPackage');
|
|
3280
|
+
|
|
3252
3281
|
/**
|
|
3253
3282
|
* H5 下的 styleSheet 操作
|
|
3254
3283
|
* @author leeenx
|
|
@@ -3596,468 +3625,370 @@ const loadFontFace = (options) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
3596
3625
|
}
|
|
3597
3626
|
});
|
|
3598
3627
|
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3628
|
+
const noop = function () { };
|
|
3629
|
+
class ActionSheet {
|
|
3630
|
+
constructor() {
|
|
3631
|
+
this.options = {
|
|
3632
|
+
itemList: [],
|
|
3633
|
+
itemColor: '#000000',
|
|
3634
|
+
success: noop,
|
|
3635
|
+
fail: noop,
|
|
3636
|
+
complete: noop
|
|
3637
|
+
};
|
|
3638
|
+
this.style = {
|
|
3639
|
+
maskStyle: {
|
|
3640
|
+
position: 'fixed',
|
|
3641
|
+
'z-index': '1000',
|
|
3642
|
+
top: '0',
|
|
3643
|
+
right: '0',
|
|
3644
|
+
left: '0',
|
|
3645
|
+
bottom: '0',
|
|
3646
|
+
background: 'rgba(0,0,0,0.6)'
|
|
3647
|
+
},
|
|
3648
|
+
actionSheetStyle: {
|
|
3649
|
+
'z-index': '4999',
|
|
3650
|
+
position: 'fixed',
|
|
3651
|
+
left: '0',
|
|
3652
|
+
bottom: '0',
|
|
3653
|
+
'-webkit-transform': 'translate(0, 100%)',
|
|
3654
|
+
transform: 'translate(0, 100%)',
|
|
3655
|
+
width: '100%',
|
|
3656
|
+
'line-height': '1.6',
|
|
3657
|
+
background: '#EFEFF4',
|
|
3658
|
+
'-webkit-transition': '-webkit-transform .3s',
|
|
3659
|
+
transition: 'transform .3s'
|
|
3660
|
+
},
|
|
3661
|
+
menuStyle: {
|
|
3662
|
+
'background-color': '#FCFCFD'
|
|
3663
|
+
},
|
|
3664
|
+
cellStyle: {
|
|
3665
|
+
position: 'relative',
|
|
3666
|
+
padding: '10px 0',
|
|
3667
|
+
'text-align': 'center',
|
|
3668
|
+
'font-size': '18px'
|
|
3669
|
+
},
|
|
3670
|
+
cancelStyle: {
|
|
3671
|
+
'margin-top': '6px',
|
|
3672
|
+
padding: '10px 0',
|
|
3673
|
+
'text-align': 'center',
|
|
3674
|
+
'font-size': '18px',
|
|
3675
|
+
color: '#000000',
|
|
3676
|
+
'background-color': '#FCFCFD'
|
|
3677
|
+
}
|
|
3678
|
+
};
|
|
3679
|
+
this.lastConfig = {};
|
|
3625
3680
|
}
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
const
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3681
|
+
create(options = {}) {
|
|
3682
|
+
return new Promise((resolve) => {
|
|
3683
|
+
// style
|
|
3684
|
+
const { maskStyle, actionSheetStyle, menuStyle, cellStyle, cancelStyle } = this.style;
|
|
3685
|
+
// configuration
|
|
3686
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
3687
|
+
this.lastConfig = config;
|
|
3688
|
+
// wrapper
|
|
3689
|
+
this.el = document.createElement('div');
|
|
3690
|
+
this.el.className = 'taro__actionSheet';
|
|
3691
|
+
this.el.style.opacity = '0';
|
|
3692
|
+
this.el.style.transition = 'opacity 0.2s linear';
|
|
3693
|
+
// mask
|
|
3694
|
+
const mask = document.createElement('div');
|
|
3695
|
+
mask.setAttribute('style', inlineStyle(maskStyle));
|
|
3696
|
+
// actionSheet
|
|
3697
|
+
this.actionSheet = document.createElement('div');
|
|
3698
|
+
this.actionSheet.setAttribute('style', inlineStyle(actionSheetStyle));
|
|
3699
|
+
// menu
|
|
3700
|
+
this.menu = document.createElement('div');
|
|
3701
|
+
this.menu.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, menuStyle), { color: config.itemColor })));
|
|
3702
|
+
// cells
|
|
3703
|
+
this.cells = config.itemList.map((item, index) => {
|
|
3704
|
+
const cell = document.createElement('div');
|
|
3705
|
+
cell.className = 'taro-actionsheet__cell';
|
|
3706
|
+
cell.setAttribute('style', inlineStyle(cellStyle));
|
|
3707
|
+
cell.textContent = item;
|
|
3708
|
+
cell.dataset.tapIndex = `${index}`;
|
|
3709
|
+
cell.onclick = e => {
|
|
3710
|
+
this.hide();
|
|
3711
|
+
const target = e.currentTarget;
|
|
3712
|
+
const index = Number(target === null || target === void 0 ? void 0 : target.dataset.tapIndex) || 0;
|
|
3713
|
+
resolve(index);
|
|
3714
|
+
};
|
|
3715
|
+
return cell;
|
|
3716
|
+
});
|
|
3717
|
+
// cancel
|
|
3718
|
+
this.cancel = document.createElement('div');
|
|
3719
|
+
this.cancel.setAttribute('style', inlineStyle(cancelStyle));
|
|
3720
|
+
this.cancel.textContent = '取消';
|
|
3721
|
+
// result
|
|
3722
|
+
this.cells.forEach(item => this.menu.appendChild(item));
|
|
3723
|
+
this.actionSheet.appendChild(this.menu);
|
|
3724
|
+
this.actionSheet.appendChild(this.cancel);
|
|
3725
|
+
this.el.appendChild(mask);
|
|
3726
|
+
this.el.appendChild(this.actionSheet);
|
|
3727
|
+
// callbacks
|
|
3728
|
+
const cb = () => {
|
|
3729
|
+
this.hide();
|
|
3730
|
+
resolve('cancel');
|
|
3731
|
+
};
|
|
3732
|
+
mask.onclick = cb;
|
|
3733
|
+
this.cancel.onclick = cb;
|
|
3734
|
+
// show immediately
|
|
3735
|
+
document.body.appendChild(this.el);
|
|
3736
|
+
setTimeout(() => {
|
|
3737
|
+
this.el.style.opacity = '1';
|
|
3738
|
+
setTransform(this.actionSheet, 'translate(0, 0)');
|
|
3739
|
+
}, 0);
|
|
3664
3740
|
});
|
|
3665
|
-
}
|
|
3666
|
-
}
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
const id = (_b = (_a = runtime.Current.page) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(/([^a-z0-9\u00a0-\uffff_-])/ig, '\\$1');
|
|
3685
|
-
const el = (id
|
|
3686
|
-
? document.querySelector(`.taro_page#${id}`)
|
|
3687
|
-
: document.querySelector('.taro_page') ||
|
|
3688
|
-
document.querySelector('.taro_router'));
|
|
3689
|
-
if (!scrollFunc) {
|
|
3690
|
-
if (!el) {
|
|
3691
|
-
scrollFunc = pos => {
|
|
3692
|
-
if (pos === undefined) {
|
|
3693
|
-
return window.pageYOffset;
|
|
3694
|
-
}
|
|
3695
|
-
else {
|
|
3696
|
-
window.scrollTo(0, pos);
|
|
3697
|
-
}
|
|
3698
|
-
};
|
|
3741
|
+
}
|
|
3742
|
+
show(options = {}) {
|
|
3743
|
+
return new Promise((resolve) => {
|
|
3744
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
3745
|
+
this.lastConfig = config;
|
|
3746
|
+
if (this.hideOpacityTimer)
|
|
3747
|
+
clearTimeout(this.hideOpacityTimer);
|
|
3748
|
+
if (this.hideDisplayTimer)
|
|
3749
|
+
clearTimeout(this.hideDisplayTimer);
|
|
3750
|
+
// itemColor
|
|
3751
|
+
if (config.itemColor)
|
|
3752
|
+
this.menu.style.color = config.itemColor;
|
|
3753
|
+
// cells
|
|
3754
|
+
const { cellStyle } = this.style;
|
|
3755
|
+
config.itemList.forEach((item, index) => {
|
|
3756
|
+
let cell;
|
|
3757
|
+
if (this.cells[index]) {
|
|
3758
|
+
// assign new content
|
|
3759
|
+
cell = this.cells[index];
|
|
3699
3760
|
}
|
|
3700
3761
|
else {
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
};
|
|
3709
|
-
}
|
|
3710
|
-
}
|
|
3711
|
-
if (scrollTop && selector) {
|
|
3712
|
-
console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector');
|
|
3713
|
-
}
|
|
3714
|
-
const from = scrollFunc();
|
|
3715
|
-
let to;
|
|
3716
|
-
if (typeof scrollTop === 'number') {
|
|
3717
|
-
to = scrollTop;
|
|
3718
|
-
}
|
|
3719
|
-
else {
|
|
3720
|
-
const el = document.querySelector(selector);
|
|
3721
|
-
to = (el === null || el === void 0 ? void 0 : el.offsetTop) || 0;
|
|
3722
|
-
}
|
|
3723
|
-
const delta = to - from;
|
|
3724
|
-
const frameCnt = duration / FRAME_DURATION;
|
|
3725
|
-
const easeFunc = getTimingFunc(easeInOut, frameCnt);
|
|
3726
|
-
const scroll = (frame = 0) => {
|
|
3727
|
-
const dest = from + delta * easeFunc(frame);
|
|
3728
|
-
scrollFunc(dest);
|
|
3729
|
-
if (frame < frameCnt) {
|
|
3730
|
-
timer && clearTimeout(timer);
|
|
3731
|
-
timer = setTimeout(() => {
|
|
3732
|
-
scroll(frame + 1);
|
|
3733
|
-
}, FRAME_DURATION);
|
|
3762
|
+
// create new cell
|
|
3763
|
+
cell = document.createElement('div');
|
|
3764
|
+
cell.className = 'taro-actionsheet__cell';
|
|
3765
|
+
cell.setAttribute('style', inlineStyle(cellStyle));
|
|
3766
|
+
cell.dataset.tapIndex = `${index}`;
|
|
3767
|
+
this.cells.push(cell);
|
|
3768
|
+
this.menu.appendChild(cell);
|
|
3734
3769
|
}
|
|
3735
|
-
|
|
3736
|
-
|
|
3770
|
+
cell.textContent = item;
|
|
3771
|
+
cell.onclick = e => {
|
|
3772
|
+
this.hide();
|
|
3773
|
+
const target = e.currentTarget;
|
|
3774
|
+
const index = Number(target === null || target === void 0 ? void 0 : target.dataset.tapIndex) || 0;
|
|
3775
|
+
resolve(index);
|
|
3776
|
+
};
|
|
3777
|
+
});
|
|
3778
|
+
const cellsLen = this.cells.length;
|
|
3779
|
+
const itemListLen = config.itemList.length;
|
|
3780
|
+
if (cellsLen > itemListLen) {
|
|
3781
|
+
for (let i = itemListLen; i < cellsLen; i++) {
|
|
3782
|
+
this.menu.removeChild(this.cells[i]);
|
|
3737
3783
|
}
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
});
|
|
3747
|
-
};
|
|
3748
|
-
|
|
3749
|
-
// 置顶
|
|
3750
|
-
const setTopBarText = temporarilyNotSupport('setTopBarText');
|
|
3751
|
-
|
|
3752
|
-
let tabConf;
|
|
3753
|
-
function initTabBarApis(config = {}) {
|
|
3754
|
-
tabConf = config.tabBar;
|
|
3755
|
-
}
|
|
3756
|
-
/**
|
|
3757
|
-
* 显示 tabBar 某一项的右上角的红点
|
|
3758
|
-
*/
|
|
3759
|
-
const showTabBarRedDot = (options) => {
|
|
3760
|
-
// options must be an Object
|
|
3761
|
-
const isObject = shouldBeObject(options);
|
|
3762
|
-
if (!isObject.flag) {
|
|
3763
|
-
const res = { errMsg: `showTabBarRedDot:fail ${isObject.msg}` };
|
|
3764
|
-
console.error(res.errMsg);
|
|
3765
|
-
return Promise.reject(res);
|
|
3766
|
-
}
|
|
3767
|
-
const { index, success, fail, complete } = options;
|
|
3768
|
-
const handle = new MethodHandler({ name: 'showTabBarRedDot', success, fail, complete });
|
|
3769
|
-
if (typeof index !== 'number') {
|
|
3770
|
-
return handle.fail({
|
|
3771
|
-
errMsg: getParameterError({
|
|
3772
|
-
para: 'index',
|
|
3773
|
-
correct: 'Number',
|
|
3774
|
-
wrong: index
|
|
3775
|
-
})
|
|
3784
|
+
this.cells.splice(itemListLen);
|
|
3785
|
+
}
|
|
3786
|
+
// show
|
|
3787
|
+
this.el.style.display = 'block';
|
|
3788
|
+
setTimeout(() => {
|
|
3789
|
+
this.el.style.opacity = '1';
|
|
3790
|
+
setTransform(this.actionSheet, 'translate(0, 0)');
|
|
3791
|
+
}, 0);
|
|
3776
3792
|
});
|
|
3777
3793
|
}
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
*/
|
|
3789
|
-
const showTabBar = (options = {}) => {
|
|
3790
|
-
// options must be an Object
|
|
3791
|
-
const isObject = shouldBeObject(options);
|
|
3792
|
-
if (!isObject.flag) {
|
|
3793
|
-
const res = { errMsg: `showTabBar:fail ${isObject.msg}` };
|
|
3794
|
-
console.error(res.errMsg);
|
|
3795
|
-
return Promise.reject(res);
|
|
3794
|
+
hide() {
|
|
3795
|
+
if (this.hideOpacityTimer)
|
|
3796
|
+
clearTimeout(this.hideOpacityTimer);
|
|
3797
|
+
if (this.hideDisplayTimer)
|
|
3798
|
+
clearTimeout(this.hideDisplayTimer);
|
|
3799
|
+
this.hideOpacityTimer = setTimeout(() => {
|
|
3800
|
+
this.el.style.opacity = '0';
|
|
3801
|
+
setTransform(this.actionSheet, 'translate(0, 100%)');
|
|
3802
|
+
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
|
|
3803
|
+
}, 0);
|
|
3796
3804
|
}
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
Taro__default["default"].eventCenter.trigger('__taroSetTabBarStyle', {
|
|
3859
|
-
color,
|
|
3860
|
-
selectedColor,
|
|
3861
|
-
backgroundColor,
|
|
3862
|
-
borderStyle,
|
|
3863
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
3864
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
3865
|
-
});
|
|
3866
|
-
});
|
|
3867
|
-
};
|
|
3868
|
-
/**
|
|
3869
|
-
* 动态设置 tabBar 某一项的内容
|
|
3870
|
-
*/
|
|
3871
|
-
const setTabBarItem = (options) => {
|
|
3872
|
-
// options must be an Object
|
|
3873
|
-
const isObject = shouldBeObject(options);
|
|
3874
|
-
if (!isObject.flag) {
|
|
3875
|
-
const res = { errMsg: `setTabBarItem:fail ${isObject.msg}` };
|
|
3876
|
-
console.error(res.errMsg);
|
|
3877
|
-
return Promise.reject(res);
|
|
3878
|
-
}
|
|
3879
|
-
const { index, text, iconPath, selectedIconPath, success, fail, complete } = options;
|
|
3880
|
-
const handle = new MethodHandler({ name: 'setTabBarItem', success, fail, complete });
|
|
3881
|
-
if (typeof index !== 'number') {
|
|
3882
|
-
return handle.fail({
|
|
3883
|
-
errMsg: getParameterError({
|
|
3884
|
-
para: 'index',
|
|
3885
|
-
correct: 'Number',
|
|
3886
|
-
wrong: index
|
|
3887
|
-
})
|
|
3888
|
-
});
|
|
3889
|
-
}
|
|
3890
|
-
return new Promise((resolve, reject) => {
|
|
3891
|
-
Taro__default["default"].eventCenter.trigger('__taroSetTabBarItem', {
|
|
3892
|
-
index,
|
|
3893
|
-
text,
|
|
3894
|
-
iconPath,
|
|
3895
|
-
selectedIconPath,
|
|
3896
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
3897
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
3898
|
-
});
|
|
3899
|
-
});
|
|
3900
|
-
};
|
|
3901
|
-
/**
|
|
3902
|
-
* 为 tabBar 某一项的右上角添加文本
|
|
3903
|
-
*/
|
|
3904
|
-
const setTabBarBadge = (options) => {
|
|
3905
|
-
// options must be an Object
|
|
3906
|
-
const isObject = shouldBeObject(options);
|
|
3907
|
-
if (!isObject.flag) {
|
|
3908
|
-
const res = { errMsg: `setTabBarBadge:fail ${isObject.msg}` };
|
|
3909
|
-
console.error(res.errMsg);
|
|
3910
|
-
return Promise.reject(res);
|
|
3911
|
-
}
|
|
3912
|
-
const { index, text, success, fail, complete } = options;
|
|
3913
|
-
const handle = new MethodHandler({ name: 'setTabBarBadge', success, fail, complete });
|
|
3914
|
-
if (typeof index !== 'number') {
|
|
3915
|
-
return handle.fail({
|
|
3916
|
-
errMsg: getParameterError({
|
|
3917
|
-
para: 'index',
|
|
3918
|
-
correct: 'Number',
|
|
3919
|
-
wrong: index
|
|
3920
|
-
})
|
|
3921
|
-
});
|
|
3922
|
-
}
|
|
3923
|
-
if (typeof text !== 'string') {
|
|
3924
|
-
return handle.fail({
|
|
3925
|
-
errMsg: getParameterError({
|
|
3926
|
-
para: 'text',
|
|
3927
|
-
correct: 'String',
|
|
3928
|
-
wrong: text
|
|
3929
|
-
})
|
|
3930
|
-
});
|
|
3931
|
-
}
|
|
3932
|
-
return new Promise((resolve, reject) => {
|
|
3933
|
-
Taro__default["default"].eventCenter.trigger('__taroSetTabBarBadge', {
|
|
3934
|
-
index,
|
|
3935
|
-
text,
|
|
3936
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
3937
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
3938
|
-
});
|
|
3939
|
-
});
|
|
3940
|
-
};
|
|
3941
|
-
/**
|
|
3942
|
-
* 移除 tabBar 某一项右上角的文本
|
|
3943
|
-
*/
|
|
3944
|
-
const removeTabBarBadge = (options) => {
|
|
3945
|
-
// options must be an Object
|
|
3946
|
-
const isObject = shouldBeObject(options);
|
|
3947
|
-
if (!isObject.flag) {
|
|
3948
|
-
const res = { errMsg: `removeTabBarBadge:fail ${isObject.msg}` };
|
|
3949
|
-
console.error(res.errMsg);
|
|
3950
|
-
return Promise.reject(res);
|
|
3951
|
-
}
|
|
3952
|
-
const { index, success, fail, complete } = options;
|
|
3953
|
-
const handle = new MethodHandler({ name: 'removeTabBarBadge', success, fail, complete });
|
|
3954
|
-
if (typeof index !== 'number') {
|
|
3955
|
-
return handle.fail({
|
|
3956
|
-
errMsg: getParameterError({
|
|
3957
|
-
para: 'index',
|
|
3958
|
-
correct: 'Number',
|
|
3959
|
-
wrong: index
|
|
3960
|
-
})
|
|
3961
|
-
});
|
|
3962
|
-
}
|
|
3963
|
-
return new Promise((resolve, reject) => {
|
|
3964
|
-
Taro__default["default"].eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
3965
|
-
index,
|
|
3966
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
3967
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
3968
|
-
});
|
|
3969
|
-
});
|
|
3970
|
-
};
|
|
3971
|
-
/**
|
|
3972
|
-
* 隐藏 tabBar 某一项的右上角的红点
|
|
3973
|
-
*/
|
|
3974
|
-
const hideTabBarRedDot = (options) => {
|
|
3975
|
-
// options must be an Object
|
|
3976
|
-
const isObject = shouldBeObject(options);
|
|
3977
|
-
if (!isObject.flag) {
|
|
3978
|
-
const res = { errMsg: `hideTabBarRedDot:fail ${isObject.msg}` };
|
|
3979
|
-
console.error(res.errMsg);
|
|
3980
|
-
return Promise.reject(res);
|
|
3981
|
-
}
|
|
3982
|
-
const { index, success, fail, complete } = options;
|
|
3983
|
-
const handle = new MethodHandler({ name: 'hideTabBarRedDot', success, fail, complete });
|
|
3984
|
-
if (typeof index !== 'number') {
|
|
3985
|
-
return handle.fail({
|
|
3986
|
-
errMsg: getParameterError({
|
|
3987
|
-
para: 'index',
|
|
3988
|
-
correct: 'Number',
|
|
3989
|
-
wrong: index
|
|
3990
|
-
})
|
|
3991
|
-
});
|
|
3992
|
-
}
|
|
3993
|
-
return new Promise((resolve, reject) => {
|
|
3994
|
-
Taro__default["default"].eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
3995
|
-
index,
|
|
3996
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
3997
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
3998
|
-
});
|
|
3999
|
-
});
|
|
4000
|
-
};
|
|
4001
|
-
/**
|
|
4002
|
-
* 隐藏 tabBar
|
|
4003
|
-
*/
|
|
4004
|
-
const hideTabBar = (options = {}) => {
|
|
4005
|
-
// options must be an Object
|
|
4006
|
-
const isObject = shouldBeObject(options);
|
|
4007
|
-
if (!isObject.flag) {
|
|
4008
|
-
const res = { errMsg: `hideTabBar:fail ${isObject.msg}` };
|
|
4009
|
-
console.error(res.errMsg);
|
|
4010
|
-
return Promise.reject(res);
|
|
3805
|
+
}
|
|
3806
|
+
|
|
3807
|
+
class Modal {
|
|
3808
|
+
constructor() {
|
|
3809
|
+
this.options = {
|
|
3810
|
+
title: '',
|
|
3811
|
+
content: '',
|
|
3812
|
+
showCancel: true,
|
|
3813
|
+
cancelText: '取消',
|
|
3814
|
+
cancelColor: '#000000',
|
|
3815
|
+
confirmText: '确定',
|
|
3816
|
+
confirmColor: '#3CC51F'
|
|
3817
|
+
};
|
|
3818
|
+
this.style = {
|
|
3819
|
+
maskStyle: {
|
|
3820
|
+
position: 'fixed',
|
|
3821
|
+
'z-index': '1000',
|
|
3822
|
+
top: '0',
|
|
3823
|
+
right: '0',
|
|
3824
|
+
left: '0',
|
|
3825
|
+
bottom: '0',
|
|
3826
|
+
background: 'rgba(0,0,0,0.6)'
|
|
3827
|
+
},
|
|
3828
|
+
modalStyle: {
|
|
3829
|
+
'z-index': '4999',
|
|
3830
|
+
position: 'fixed',
|
|
3831
|
+
top: '50%',
|
|
3832
|
+
left: '50%',
|
|
3833
|
+
transform: 'translate(-50%, -50%)',
|
|
3834
|
+
width: '80%',
|
|
3835
|
+
'max-width': '300px',
|
|
3836
|
+
'border-radius': '3px',
|
|
3837
|
+
'text-align': 'center',
|
|
3838
|
+
'line-height': '1.6',
|
|
3839
|
+
overflow: 'hidden',
|
|
3840
|
+
background: '#FFFFFF'
|
|
3841
|
+
},
|
|
3842
|
+
titleStyle: {
|
|
3843
|
+
padding: '20px 24px 9px',
|
|
3844
|
+
'font-size': '18px'
|
|
3845
|
+
},
|
|
3846
|
+
textStyle: {
|
|
3847
|
+
padding: '0 24px 12px',
|
|
3848
|
+
'min-height': '40px',
|
|
3849
|
+
'font-size': '15px',
|
|
3850
|
+
'line-height': '1.3',
|
|
3851
|
+
color: '#808080'
|
|
3852
|
+
},
|
|
3853
|
+
footStyle: {
|
|
3854
|
+
position: 'relative',
|
|
3855
|
+
'line-height': '48px',
|
|
3856
|
+
'font-size': '18px',
|
|
3857
|
+
display: 'flex'
|
|
3858
|
+
},
|
|
3859
|
+
btnStyle: {
|
|
3860
|
+
position: 'relative',
|
|
3861
|
+
'-webkit-box-flex': '1',
|
|
3862
|
+
'-webkit-flex': '1',
|
|
3863
|
+
flex: '1'
|
|
3864
|
+
}
|
|
3865
|
+
};
|
|
4011
3866
|
}
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
3867
|
+
create(options = {}) {
|
|
3868
|
+
return new Promise((resolve) => {
|
|
3869
|
+
// style
|
|
3870
|
+
const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style;
|
|
3871
|
+
// configuration
|
|
3872
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
3873
|
+
// wrapper
|
|
3874
|
+
this.el = document.createElement('div');
|
|
3875
|
+
this.el.className = 'taro__modal';
|
|
3876
|
+
this.el.style.opacity = '0';
|
|
3877
|
+
this.el.style.transition = 'opacity 0.2s linear';
|
|
3878
|
+
// mask
|
|
3879
|
+
const mask = document.createElement('div');
|
|
3880
|
+
mask.className = 'taro-modal__mask';
|
|
3881
|
+
mask.setAttribute('style', inlineStyle(maskStyle));
|
|
3882
|
+
// modal
|
|
3883
|
+
const modal = document.createElement('div');
|
|
3884
|
+
modal.className = 'taro-modal__content';
|
|
3885
|
+
modal.setAttribute('style', inlineStyle(modalStyle));
|
|
3886
|
+
// title
|
|
3887
|
+
const titleCSS = config.title ? titleStyle : Object.assign(Object.assign({}, titleStyle), { display: 'none' });
|
|
3888
|
+
this.title = document.createElement('div');
|
|
3889
|
+
this.title.className = 'taro-modal__title';
|
|
3890
|
+
this.title.setAttribute('style', inlineStyle(titleCSS));
|
|
3891
|
+
this.title.textContent = config.title;
|
|
3892
|
+
// text
|
|
3893
|
+
const textCSS = config.title ? textStyle : Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
3894
|
+
this.text = document.createElement('div');
|
|
3895
|
+
this.text.className = 'taro-modal__text';
|
|
3896
|
+
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
3897
|
+
this.text.textContent = config.content;
|
|
3898
|
+
// foot
|
|
3899
|
+
const foot = document.createElement('div');
|
|
3900
|
+
foot.className = 'taro-modal__foot';
|
|
3901
|
+
foot.setAttribute('style', inlineStyle(footStyle));
|
|
3902
|
+
// cancel button
|
|
3903
|
+
const cancelCSS = Object.assign(Object.assign({}, btnStyle), { color: config.cancelColor, display: config.showCancel ? 'block' : 'none' });
|
|
3904
|
+
this.cancel = document.createElement('div');
|
|
3905
|
+
this.cancel.className = 'taro-model__btn taro-model__cancel';
|
|
3906
|
+
this.cancel.setAttribute('style', inlineStyle(cancelCSS));
|
|
3907
|
+
this.cancel.textContent = config.cancelText;
|
|
3908
|
+
this.cancel.onclick = () => {
|
|
3909
|
+
this.hide();
|
|
3910
|
+
resolve('cancel');
|
|
3911
|
+
};
|
|
3912
|
+
// confirm button
|
|
3913
|
+
this.confirm = document.createElement('div');
|
|
3914
|
+
this.confirm.className = 'taro-model__btn taro-model__confirm';
|
|
3915
|
+
this.confirm.setAttribute('style', inlineStyle(btnStyle));
|
|
3916
|
+
this.confirm.style.color = config.confirmColor;
|
|
3917
|
+
this.confirm.textContent = config.confirmText;
|
|
3918
|
+
this.confirm.onclick = () => {
|
|
3919
|
+
this.hide();
|
|
3920
|
+
resolve('confirm');
|
|
3921
|
+
};
|
|
3922
|
+
// result
|
|
3923
|
+
foot.appendChild(this.cancel);
|
|
3924
|
+
foot.appendChild(this.confirm);
|
|
3925
|
+
modal.appendChild(this.title);
|
|
3926
|
+
modal.appendChild(this.text);
|
|
3927
|
+
modal.appendChild(foot);
|
|
3928
|
+
this.el.appendChild(mask);
|
|
3929
|
+
this.el.appendChild(modal);
|
|
3930
|
+
// show immediately
|
|
3931
|
+
document.body.appendChild(this.el);
|
|
3932
|
+
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
4021
3933
|
});
|
|
4022
3934
|
}
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
3935
|
+
show(options = {}) {
|
|
3936
|
+
return new Promise((resolve) => {
|
|
3937
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
3938
|
+
if (this.hideOpacityTimer)
|
|
3939
|
+
clearTimeout(this.hideOpacityTimer);
|
|
3940
|
+
if (this.hideDisplayTimer)
|
|
3941
|
+
clearTimeout(this.hideDisplayTimer);
|
|
3942
|
+
// title & text
|
|
3943
|
+
const { textStyle } = this.style;
|
|
3944
|
+
if (config.title) {
|
|
3945
|
+
this.title.textContent = config.title;
|
|
3946
|
+
// none => block
|
|
3947
|
+
this.title.style.display = 'block';
|
|
3948
|
+
this.text.setAttribute('style', inlineStyle(textStyle));
|
|
3949
|
+
}
|
|
3950
|
+
else {
|
|
3951
|
+
// block => none
|
|
3952
|
+
this.title.style.display = 'none';
|
|
3953
|
+
const textCSS = Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
3954
|
+
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
3955
|
+
}
|
|
3956
|
+
this.text.textContent = config.content || '';
|
|
3957
|
+
// showCancel
|
|
3958
|
+
this.cancel.style.display = config.showCancel ? 'block' : 'none';
|
|
3959
|
+
// cancelText
|
|
3960
|
+
this.cancel.textContent = config.cancelText || '';
|
|
3961
|
+
// cancelColor
|
|
3962
|
+
this.cancel.style.color = config.cancelColor || '';
|
|
3963
|
+
// confirmText
|
|
3964
|
+
this.confirm.textContent = config.confirmText || '';
|
|
3965
|
+
// confirmColor
|
|
3966
|
+
this.confirm.style.color = config.confirmColor || '';
|
|
3967
|
+
// cbs
|
|
3968
|
+
this.cancel.onclick = () => {
|
|
3969
|
+
this.hide();
|
|
3970
|
+
resolve('cancel');
|
|
3971
|
+
};
|
|
3972
|
+
this.confirm.onclick = () => {
|
|
3973
|
+
this.hide();
|
|
3974
|
+
resolve('confirm');
|
|
3975
|
+
};
|
|
3976
|
+
// show
|
|
3977
|
+
this.el.style.display = 'block';
|
|
3978
|
+
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
4028
3979
|
});
|
|
4029
|
-
});
|
|
4030
|
-
};
|
|
4031
|
-
|
|
4032
|
-
const callbackManager = new CallbackManager();
|
|
4033
|
-
const resizeListener = () => {
|
|
4034
|
-
callbackManager.trigger({
|
|
4035
|
-
windowWidth: window.screen.width,
|
|
4036
|
-
windowHeight: window.screen.height
|
|
4037
|
-
});
|
|
4038
|
-
};
|
|
4039
|
-
/**
|
|
4040
|
-
* 设置窗口大小,该接口仅适用于 PC 平台,使用细则请参见指南
|
|
4041
|
-
*/
|
|
4042
|
-
const setWindowSize = temporarilyNotSupport('setWindowSize');
|
|
4043
|
-
/**
|
|
4044
|
-
* 监听窗口尺寸变化事件
|
|
4045
|
-
*/
|
|
4046
|
-
const onWindowResize = callback => {
|
|
4047
|
-
callbackManager.add(callback);
|
|
4048
|
-
if (callbackManager.count() === 1) {
|
|
4049
|
-
window.addEventListener('resize', resizeListener);
|
|
4050
3980
|
}
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
3981
|
+
hide() {
|
|
3982
|
+
if (this.hideOpacityTimer)
|
|
3983
|
+
clearTimeout(this.hideOpacityTimer);
|
|
3984
|
+
if (this.hideDisplayTimer)
|
|
3985
|
+
clearTimeout(this.hideDisplayTimer);
|
|
3986
|
+
this.hideOpacityTimer = setTimeout(() => {
|
|
3987
|
+
this.el.style.opacity = '0';
|
|
3988
|
+
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
|
|
3989
|
+
}, 0);
|
|
4059
3990
|
}
|
|
4060
|
-
}
|
|
3991
|
+
}
|
|
4061
3992
|
|
|
4062
3993
|
class Toast {
|
|
4063
3994
|
constructor() {
|
|
@@ -4228,632 +4159,730 @@ class Toast {
|
|
|
4228
4159
|
}
|
|
4229
4160
|
}
|
|
4230
4161
|
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
background: '#FFFFFF'
|
|
4265
|
-
},
|
|
4266
|
-
titleStyle: {
|
|
4267
|
-
padding: '20px 24px 9px',
|
|
4268
|
-
'font-size': '18px'
|
|
4269
|
-
},
|
|
4270
|
-
textStyle: {
|
|
4271
|
-
padding: '0 24px 12px',
|
|
4272
|
-
'min-height': '40px',
|
|
4273
|
-
'font-size': '15px',
|
|
4274
|
-
'line-height': '1.3',
|
|
4275
|
-
color: '#808080'
|
|
4276
|
-
},
|
|
4277
|
-
footStyle: {
|
|
4278
|
-
position: 'relative',
|
|
4279
|
-
'line-height': '48px',
|
|
4280
|
-
'font-size': '18px',
|
|
4281
|
-
display: 'flex'
|
|
4282
|
-
},
|
|
4283
|
-
btnStyle: {
|
|
4284
|
-
position: 'relative',
|
|
4285
|
-
'-webkit-box-flex': '1',
|
|
4286
|
-
'-webkit-flex': '1',
|
|
4287
|
-
flex: '1'
|
|
4288
|
-
}
|
|
4289
|
-
};
|
|
4162
|
+
// 交互
|
|
4163
|
+
let status = 'default';
|
|
4164
|
+
// inject necessary style
|
|
4165
|
+
function init(doc) {
|
|
4166
|
+
if (status === 'ready')
|
|
4167
|
+
return;
|
|
4168
|
+
const taroStyle = doc.createElement('style');
|
|
4169
|
+
taroStyle.textContent = '@font-face{font-weight:normal;font-style:normal;font-family:"taro";src:url("data:application/x-font-ttf;charset=utf-8;base64, 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") format("truetype");}@-webkit-keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}@keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}.taro-modal__foot:after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);} .taro-model__btn:active {background-color: #EEEEEE}.taro-model__btn:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;width: 1px;bottom: 0;border-left: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleX(0.5);transform: scaleX(0.5);}.taro-actionsheet__cell:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #e5e5e5;color: #e5e5e5;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);}';
|
|
4170
|
+
doc.querySelector('head').appendChild(taroStyle);
|
|
4171
|
+
status = 'ready';
|
|
4172
|
+
}
|
|
4173
|
+
const toast = new Toast();
|
|
4174
|
+
const modal = new Modal();
|
|
4175
|
+
const actionSheet = new ActionSheet();
|
|
4176
|
+
const showToast = (options = { title: '' }) => {
|
|
4177
|
+
init(document);
|
|
4178
|
+
options = Object.assign({
|
|
4179
|
+
title: '',
|
|
4180
|
+
icon: 'success',
|
|
4181
|
+
image: '',
|
|
4182
|
+
duration: 1500,
|
|
4183
|
+
mask: false
|
|
4184
|
+
}, options);
|
|
4185
|
+
const { success, fail, complete } = options;
|
|
4186
|
+
const handle = new MethodHandler({ name: 'showToast', success, fail, complete });
|
|
4187
|
+
if (typeof options.title !== 'string') {
|
|
4188
|
+
return handle.fail({
|
|
4189
|
+
errMsg: getParameterError({
|
|
4190
|
+
para: 'title',
|
|
4191
|
+
correct: 'String',
|
|
4192
|
+
wrong: options.title
|
|
4193
|
+
})
|
|
4194
|
+
});
|
|
4290
4195
|
}
|
|
4291
|
-
|
|
4292
|
-
return
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4196
|
+
if (typeof options.duration !== 'number') {
|
|
4197
|
+
return handle.fail({
|
|
4198
|
+
errMsg: getParameterError({
|
|
4199
|
+
para: 'duration',
|
|
4200
|
+
correct: 'Number',
|
|
4201
|
+
wrong: options.duration
|
|
4202
|
+
})
|
|
4203
|
+
});
|
|
4204
|
+
}
|
|
4205
|
+
if (options.image && typeof options.image !== 'string')
|
|
4206
|
+
options.image = '';
|
|
4207
|
+
options.mask = !!options.mask;
|
|
4208
|
+
let errMsg = '';
|
|
4209
|
+
if (!toast.el) {
|
|
4210
|
+
errMsg = toast.create(options, 'toast');
|
|
4211
|
+
}
|
|
4212
|
+
else {
|
|
4213
|
+
errMsg = toast.show(options, 'toast');
|
|
4214
|
+
}
|
|
4215
|
+
return handle.success({ errMsg });
|
|
4216
|
+
};
|
|
4217
|
+
const hideToast = ({ success, fail, complete } = {}) => {
|
|
4218
|
+
const handle = new MethodHandler({ name: 'hideToast', success, fail, complete });
|
|
4219
|
+
if (!toast.el)
|
|
4220
|
+
return handle.success();
|
|
4221
|
+
toast.hide(0, 'toast');
|
|
4222
|
+
return handle.success();
|
|
4223
|
+
};
|
|
4224
|
+
const showLoading = (options = { title: '' }) => {
|
|
4225
|
+
init(document);
|
|
4226
|
+
options = Object.assign({
|
|
4227
|
+
title: '',
|
|
4228
|
+
mask: false
|
|
4229
|
+
}, options);
|
|
4230
|
+
const { success, fail, complete } = options;
|
|
4231
|
+
const handle = new MethodHandler({ name: 'showLoading', success, fail, complete });
|
|
4232
|
+
const config = {
|
|
4233
|
+
icon: 'loading',
|
|
4234
|
+
image: '',
|
|
4235
|
+
duration: -1
|
|
4236
|
+
};
|
|
4237
|
+
options = Object.assign({}, options, config);
|
|
4238
|
+
if (typeof options.title !== 'string') {
|
|
4239
|
+
return handle.fail({
|
|
4240
|
+
errMsg: getParameterError({
|
|
4241
|
+
para: 'title',
|
|
4242
|
+
correct: 'String',
|
|
4243
|
+
wrong: options.title
|
|
4244
|
+
})
|
|
4245
|
+
});
|
|
4246
|
+
}
|
|
4247
|
+
options.mask = !!options.mask;
|
|
4248
|
+
let errMsg = '';
|
|
4249
|
+
if (!toast.el) {
|
|
4250
|
+
errMsg = toast.create(options, 'loading');
|
|
4251
|
+
}
|
|
4252
|
+
else {
|
|
4253
|
+
errMsg = toast.show(options, 'loading');
|
|
4254
|
+
}
|
|
4255
|
+
return handle.success({ errMsg });
|
|
4256
|
+
};
|
|
4257
|
+
const hideLoading = ({ success, fail, complete } = {}) => {
|
|
4258
|
+
const handle = new MethodHandler({ name: 'hideLoading', success, fail, complete });
|
|
4259
|
+
if (!toast.el)
|
|
4260
|
+
return handle.success();
|
|
4261
|
+
toast.hide(0, 'loading');
|
|
4262
|
+
return handle.success();
|
|
4263
|
+
};
|
|
4264
|
+
const showModal = (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4265
|
+
init(document);
|
|
4266
|
+
options = Object.assign({
|
|
4267
|
+
title: '',
|
|
4268
|
+
content: '',
|
|
4269
|
+
showCancel: true,
|
|
4270
|
+
cancelText: '取消',
|
|
4271
|
+
cancelColor: '#000000',
|
|
4272
|
+
confirmText: '确定',
|
|
4273
|
+
confirmColor: '#3CC51F'
|
|
4274
|
+
}, options);
|
|
4275
|
+
const { success, fail, complete } = options;
|
|
4276
|
+
const handle = new MethodHandler({ name: 'showModal', success, fail, complete });
|
|
4277
|
+
if (typeof options.title !== 'string') {
|
|
4278
|
+
return handle.fail({
|
|
4279
|
+
errMsg: getParameterError({
|
|
4280
|
+
para: 'title',
|
|
4281
|
+
correct: 'String',
|
|
4282
|
+
wrong: options.title
|
|
4283
|
+
})
|
|
4357
4284
|
});
|
|
4358
4285
|
}
|
|
4359
|
-
|
|
4360
|
-
return
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
// title & text
|
|
4367
|
-
const { textStyle } = this.style;
|
|
4368
|
-
if (config.title) {
|
|
4369
|
-
this.title.textContent = config.title;
|
|
4370
|
-
// none => block
|
|
4371
|
-
this.title.style.display = 'block';
|
|
4372
|
-
this.text.setAttribute('style', inlineStyle(textStyle));
|
|
4373
|
-
}
|
|
4374
|
-
else {
|
|
4375
|
-
// block => none
|
|
4376
|
-
this.title.style.display = 'none';
|
|
4377
|
-
const textCSS = Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
4378
|
-
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
4379
|
-
}
|
|
4380
|
-
this.text.textContent = config.content || '';
|
|
4381
|
-
// showCancel
|
|
4382
|
-
this.cancel.style.display = config.showCancel ? 'block' : 'none';
|
|
4383
|
-
// cancelText
|
|
4384
|
-
this.cancel.textContent = config.cancelText || '';
|
|
4385
|
-
// cancelColor
|
|
4386
|
-
this.cancel.style.color = config.cancelColor || '';
|
|
4387
|
-
// confirmText
|
|
4388
|
-
this.confirm.textContent = config.confirmText || '';
|
|
4389
|
-
// confirmColor
|
|
4390
|
-
this.confirm.style.color = config.confirmColor || '';
|
|
4391
|
-
// cbs
|
|
4392
|
-
this.cancel.onclick = () => {
|
|
4393
|
-
this.hide();
|
|
4394
|
-
resolve('cancel');
|
|
4395
|
-
};
|
|
4396
|
-
this.confirm.onclick = () => {
|
|
4397
|
-
this.hide();
|
|
4398
|
-
resolve('confirm');
|
|
4399
|
-
};
|
|
4400
|
-
// show
|
|
4401
|
-
this.el.style.display = 'block';
|
|
4402
|
-
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
4286
|
+
if (typeof options.content !== 'string') {
|
|
4287
|
+
return handle.fail({
|
|
4288
|
+
errMsg: getParameterError({
|
|
4289
|
+
para: 'content',
|
|
4290
|
+
correct: 'String',
|
|
4291
|
+
wrong: options.content
|
|
4292
|
+
})
|
|
4403
4293
|
});
|
|
4404
4294
|
}
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
}, 0);
|
|
4295
|
+
if (typeof options.cancelText !== 'string') {
|
|
4296
|
+
return handle.fail({
|
|
4297
|
+
errMsg: getParameterError({
|
|
4298
|
+
para: 'cancelText',
|
|
4299
|
+
correct: 'String',
|
|
4300
|
+
wrong: options.cancelText
|
|
4301
|
+
})
|
|
4302
|
+
});
|
|
4414
4303
|
}
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
constructor() {
|
|
4420
|
-
this.options = {
|
|
4421
|
-
itemList: [],
|
|
4422
|
-
itemColor: '#000000',
|
|
4423
|
-
success: noop,
|
|
4424
|
-
fail: noop,
|
|
4425
|
-
complete: noop
|
|
4426
|
-
};
|
|
4427
|
-
this.style = {
|
|
4428
|
-
maskStyle: {
|
|
4429
|
-
position: 'fixed',
|
|
4430
|
-
'z-index': '1000',
|
|
4431
|
-
top: '0',
|
|
4432
|
-
right: '0',
|
|
4433
|
-
left: '0',
|
|
4434
|
-
bottom: '0',
|
|
4435
|
-
background: 'rgba(0,0,0,0.6)'
|
|
4436
|
-
},
|
|
4437
|
-
actionSheetStyle: {
|
|
4438
|
-
'z-index': '4999',
|
|
4439
|
-
position: 'fixed',
|
|
4440
|
-
left: '0',
|
|
4441
|
-
bottom: '0',
|
|
4442
|
-
'-webkit-transform': 'translate(0, 100%)',
|
|
4443
|
-
transform: 'translate(0, 100%)',
|
|
4444
|
-
width: '100%',
|
|
4445
|
-
'line-height': '1.6',
|
|
4446
|
-
background: '#EFEFF4',
|
|
4447
|
-
'-webkit-transition': '-webkit-transform .3s',
|
|
4448
|
-
transition: 'transform .3s'
|
|
4449
|
-
},
|
|
4450
|
-
menuStyle: {
|
|
4451
|
-
'background-color': '#FCFCFD'
|
|
4452
|
-
},
|
|
4453
|
-
cellStyle: {
|
|
4454
|
-
position: 'relative',
|
|
4455
|
-
padding: '10px 0',
|
|
4456
|
-
'text-align': 'center',
|
|
4457
|
-
'font-size': '18px'
|
|
4458
|
-
},
|
|
4459
|
-
cancelStyle: {
|
|
4460
|
-
'margin-top': '6px',
|
|
4461
|
-
padding: '10px 0',
|
|
4462
|
-
'text-align': 'center',
|
|
4463
|
-
'font-size': '18px',
|
|
4464
|
-
color: '#000000',
|
|
4465
|
-
'background-color': '#FCFCFD'
|
|
4466
|
-
}
|
|
4467
|
-
};
|
|
4468
|
-
this.lastConfig = {};
|
|
4304
|
+
if (options.cancelText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
4305
|
+
return handle.fail({
|
|
4306
|
+
errMsg: 'cancelText length should not larger then 4 Chinese characters'
|
|
4307
|
+
});
|
|
4469
4308
|
}
|
|
4470
|
-
|
|
4471
|
-
return
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4309
|
+
if (typeof options.confirmText !== 'string') {
|
|
4310
|
+
return handle.fail({
|
|
4311
|
+
errMsg: getParameterError({
|
|
4312
|
+
para: 'confirmText',
|
|
4313
|
+
correct: 'String',
|
|
4314
|
+
wrong: options.confirmText
|
|
4315
|
+
})
|
|
4316
|
+
});
|
|
4317
|
+
}
|
|
4318
|
+
if (options.confirmText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
4319
|
+
return handle.fail({
|
|
4320
|
+
errMsg: 'confirmText length should not larger then 4 Chinese characters'
|
|
4321
|
+
});
|
|
4322
|
+
}
|
|
4323
|
+
if (typeof options.cancelColor !== 'string') {
|
|
4324
|
+
return handle.fail({
|
|
4325
|
+
errMsg: getParameterError({
|
|
4326
|
+
para: 'cancelColor',
|
|
4327
|
+
correct: 'String',
|
|
4328
|
+
wrong: options.cancelColor
|
|
4329
|
+
})
|
|
4330
|
+
});
|
|
4331
|
+
}
|
|
4332
|
+
if (typeof options.confirmColor !== 'string') {
|
|
4333
|
+
return handle.fail({
|
|
4334
|
+
errMsg: getParameterError({
|
|
4335
|
+
para: 'confirmColor',
|
|
4336
|
+
correct: 'String',
|
|
4337
|
+
wrong: options.confirmColor
|
|
4338
|
+
})
|
|
4339
|
+
});
|
|
4340
|
+
}
|
|
4341
|
+
options.showCancel = !!options.showCancel;
|
|
4342
|
+
let result = '';
|
|
4343
|
+
if (!modal.el) {
|
|
4344
|
+
result = yield modal.create(options);
|
|
4345
|
+
}
|
|
4346
|
+
else {
|
|
4347
|
+
result = yield modal.show(options);
|
|
4348
|
+
}
|
|
4349
|
+
const res = { cancel: !1, confirm: !1 };
|
|
4350
|
+
res[result] = !0;
|
|
4351
|
+
return handle.success(res);
|
|
4352
|
+
});
|
|
4353
|
+
function hideModal() {
|
|
4354
|
+
if (!modal.el)
|
|
4355
|
+
return;
|
|
4356
|
+
modal.hide();
|
|
4357
|
+
}
|
|
4358
|
+
const showActionSheet = (options = { itemList: [] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4359
|
+
init(document);
|
|
4360
|
+
options = Object.assign({
|
|
4361
|
+
itemColor: '#000000',
|
|
4362
|
+
itemList: []
|
|
4363
|
+
}, options);
|
|
4364
|
+
const { success, fail, complete } = options;
|
|
4365
|
+
const handle = new MethodHandler({ name: 'showActionSheet', success, fail, complete });
|
|
4366
|
+
// list item String
|
|
4367
|
+
if (!Array.isArray(options.itemList)) {
|
|
4368
|
+
return handle.fail({
|
|
4369
|
+
errMsg: getParameterError({
|
|
4370
|
+
para: 'itemList',
|
|
4371
|
+
correct: 'Array',
|
|
4372
|
+
wrong: options.itemList
|
|
4373
|
+
})
|
|
4529
4374
|
});
|
|
4530
4375
|
}
|
|
4531
|
-
|
|
4532
|
-
return
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
let cell;
|
|
4546
|
-
if (this.cells[index]) {
|
|
4547
|
-
// assign new content
|
|
4548
|
-
cell = this.cells[index];
|
|
4549
|
-
}
|
|
4550
|
-
else {
|
|
4551
|
-
// create new cell
|
|
4552
|
-
cell = document.createElement('div');
|
|
4553
|
-
cell.className = 'taro-actionsheet__cell';
|
|
4554
|
-
cell.setAttribute('style', inlineStyle(cellStyle));
|
|
4555
|
-
cell.dataset.tapIndex = `${index}`;
|
|
4556
|
-
this.cells.push(cell);
|
|
4557
|
-
this.menu.appendChild(cell);
|
|
4558
|
-
}
|
|
4559
|
-
cell.textContent = item;
|
|
4560
|
-
cell.onclick = e => {
|
|
4561
|
-
this.hide();
|
|
4562
|
-
const target = e.currentTarget;
|
|
4563
|
-
const index = Number(target === null || target === void 0 ? void 0 : target.dataset.tapIndex) || 0;
|
|
4564
|
-
resolve(index);
|
|
4565
|
-
};
|
|
4376
|
+
if (options.itemList.length < 1) {
|
|
4377
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should have at least 1 item' });
|
|
4378
|
+
}
|
|
4379
|
+
if (options.itemList.length > 6) {
|
|
4380
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should not be large than 6' });
|
|
4381
|
+
}
|
|
4382
|
+
for (let i = 0; i < options.itemList.length; i++) {
|
|
4383
|
+
if (typeof options.itemList[i] !== 'string') {
|
|
4384
|
+
return handle.fail({
|
|
4385
|
+
errMsg: getParameterError({
|
|
4386
|
+
para: `itemList[${i}]`,
|
|
4387
|
+
correct: 'String',
|
|
4388
|
+
wrong: options.itemList[i]
|
|
4389
|
+
})
|
|
4566
4390
|
});
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
this.el.style.display = 'block';
|
|
4577
|
-
setTimeout(() => {
|
|
4578
|
-
this.el.style.opacity = '1';
|
|
4579
|
-
setTransform(this.actionSheet, 'translate(0, 0)');
|
|
4580
|
-
}, 0);
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
if (typeof options.itemColor !== 'string') {
|
|
4394
|
+
return handle.fail({
|
|
4395
|
+
errMsg: getParameterError({
|
|
4396
|
+
para: 'itemColor',
|
|
4397
|
+
correct: 'String',
|
|
4398
|
+
wrong: options.itemColor
|
|
4399
|
+
})
|
|
4581
4400
|
});
|
|
4582
4401
|
}
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4402
|
+
let result = '';
|
|
4403
|
+
if (!actionSheet.el) {
|
|
4404
|
+
result = yield actionSheet.create(options);
|
|
4405
|
+
}
|
|
4406
|
+
else {
|
|
4407
|
+
result = yield actionSheet.show(options);
|
|
4408
|
+
}
|
|
4409
|
+
if (typeof result === 'string') {
|
|
4410
|
+
return handle.fail(({ errMsg: result }));
|
|
4411
|
+
}
|
|
4412
|
+
else {
|
|
4413
|
+
return handle.success(({ tapIndex: result }));
|
|
4414
|
+
}
|
|
4415
|
+
});
|
|
4416
|
+
Taro__default["default"].eventCenter.on('__taroRouterChange', () => {
|
|
4417
|
+
hideToast();
|
|
4418
|
+
hideLoading();
|
|
4419
|
+
hideModal();
|
|
4420
|
+
});
|
|
4421
|
+
const enableAlertBeforeUnload = temporarilyNotSupport('enableAlertBeforeUnload');
|
|
4422
|
+
const disableAlertBeforeUnload = temporarilyNotSupport('disableAlertBeforeUnload');
|
|
4423
|
+
|
|
4424
|
+
// 菜单
|
|
4425
|
+
const getMenuButtonBoundingClientRect = temporarilyNotSupport('getMenuButtonBoundingClientRect');
|
|
4426
|
+
|
|
4427
|
+
// 导航栏
|
|
4428
|
+
const showNavigationBarLoading = temporarilyNotSupport('showNavigationBarLoading');
|
|
4429
|
+
function setNavigationBarTitle(options) {
|
|
4430
|
+
// options must be an Object
|
|
4431
|
+
const isObject = shouldBeObject(options);
|
|
4432
|
+
if (!isObject.flag) {
|
|
4433
|
+
const res = { errMsg: `setNavigationBarTitle:fail ${isObject.msg}` };
|
|
4434
|
+
console.error(res.errMsg);
|
|
4435
|
+
return Promise.reject(res);
|
|
4436
|
+
}
|
|
4437
|
+
const { title, success, fail, complete } = options;
|
|
4438
|
+
const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete });
|
|
4439
|
+
if (!title || typeof title !== 'string') {
|
|
4440
|
+
return handle.fail({
|
|
4441
|
+
errMsg: getParameterError({
|
|
4442
|
+
para: 'title',
|
|
4443
|
+
correct: 'String',
|
|
4444
|
+
wrong: title
|
|
4445
|
+
})
|
|
4446
|
+
});
|
|
4593
4447
|
}
|
|
4448
|
+
if (document.title !== title) {
|
|
4449
|
+
document.title = title;
|
|
4450
|
+
}
|
|
4451
|
+
return handle.success();
|
|
4594
4452
|
}
|
|
4453
|
+
/**
|
|
4454
|
+
* 设置页面导航条颜色
|
|
4455
|
+
*/
|
|
4456
|
+
const setNavigationBarColor = (options) => {
|
|
4457
|
+
const { backgroundColor, success, fail, complete } = options;
|
|
4458
|
+
const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete });
|
|
4459
|
+
const meta = document.createElement('meta');
|
|
4460
|
+
meta.setAttribute('name', 'theme-color');
|
|
4461
|
+
meta.setAttribute('content', backgroundColor);
|
|
4462
|
+
document.head.appendChild(meta);
|
|
4463
|
+
return handle.success();
|
|
4464
|
+
};
|
|
4465
|
+
const hideNavigationBarLoading = temporarilyNotSupport('hideNavigationBarLoading');
|
|
4466
|
+
const hideHomeButton = temporarilyNotSupport('hideHomeButton');
|
|
4467
|
+
|
|
4468
|
+
/**
|
|
4469
|
+
* 开始下拉刷新。调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
|
|
4470
|
+
*/
|
|
4471
|
+
const startPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
4472
|
+
const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
|
|
4473
|
+
return new Promise((resolve, reject) => {
|
|
4474
|
+
Taro__default["default"].eventCenter.trigger('__taroStartPullDownRefresh', {
|
|
4475
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4476
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4477
|
+
});
|
|
4478
|
+
});
|
|
4479
|
+
};
|
|
4480
|
+
/**
|
|
4481
|
+
* 停止当前页面下拉刷新。
|
|
4482
|
+
*/
|
|
4483
|
+
const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
4484
|
+
const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
|
|
4485
|
+
return new Promise((resolve, reject) => {
|
|
4486
|
+
Taro__default["default"].eventCenter.trigger('__taroStopPullDownRefresh', {
|
|
4487
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4488
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4489
|
+
});
|
|
4490
|
+
});
|
|
4491
|
+
};
|
|
4492
|
+
|
|
4493
|
+
let timer;
|
|
4494
|
+
const FRAME_DURATION = 17;
|
|
4495
|
+
/**
|
|
4496
|
+
* 将页面滚动到目标位置
|
|
4497
|
+
*/
|
|
4498
|
+
const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success, fail, complete }) => {
|
|
4499
|
+
let scrollFunc;
|
|
4500
|
+
const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete });
|
|
4501
|
+
return new Promise((resolve, reject) => {
|
|
4502
|
+
var _a, _b;
|
|
4503
|
+
try {
|
|
4504
|
+
if (scrollTop === undefined && !selector) {
|
|
4505
|
+
return handle.fail({
|
|
4506
|
+
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
4507
|
+
}, reject);
|
|
4508
|
+
}
|
|
4509
|
+
const id = (_b = (_a = runtime.Current.page) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(/([^a-z0-9\u00a0-\uffff_-])/ig, '\\$1');
|
|
4510
|
+
const el = (id
|
|
4511
|
+
? document.querySelector(`.taro_page#${id}`)
|
|
4512
|
+
: document.querySelector('.taro_page') ||
|
|
4513
|
+
document.querySelector('.taro_router'));
|
|
4514
|
+
if (!scrollFunc) {
|
|
4515
|
+
if (!el) {
|
|
4516
|
+
scrollFunc = pos => {
|
|
4517
|
+
if (pos === undefined) {
|
|
4518
|
+
return window.pageYOffset;
|
|
4519
|
+
}
|
|
4520
|
+
else {
|
|
4521
|
+
window.scrollTo(0, pos);
|
|
4522
|
+
}
|
|
4523
|
+
};
|
|
4524
|
+
}
|
|
4525
|
+
else {
|
|
4526
|
+
scrollFunc = pos => {
|
|
4527
|
+
if (pos === undefined) {
|
|
4528
|
+
return el.scrollTop;
|
|
4529
|
+
}
|
|
4530
|
+
else {
|
|
4531
|
+
el.scrollTop = pos;
|
|
4532
|
+
}
|
|
4533
|
+
};
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4536
|
+
if (scrollTop && selector) {
|
|
4537
|
+
console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector');
|
|
4538
|
+
}
|
|
4539
|
+
const from = scrollFunc();
|
|
4540
|
+
let to;
|
|
4541
|
+
if (typeof scrollTop === 'number') {
|
|
4542
|
+
to = scrollTop;
|
|
4543
|
+
}
|
|
4544
|
+
else {
|
|
4545
|
+
const el = document.querySelector(selector);
|
|
4546
|
+
to = (el === null || el === void 0 ? void 0 : el.offsetTop) || 0;
|
|
4547
|
+
}
|
|
4548
|
+
const delta = to - from;
|
|
4549
|
+
const frameCnt = duration / FRAME_DURATION;
|
|
4550
|
+
const easeFunc = getTimingFunc(easeInOut, frameCnt);
|
|
4551
|
+
const scroll = (frame = 0) => {
|
|
4552
|
+
const dest = from + delta * easeFunc(frame);
|
|
4553
|
+
scrollFunc(dest);
|
|
4554
|
+
if (frame < frameCnt) {
|
|
4555
|
+
timer && clearTimeout(timer);
|
|
4556
|
+
timer = setTimeout(() => {
|
|
4557
|
+
scroll(frame + 1);
|
|
4558
|
+
}, FRAME_DURATION);
|
|
4559
|
+
}
|
|
4560
|
+
else {
|
|
4561
|
+
return handle.success({}, resolve);
|
|
4562
|
+
}
|
|
4563
|
+
};
|
|
4564
|
+
scroll();
|
|
4565
|
+
}
|
|
4566
|
+
catch (e) {
|
|
4567
|
+
return handle.fail({
|
|
4568
|
+
errMsg: e.message
|
|
4569
|
+
}, reject);
|
|
4570
|
+
}
|
|
4571
|
+
});
|
|
4572
|
+
};
|
|
4595
4573
|
|
|
4596
|
-
//
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
const taroStyle = doc.createElement('style');
|
|
4603
|
-
taroStyle.textContent = '@font-face{font-weight:normal;font-style:normal;font-family:"taro";src:url("data:application/x-font-ttf;charset=utf-8;base64, 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") format("truetype");}@-webkit-keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}@keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}.taro-modal__foot:after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);} .taro-model__btn:active {background-color: #EEEEEE}.taro-model__btn:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;width: 1px;bottom: 0;border-left: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleX(0.5);transform: scaleX(0.5);}.taro-actionsheet__cell:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #e5e5e5;color: #e5e5e5;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);}';
|
|
4604
|
-
doc.querySelector('head').appendChild(taroStyle);
|
|
4605
|
-
status = 'ready';
|
|
4574
|
+
// 置顶
|
|
4575
|
+
const setTopBarText = temporarilyNotSupport('setTopBarText');
|
|
4576
|
+
|
|
4577
|
+
let tabConf;
|
|
4578
|
+
function initTabBarApis(config = {}) {
|
|
4579
|
+
tabConf = config.tabBar;
|
|
4606
4580
|
}
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
const
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
mask: false
|
|
4618
|
-
}, options);
|
|
4619
|
-
const { success, fail, complete } = options;
|
|
4620
|
-
const handle = new MethodHandler({ name: 'showToast', success, fail, complete });
|
|
4621
|
-
if (typeof options.title !== 'string') {
|
|
4622
|
-
return handle.fail({
|
|
4623
|
-
errMsg: getParameterError({
|
|
4624
|
-
para: 'title',
|
|
4625
|
-
correct: 'String',
|
|
4626
|
-
wrong: options.title
|
|
4627
|
-
})
|
|
4628
|
-
});
|
|
4581
|
+
/**
|
|
4582
|
+
* 显示 tabBar 某一项的右上角的红点
|
|
4583
|
+
*/
|
|
4584
|
+
const showTabBarRedDot = (options) => {
|
|
4585
|
+
// options must be an Object
|
|
4586
|
+
const isObject = shouldBeObject(options);
|
|
4587
|
+
if (!isObject.flag) {
|
|
4588
|
+
const res = { errMsg: `showTabBarRedDot:fail ${isObject.msg}` };
|
|
4589
|
+
console.error(res.errMsg);
|
|
4590
|
+
return Promise.reject(res);
|
|
4629
4591
|
}
|
|
4630
|
-
|
|
4592
|
+
const { index, success, fail, complete } = options;
|
|
4593
|
+
const handle = new MethodHandler({ name: 'showTabBarRedDot', success, fail, complete });
|
|
4594
|
+
if (typeof index !== 'number') {
|
|
4631
4595
|
return handle.fail({
|
|
4632
4596
|
errMsg: getParameterError({
|
|
4633
|
-
para: '
|
|
4597
|
+
para: 'index',
|
|
4634
4598
|
correct: 'Number',
|
|
4635
|
-
wrong:
|
|
4599
|
+
wrong: index
|
|
4636
4600
|
})
|
|
4637
4601
|
});
|
|
4638
4602
|
}
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
}
|
|
4646
|
-
else {
|
|
4647
|
-
errMsg = toast.show(options, 'toast');
|
|
4648
|
-
}
|
|
4649
|
-
return handle.success({ errMsg });
|
|
4650
|
-
};
|
|
4651
|
-
const hideToast = ({ success, fail, complete } = {}) => {
|
|
4652
|
-
const handle = new MethodHandler({ name: 'hideToast', success, fail, complete });
|
|
4653
|
-
if (!toast.el)
|
|
4654
|
-
return handle.success();
|
|
4655
|
-
toast.hide(0, 'toast');
|
|
4656
|
-
return handle.success();
|
|
4603
|
+
return new Promise((resolve, reject) => {
|
|
4604
|
+
Taro__default["default"].eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
4605
|
+
index,
|
|
4606
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4607
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4608
|
+
});
|
|
4609
|
+
});
|
|
4657
4610
|
};
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
};
|
|
4671
|
-
options
|
|
4672
|
-
if (typeof options.title !== 'string') {
|
|
4611
|
+
/**
|
|
4612
|
+
* 显示 tabBar
|
|
4613
|
+
*/
|
|
4614
|
+
const showTabBar = (options = {}) => {
|
|
4615
|
+
// options must be an Object
|
|
4616
|
+
const isObject = shouldBeObject(options);
|
|
4617
|
+
if (!isObject.flag) {
|
|
4618
|
+
const res = { errMsg: `showTabBar:fail ${isObject.msg}` };
|
|
4619
|
+
console.error(res.errMsg);
|
|
4620
|
+
return Promise.reject(res);
|
|
4621
|
+
}
|
|
4622
|
+
const { animation, success, fail, complete } = options;
|
|
4623
|
+
const handle = new MethodHandler({ name: 'showTabBar', success, fail, complete });
|
|
4624
|
+
if (options.hasOwnProperty('animation') && typeof animation !== 'boolean') {
|
|
4673
4625
|
return handle.fail({
|
|
4674
4626
|
errMsg: getParameterError({
|
|
4675
|
-
para: '
|
|
4676
|
-
correct: '
|
|
4677
|
-
wrong:
|
|
4627
|
+
para: 'animation',
|
|
4628
|
+
correct: 'Boolean',
|
|
4629
|
+
wrong: animation
|
|
4678
4630
|
})
|
|
4679
4631
|
});
|
|
4680
4632
|
}
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4633
|
+
return new Promise((resolve, reject) => {
|
|
4634
|
+
Taro__default["default"].eventCenter.trigger('__taroShowTabBar', {
|
|
4635
|
+
animation,
|
|
4636
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4637
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4638
|
+
});
|
|
4639
|
+
});
|
|
4640
|
+
};
|
|
4641
|
+
/**
|
|
4642
|
+
* 动态设置 tabBar 的整体样式
|
|
4643
|
+
*/
|
|
4644
|
+
const setTabBarStyle = (options = {}) => {
|
|
4645
|
+
// options must be an Object
|
|
4646
|
+
const isObject = shouldBeObject(options);
|
|
4647
|
+
if (!isObject.flag) {
|
|
4648
|
+
const res = { errMsg: `setTabBarStyle:fail ${isObject.msg}` };
|
|
4649
|
+
console.error(res.errMsg);
|
|
4650
|
+
return Promise.reject(res);
|
|
4685
4651
|
}
|
|
4686
|
-
|
|
4687
|
-
|
|
4652
|
+
const { color, selectedColor, backgroundColor, borderStyle, success, fail, complete } = options;
|
|
4653
|
+
const handle = new MethodHandler({ name: 'setTabBarStyle', success, fail, complete });
|
|
4654
|
+
let errMsg;
|
|
4655
|
+
if (color && !isValidColor(color)) {
|
|
4656
|
+
errMsg = 'color';
|
|
4688
4657
|
}
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4658
|
+
else if (selectedColor && !isValidColor(selectedColor)) {
|
|
4659
|
+
errMsg = 'selectedColor';
|
|
4660
|
+
}
|
|
4661
|
+
else if (backgroundColor && !isValidColor(backgroundColor)) {
|
|
4662
|
+
errMsg = 'backgroundColor';
|
|
4663
|
+
}
|
|
4664
|
+
else if (borderStyle && !/^(black|white)$/.test(borderStyle)) {
|
|
4665
|
+
errMsg = 'borderStyle';
|
|
4666
|
+
}
|
|
4667
|
+
if (errMsg) {
|
|
4668
|
+
return handle.fail({ errMsg: `invalid ${errMsg}` });
|
|
4669
|
+
}
|
|
4670
|
+
if (!tabConf) {
|
|
4671
|
+
return handle.fail();
|
|
4672
|
+
}
|
|
4673
|
+
const obj = {};
|
|
4674
|
+
if (color)
|
|
4675
|
+
obj.color = color;
|
|
4676
|
+
if (selectedColor)
|
|
4677
|
+
obj.selectedColor = selectedColor;
|
|
4678
|
+
if (backgroundColor)
|
|
4679
|
+
obj.backgroundColor = backgroundColor;
|
|
4680
|
+
if (borderStyle)
|
|
4681
|
+
obj.borderStyle = borderStyle;
|
|
4682
|
+
return new Promise((resolve, reject) => {
|
|
4683
|
+
Taro__default["default"].eventCenter.trigger('__taroSetTabBarStyle', {
|
|
4684
|
+
color,
|
|
4685
|
+
selectedColor,
|
|
4686
|
+
backgroundColor,
|
|
4687
|
+
borderStyle,
|
|
4688
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4689
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4690
|
+
});
|
|
4691
|
+
});
|
|
4697
4692
|
};
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
}
|
|
4709
|
-
const { success, fail, complete } = options;
|
|
4710
|
-
const handle = new MethodHandler({ name: '
|
|
4711
|
-
if (typeof
|
|
4693
|
+
/**
|
|
4694
|
+
* 动态设置 tabBar 某一项的内容
|
|
4695
|
+
*/
|
|
4696
|
+
const setTabBarItem = (options) => {
|
|
4697
|
+
// options must be an Object
|
|
4698
|
+
const isObject = shouldBeObject(options);
|
|
4699
|
+
if (!isObject.flag) {
|
|
4700
|
+
const res = { errMsg: `setTabBarItem:fail ${isObject.msg}` };
|
|
4701
|
+
console.error(res.errMsg);
|
|
4702
|
+
return Promise.reject(res);
|
|
4703
|
+
}
|
|
4704
|
+
const { index, text, iconPath, selectedIconPath, success, fail, complete } = options;
|
|
4705
|
+
const handle = new MethodHandler({ name: 'setTabBarItem', success, fail, complete });
|
|
4706
|
+
if (typeof index !== 'number') {
|
|
4712
4707
|
return handle.fail({
|
|
4713
4708
|
errMsg: getParameterError({
|
|
4714
|
-
para: '
|
|
4715
|
-
correct: '
|
|
4716
|
-
wrong:
|
|
4709
|
+
para: 'index',
|
|
4710
|
+
correct: 'Number',
|
|
4711
|
+
wrong: index
|
|
4717
4712
|
})
|
|
4718
4713
|
});
|
|
4719
4714
|
}
|
|
4720
|
-
|
|
4715
|
+
return new Promise((resolve, reject) => {
|
|
4716
|
+
Taro__default["default"].eventCenter.trigger('__taroSetTabBarItem', {
|
|
4717
|
+
index,
|
|
4718
|
+
text,
|
|
4719
|
+
iconPath,
|
|
4720
|
+
selectedIconPath,
|
|
4721
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4722
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4723
|
+
});
|
|
4724
|
+
});
|
|
4725
|
+
};
|
|
4726
|
+
/**
|
|
4727
|
+
* 为 tabBar 某一项的右上角添加文本
|
|
4728
|
+
*/
|
|
4729
|
+
const setTabBarBadge = (options) => {
|
|
4730
|
+
// options must be an Object
|
|
4731
|
+
const isObject = shouldBeObject(options);
|
|
4732
|
+
if (!isObject.flag) {
|
|
4733
|
+
const res = { errMsg: `setTabBarBadge:fail ${isObject.msg}` };
|
|
4734
|
+
console.error(res.errMsg);
|
|
4735
|
+
return Promise.reject(res);
|
|
4736
|
+
}
|
|
4737
|
+
const { index, text, success, fail, complete } = options;
|
|
4738
|
+
const handle = new MethodHandler({ name: 'setTabBarBadge', success, fail, complete });
|
|
4739
|
+
if (typeof index !== 'number') {
|
|
4721
4740
|
return handle.fail({
|
|
4722
4741
|
errMsg: getParameterError({
|
|
4723
|
-
para: '
|
|
4724
|
-
correct: '
|
|
4725
|
-
wrong:
|
|
4742
|
+
para: 'index',
|
|
4743
|
+
correct: 'Number',
|
|
4744
|
+
wrong: index
|
|
4726
4745
|
})
|
|
4727
4746
|
});
|
|
4728
4747
|
}
|
|
4729
|
-
if (typeof
|
|
4748
|
+
if (typeof text !== 'string') {
|
|
4730
4749
|
return handle.fail({
|
|
4731
4750
|
errMsg: getParameterError({
|
|
4732
|
-
para: '
|
|
4751
|
+
para: 'text',
|
|
4733
4752
|
correct: 'String',
|
|
4734
|
-
wrong:
|
|
4753
|
+
wrong: text
|
|
4735
4754
|
})
|
|
4736
4755
|
});
|
|
4737
4756
|
}
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4757
|
+
return new Promise((resolve, reject) => {
|
|
4758
|
+
Taro__default["default"].eventCenter.trigger('__taroSetTabBarBadge', {
|
|
4759
|
+
index,
|
|
4760
|
+
text,
|
|
4761
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4762
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4741
4763
|
});
|
|
4764
|
+
});
|
|
4765
|
+
};
|
|
4766
|
+
/**
|
|
4767
|
+
* 移除 tabBar 某一项右上角的文本
|
|
4768
|
+
*/
|
|
4769
|
+
const removeTabBarBadge = (options) => {
|
|
4770
|
+
// options must be an Object
|
|
4771
|
+
const isObject = shouldBeObject(options);
|
|
4772
|
+
if (!isObject.flag) {
|
|
4773
|
+
const res = { errMsg: `removeTabBarBadge:fail ${isObject.msg}` };
|
|
4774
|
+
console.error(res.errMsg);
|
|
4775
|
+
return Promise.reject(res);
|
|
4742
4776
|
}
|
|
4743
|
-
|
|
4777
|
+
const { index, success, fail, complete } = options;
|
|
4778
|
+
const handle = new MethodHandler({ name: 'removeTabBarBadge', success, fail, complete });
|
|
4779
|
+
if (typeof index !== 'number') {
|
|
4744
4780
|
return handle.fail({
|
|
4745
4781
|
errMsg: getParameterError({
|
|
4746
|
-
para: '
|
|
4747
|
-
correct: '
|
|
4748
|
-
wrong:
|
|
4782
|
+
para: 'index',
|
|
4783
|
+
correct: 'Number',
|
|
4784
|
+
wrong: index
|
|
4749
4785
|
})
|
|
4750
4786
|
});
|
|
4751
4787
|
}
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4788
|
+
return new Promise((resolve, reject) => {
|
|
4789
|
+
Taro__default["default"].eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
4790
|
+
index,
|
|
4791
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4792
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4755
4793
|
});
|
|
4794
|
+
});
|
|
4795
|
+
};
|
|
4796
|
+
/**
|
|
4797
|
+
* 隐藏 tabBar 某一项的右上角的红点
|
|
4798
|
+
*/
|
|
4799
|
+
const hideTabBarRedDot = (options) => {
|
|
4800
|
+
// options must be an Object
|
|
4801
|
+
const isObject = shouldBeObject(options);
|
|
4802
|
+
if (!isObject.flag) {
|
|
4803
|
+
const res = { errMsg: `hideTabBarRedDot:fail ${isObject.msg}` };
|
|
4804
|
+
console.error(res.errMsg);
|
|
4805
|
+
return Promise.reject(res);
|
|
4756
4806
|
}
|
|
4757
|
-
|
|
4807
|
+
const { index, success, fail, complete } = options;
|
|
4808
|
+
const handle = new MethodHandler({ name: 'hideTabBarRedDot', success, fail, complete });
|
|
4809
|
+
if (typeof index !== 'number') {
|
|
4758
4810
|
return handle.fail({
|
|
4759
4811
|
errMsg: getParameterError({
|
|
4760
|
-
para: '
|
|
4761
|
-
correct: '
|
|
4762
|
-
wrong:
|
|
4812
|
+
para: 'index',
|
|
4813
|
+
correct: 'Number',
|
|
4814
|
+
wrong: index
|
|
4763
4815
|
})
|
|
4764
4816
|
});
|
|
4765
4817
|
}
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
wrong: options.confirmColor
|
|
4772
|
-
})
|
|
4818
|
+
return new Promise((resolve, reject) => {
|
|
4819
|
+
Taro__default["default"].eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
4820
|
+
index,
|
|
4821
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4822
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4773
4823
|
});
|
|
4824
|
+
});
|
|
4825
|
+
};
|
|
4826
|
+
/**
|
|
4827
|
+
* 隐藏 tabBar
|
|
4828
|
+
*/
|
|
4829
|
+
const hideTabBar = (options = {}) => {
|
|
4830
|
+
// options must be an Object
|
|
4831
|
+
const isObject = shouldBeObject(options);
|
|
4832
|
+
if (!isObject.flag) {
|
|
4833
|
+
const res = { errMsg: `hideTabBar:fail ${isObject.msg}` };
|
|
4834
|
+
console.error(res.errMsg);
|
|
4835
|
+
return Promise.reject(res);
|
|
4774
4836
|
}
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
if (
|
|
4778
|
-
result = yield modal.create(options);
|
|
4779
|
-
}
|
|
4780
|
-
else {
|
|
4781
|
-
result = yield modal.show(options);
|
|
4782
|
-
}
|
|
4783
|
-
const res = { cancel: !1, confirm: !1 };
|
|
4784
|
-
res[result] = !0;
|
|
4785
|
-
return handle.success(res);
|
|
4786
|
-
});
|
|
4787
|
-
function hideModal() {
|
|
4788
|
-
if (!modal.el)
|
|
4789
|
-
return;
|
|
4790
|
-
modal.hide();
|
|
4791
|
-
}
|
|
4792
|
-
const showActionSheet = (options = { itemList: [] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4793
|
-
init(document);
|
|
4794
|
-
options = Object.assign({
|
|
4795
|
-
itemColor: '#000000',
|
|
4796
|
-
itemList: []
|
|
4797
|
-
}, options);
|
|
4798
|
-
const { success, fail, complete } = options;
|
|
4799
|
-
const handle = new MethodHandler({ name: 'showActionSheet', success, fail, complete });
|
|
4800
|
-
// list item String
|
|
4801
|
-
if (!Array.isArray(options.itemList)) {
|
|
4837
|
+
const { animation, success, fail, complete } = options;
|
|
4838
|
+
const handle = new MethodHandler({ name: 'hideTabBar', success, fail, complete });
|
|
4839
|
+
if (options.hasOwnProperty('animation') && typeof animation !== 'boolean') {
|
|
4802
4840
|
return handle.fail({
|
|
4803
4841
|
errMsg: getParameterError({
|
|
4804
|
-
para: '
|
|
4805
|
-
correct: '
|
|
4806
|
-
wrong:
|
|
4842
|
+
para: 'animation',
|
|
4843
|
+
correct: 'Boolean',
|
|
4844
|
+
wrong: animation
|
|
4807
4845
|
})
|
|
4808
4846
|
});
|
|
4809
4847
|
}
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
}
|
|
4816
|
-
for (let i = 0; i < options.itemList.length; i++) {
|
|
4817
|
-
if (typeof options.itemList[i] !== 'string') {
|
|
4818
|
-
return handle.fail({
|
|
4819
|
-
errMsg: getParameterError({
|
|
4820
|
-
para: `itemList[${i}]`,
|
|
4821
|
-
correct: 'String',
|
|
4822
|
-
wrong: options.itemList[i]
|
|
4823
|
-
})
|
|
4824
|
-
});
|
|
4825
|
-
}
|
|
4826
|
-
}
|
|
4827
|
-
if (typeof options.itemColor !== 'string') {
|
|
4828
|
-
return handle.fail({
|
|
4829
|
-
errMsg: getParameterError({
|
|
4830
|
-
para: 'itemColor',
|
|
4831
|
-
correct: 'String',
|
|
4832
|
-
wrong: options.itemColor
|
|
4833
|
-
})
|
|
4848
|
+
return new Promise((resolve, reject) => {
|
|
4849
|
+
Taro__default["default"].eventCenter.trigger('__taroHideTabBar', {
|
|
4850
|
+
animation,
|
|
4851
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4852
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4834
4853
|
});
|
|
4854
|
+
});
|
|
4855
|
+
};
|
|
4856
|
+
|
|
4857
|
+
const callbackManager = new CallbackManager();
|
|
4858
|
+
const resizeListener = () => {
|
|
4859
|
+
callbackManager.trigger({
|
|
4860
|
+
windowWidth: window.screen.width,
|
|
4861
|
+
windowHeight: window.screen.height
|
|
4862
|
+
});
|
|
4863
|
+
};
|
|
4864
|
+
/**
|
|
4865
|
+
* 设置窗口大小,该接口仅适用于 PC 平台,使用细则请参见指南
|
|
4866
|
+
*/
|
|
4867
|
+
const setWindowSize = temporarilyNotSupport('setWindowSize');
|
|
4868
|
+
/**
|
|
4869
|
+
* 监听窗口尺寸变化事件
|
|
4870
|
+
*/
|
|
4871
|
+
const onWindowResize = callback => {
|
|
4872
|
+
callbackManager.add(callback);
|
|
4873
|
+
if (callbackManager.count() === 1) {
|
|
4874
|
+
window.addEventListener('resize', resizeListener);
|
|
4835
4875
|
}
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
return handle.fail(({ errMsg: result }));
|
|
4845
|
-
}
|
|
4846
|
-
else {
|
|
4847
|
-
return handle.success(({ tapIndex: result }));
|
|
4876
|
+
};
|
|
4877
|
+
/**
|
|
4878
|
+
* 取消监听窗口尺寸变化事件
|
|
4879
|
+
*/
|
|
4880
|
+
const offWindowResize = callback => {
|
|
4881
|
+
callbackManager.remove(callback);
|
|
4882
|
+
if (callbackManager.count() === 0) {
|
|
4883
|
+
window.removeEventListener('resize', resizeListener);
|
|
4848
4884
|
}
|
|
4849
|
-
}
|
|
4850
|
-
Taro__default["default"].eventCenter.on('__taroRouterChange', () => {
|
|
4851
|
-
hideToast();
|
|
4852
|
-
hideLoading();
|
|
4853
|
-
hideModal();
|
|
4854
|
-
});
|
|
4855
|
-
const enableAlertBeforeUnload = temporarilyNotSupport('enableAlertBeforeUnload');
|
|
4856
|
-
const disableAlertBeforeUnload = temporarilyNotSupport('disableAlertBeforeUnload');
|
|
4885
|
+
};
|
|
4857
4886
|
|
|
4858
4887
|
// Worker
|
|
4859
4888
|
const createWorker = temporarilyNotSupport('createWorker');
|
|
@@ -5105,35 +5134,6 @@ const createSelectorQuery = () => {
|
|
|
5105
5134
|
};
|
|
5106
5135
|
const createIntersectionObserver = temporarilyNotSupport('createIntersectionObserver');
|
|
5107
5136
|
|
|
5108
|
-
// AliPay
|
|
5109
|
-
const getOpenUserInfo = temporarilyNotSupport('getOpenUserInfo');
|
|
5110
|
-
|
|
5111
|
-
const setPageInfo = temporarilyNotSupport('setPageInfo');
|
|
5112
|
-
// 百度小程序 AI 相关
|
|
5113
|
-
const ocrIdCard = temporarilyNotSupport('ocrIdCard');
|
|
5114
|
-
const ocrBankCard = temporarilyNotSupport('ocrBankCard');
|
|
5115
|
-
const ocrDrivingLicense = temporarilyNotSupport('ocrDrivingLicense');
|
|
5116
|
-
const ocrVehicleLicense = temporarilyNotSupport('ocrVehicleLicense');
|
|
5117
|
-
const textReview = temporarilyNotSupport('textReview');
|
|
5118
|
-
const textToAudio = temporarilyNotSupport('textToAudio');
|
|
5119
|
-
const imageAudit = temporarilyNotSupport('imageAudit');
|
|
5120
|
-
const advancedGeneralIdentify = temporarilyNotSupport('advancedGeneralIdentify');
|
|
5121
|
-
const objectDetectIdentify = temporarilyNotSupport('objectDetectIdentify');
|
|
5122
|
-
const carClassify = temporarilyNotSupport('carClassify');
|
|
5123
|
-
const dishClassify = temporarilyNotSupport('dishClassify');
|
|
5124
|
-
const logoClassify = temporarilyNotSupport('logoClassify');
|
|
5125
|
-
const animalClassify = temporarilyNotSupport('animalClassify');
|
|
5126
|
-
const plantClassify = temporarilyNotSupport('plantClassify');
|
|
5127
|
-
// 用户信息
|
|
5128
|
-
const getSwanId = temporarilyNotSupport('getSwanId');
|
|
5129
|
-
// 百度收银台支付
|
|
5130
|
-
const requestPolymerPayment = temporarilyNotSupport('requestPolymerPayment');
|
|
5131
|
-
// 打开小程序
|
|
5132
|
-
const navigateToSmartGameProgram = temporarilyNotSupport('navigateToSmartGameProgram');
|
|
5133
|
-
const navigateToSmartProgram = temporarilyNotSupport('navigateToSmartProgram');
|
|
5134
|
-
const navigateBackSmartProgram = temporarilyNotSupport('navigateBackSmartProgram');
|
|
5135
|
-
const preloadSubPackage = temporarilyNotSupport('preloadSubPackage');
|
|
5136
|
-
|
|
5137
5137
|
const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload } = Taro__default["default"];
|
|
5138
5138
|
const taro = {
|
|
5139
5139
|
// @ts-ignore
|