@tarojs/taro-h5 3.5.0-alpha.7 → 3.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/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/download.js +1 -0
- package/dist/api/network/request/index.js +1 -1
- package/dist/api/network/upload.js +1 -0
- package/dist/api/network/utils.js +1 -0
- 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 +1092 -1089
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1092 -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 +2 -0
- package/src/api/network/request/index.ts +2 -1
- package/src/api/network/upload.ts +2 -0
- package/src/api/network/utils.ts +1 -0
- 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
|
*/
|
|
@@ -2600,6 +2603,7 @@ const convertObjectUrlToBlob = url => {
|
|
|
2600
2603
|
const xhr = new XMLHttpRequest();
|
|
2601
2604
|
xhr.open('GET', url, true);
|
|
2602
2605
|
xhr.responseType = 'blob';
|
|
2606
|
+
xhr.withCredentials = true;
|
|
2603
2607
|
xhr.onload = function () {
|
|
2604
2608
|
if (this.status === 200) {
|
|
2605
2609
|
resolve(this.response);
|
|
@@ -2622,6 +2626,7 @@ const createDownloadTask = ({ url, header, success, error }) => {
|
|
|
2622
2626
|
progressUpdate: new CallbackManager()
|
|
2623
2627
|
};
|
|
2624
2628
|
xhr.open('GET', url, true);
|
|
2629
|
+
xhr.withCredentials = true;
|
|
2625
2630
|
xhr.responseType = 'blob';
|
|
2626
2631
|
setHeader(xhr, header);
|
|
2627
2632
|
xhr.onprogress = e => {
|
|
@@ -2891,6 +2896,7 @@ const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout,
|
|
|
2891
2896
|
progressUpdate: new CallbackManager()
|
|
2892
2897
|
};
|
|
2893
2898
|
xhr.open('POST', url);
|
|
2899
|
+
xhr.withCredentials = true;
|
|
2894
2900
|
setHeader(xhr, header);
|
|
2895
2901
|
for (formKey in formData) {
|
|
2896
2902
|
form.append(formKey, formData[formKey]);
|
|
@@ -3249,6 +3255,32 @@ const hideShareMenu = temporarilyNotSupport('hideShareMenu');
|
|
|
3249
3255
|
const getShareInfo = temporarilyNotSupport('getShareInfo');
|
|
3250
3256
|
const authPrivateMessage = temporarilyNotSupport('authPrivateMessage');
|
|
3251
3257
|
|
|
3258
|
+
const setPageInfo = temporarilyNotSupport('setPageInfo');
|
|
3259
|
+
// 百度小程序 AI 相关
|
|
3260
|
+
const ocrIdCard = temporarilyNotSupport('ocrIdCard');
|
|
3261
|
+
const ocrBankCard = temporarilyNotSupport('ocrBankCard');
|
|
3262
|
+
const ocrDrivingLicense = temporarilyNotSupport('ocrDrivingLicense');
|
|
3263
|
+
const ocrVehicleLicense = temporarilyNotSupport('ocrVehicleLicense');
|
|
3264
|
+
const textReview = temporarilyNotSupport('textReview');
|
|
3265
|
+
const textToAudio = temporarilyNotSupport('textToAudio');
|
|
3266
|
+
const imageAudit = temporarilyNotSupport('imageAudit');
|
|
3267
|
+
const advancedGeneralIdentify = temporarilyNotSupport('advancedGeneralIdentify');
|
|
3268
|
+
const objectDetectIdentify = temporarilyNotSupport('objectDetectIdentify');
|
|
3269
|
+
const carClassify = temporarilyNotSupport('carClassify');
|
|
3270
|
+
const dishClassify = temporarilyNotSupport('dishClassify');
|
|
3271
|
+
const logoClassify = temporarilyNotSupport('logoClassify');
|
|
3272
|
+
const animalClassify = temporarilyNotSupport('animalClassify');
|
|
3273
|
+
const plantClassify = temporarilyNotSupport('plantClassify');
|
|
3274
|
+
// 用户信息
|
|
3275
|
+
const getSwanId = temporarilyNotSupport('getSwanId');
|
|
3276
|
+
// 百度收银台支付
|
|
3277
|
+
const requestPolymerPayment = temporarilyNotSupport('requestPolymerPayment');
|
|
3278
|
+
// 打开小程序
|
|
3279
|
+
const navigateToSmartGameProgram = temporarilyNotSupport('navigateToSmartGameProgram');
|
|
3280
|
+
const navigateToSmartProgram = temporarilyNotSupport('navigateToSmartProgram');
|
|
3281
|
+
const navigateBackSmartProgram = temporarilyNotSupport('navigateBackSmartProgram');
|
|
3282
|
+
const preloadSubPackage = temporarilyNotSupport('preloadSubPackage');
|
|
3283
|
+
|
|
3252
3284
|
/**
|
|
3253
3285
|
* H5 下的 styleSheet 操作
|
|
3254
3286
|
* @author leeenx
|
|
@@ -3596,468 +3628,370 @@ const loadFontFace = (options) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
3596
3628
|
}
|
|
3597
3629
|
});
|
|
3598
3630
|
|
|
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
|
-
|
|
3631
|
+
const noop = function () { };
|
|
3632
|
+
class ActionSheet {
|
|
3633
|
+
constructor() {
|
|
3634
|
+
this.options = {
|
|
3635
|
+
itemList: [],
|
|
3636
|
+
itemColor: '#000000',
|
|
3637
|
+
success: noop,
|
|
3638
|
+
fail: noop,
|
|
3639
|
+
complete: noop
|
|
3640
|
+
};
|
|
3641
|
+
this.style = {
|
|
3642
|
+
maskStyle: {
|
|
3643
|
+
position: 'fixed',
|
|
3644
|
+
'z-index': '1000',
|
|
3645
|
+
top: '0',
|
|
3646
|
+
right: '0',
|
|
3647
|
+
left: '0',
|
|
3648
|
+
bottom: '0',
|
|
3649
|
+
background: 'rgba(0,0,0,0.6)'
|
|
3650
|
+
},
|
|
3651
|
+
actionSheetStyle: {
|
|
3652
|
+
'z-index': '4999',
|
|
3653
|
+
position: 'fixed',
|
|
3654
|
+
left: '0',
|
|
3655
|
+
bottom: '0',
|
|
3656
|
+
'-webkit-transform': 'translate(0, 100%)',
|
|
3657
|
+
transform: 'translate(0, 100%)',
|
|
3658
|
+
width: '100%',
|
|
3659
|
+
'line-height': '1.6',
|
|
3660
|
+
background: '#EFEFF4',
|
|
3661
|
+
'-webkit-transition': '-webkit-transform .3s',
|
|
3662
|
+
transition: 'transform .3s'
|
|
3663
|
+
},
|
|
3664
|
+
menuStyle: {
|
|
3665
|
+
'background-color': '#FCFCFD'
|
|
3666
|
+
},
|
|
3667
|
+
cellStyle: {
|
|
3668
|
+
position: 'relative',
|
|
3669
|
+
padding: '10px 0',
|
|
3670
|
+
'text-align': 'center',
|
|
3671
|
+
'font-size': '18px'
|
|
3672
|
+
},
|
|
3673
|
+
cancelStyle: {
|
|
3674
|
+
'margin-top': '6px',
|
|
3675
|
+
padding: '10px 0',
|
|
3676
|
+
'text-align': 'center',
|
|
3677
|
+
'font-size': '18px',
|
|
3678
|
+
color: '#000000',
|
|
3679
|
+
'background-color': '#FCFCFD'
|
|
3680
|
+
}
|
|
3681
|
+
};
|
|
3682
|
+
this.lastConfig = {};
|
|
3625
3683
|
}
|
|
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
|
-
|
|
3684
|
+
create(options = {}) {
|
|
3685
|
+
return new Promise((resolve) => {
|
|
3686
|
+
// style
|
|
3687
|
+
const { maskStyle, actionSheetStyle, menuStyle, cellStyle, cancelStyle } = this.style;
|
|
3688
|
+
// configuration
|
|
3689
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
3690
|
+
this.lastConfig = config;
|
|
3691
|
+
// wrapper
|
|
3692
|
+
this.el = document.createElement('div');
|
|
3693
|
+
this.el.className = 'taro__actionSheet';
|
|
3694
|
+
this.el.style.opacity = '0';
|
|
3695
|
+
this.el.style.transition = 'opacity 0.2s linear';
|
|
3696
|
+
// mask
|
|
3697
|
+
const mask = document.createElement('div');
|
|
3698
|
+
mask.setAttribute('style', inlineStyle(maskStyle));
|
|
3699
|
+
// actionSheet
|
|
3700
|
+
this.actionSheet = document.createElement('div');
|
|
3701
|
+
this.actionSheet.setAttribute('style', inlineStyle(actionSheetStyle));
|
|
3702
|
+
// menu
|
|
3703
|
+
this.menu = document.createElement('div');
|
|
3704
|
+
this.menu.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, menuStyle), { color: config.itemColor })));
|
|
3705
|
+
// cells
|
|
3706
|
+
this.cells = config.itemList.map((item, index) => {
|
|
3707
|
+
const cell = document.createElement('div');
|
|
3708
|
+
cell.className = 'taro-actionsheet__cell';
|
|
3709
|
+
cell.setAttribute('style', inlineStyle(cellStyle));
|
|
3710
|
+
cell.textContent = item;
|
|
3711
|
+
cell.dataset.tapIndex = `${index}`;
|
|
3712
|
+
cell.onclick = e => {
|
|
3713
|
+
this.hide();
|
|
3714
|
+
const target = e.currentTarget;
|
|
3715
|
+
const index = Number(target === null || target === void 0 ? void 0 : target.dataset.tapIndex) || 0;
|
|
3716
|
+
resolve(index);
|
|
3717
|
+
};
|
|
3718
|
+
return cell;
|
|
3719
|
+
});
|
|
3720
|
+
// cancel
|
|
3721
|
+
this.cancel = document.createElement('div');
|
|
3722
|
+
this.cancel.setAttribute('style', inlineStyle(cancelStyle));
|
|
3723
|
+
this.cancel.textContent = '取消';
|
|
3724
|
+
// result
|
|
3725
|
+
this.cells.forEach(item => this.menu.appendChild(item));
|
|
3726
|
+
this.actionSheet.appendChild(this.menu);
|
|
3727
|
+
this.actionSheet.appendChild(this.cancel);
|
|
3728
|
+
this.el.appendChild(mask);
|
|
3729
|
+
this.el.appendChild(this.actionSheet);
|
|
3730
|
+
// callbacks
|
|
3731
|
+
const cb = () => {
|
|
3732
|
+
this.hide();
|
|
3733
|
+
resolve('cancel');
|
|
3734
|
+
};
|
|
3735
|
+
mask.onclick = cb;
|
|
3736
|
+
this.cancel.onclick = cb;
|
|
3737
|
+
// show immediately
|
|
3738
|
+
document.body.appendChild(this.el);
|
|
3739
|
+
setTimeout(() => {
|
|
3740
|
+
this.el.style.opacity = '1';
|
|
3741
|
+
setTransform(this.actionSheet, 'translate(0, 0)');
|
|
3742
|
+
}, 0);
|
|
3664
3743
|
});
|
|
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
|
-
};
|
|
3744
|
+
}
|
|
3745
|
+
show(options = {}) {
|
|
3746
|
+
return new Promise((resolve) => {
|
|
3747
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
3748
|
+
this.lastConfig = config;
|
|
3749
|
+
if (this.hideOpacityTimer)
|
|
3750
|
+
clearTimeout(this.hideOpacityTimer);
|
|
3751
|
+
if (this.hideDisplayTimer)
|
|
3752
|
+
clearTimeout(this.hideDisplayTimer);
|
|
3753
|
+
// itemColor
|
|
3754
|
+
if (config.itemColor)
|
|
3755
|
+
this.menu.style.color = config.itemColor;
|
|
3756
|
+
// cells
|
|
3757
|
+
const { cellStyle } = this.style;
|
|
3758
|
+
config.itemList.forEach((item, index) => {
|
|
3759
|
+
let cell;
|
|
3760
|
+
if (this.cells[index]) {
|
|
3761
|
+
// assign new content
|
|
3762
|
+
cell = this.cells[index];
|
|
3699
3763
|
}
|
|
3700
3764
|
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);
|
|
3765
|
+
// create new cell
|
|
3766
|
+
cell = document.createElement('div');
|
|
3767
|
+
cell.className = 'taro-actionsheet__cell';
|
|
3768
|
+
cell.setAttribute('style', inlineStyle(cellStyle));
|
|
3769
|
+
cell.dataset.tapIndex = `${index}`;
|
|
3770
|
+
this.cells.push(cell);
|
|
3771
|
+
this.menu.appendChild(cell);
|
|
3734
3772
|
}
|
|
3735
|
-
|
|
3736
|
-
|
|
3773
|
+
cell.textContent = item;
|
|
3774
|
+
cell.onclick = e => {
|
|
3775
|
+
this.hide();
|
|
3776
|
+
const target = e.currentTarget;
|
|
3777
|
+
const index = Number(target === null || target === void 0 ? void 0 : target.dataset.tapIndex) || 0;
|
|
3778
|
+
resolve(index);
|
|
3779
|
+
};
|
|
3780
|
+
});
|
|
3781
|
+
const cellsLen = this.cells.length;
|
|
3782
|
+
const itemListLen = config.itemList.length;
|
|
3783
|
+
if (cellsLen > itemListLen) {
|
|
3784
|
+
for (let i = itemListLen; i < cellsLen; i++) {
|
|
3785
|
+
this.menu.removeChild(this.cells[i]);
|
|
3737
3786
|
}
|
|
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
|
-
})
|
|
3787
|
+
this.cells.splice(itemListLen);
|
|
3788
|
+
}
|
|
3789
|
+
// show
|
|
3790
|
+
this.el.style.display = 'block';
|
|
3791
|
+
setTimeout(() => {
|
|
3792
|
+
this.el.style.opacity = '1';
|
|
3793
|
+
setTransform(this.actionSheet, 'translate(0, 0)');
|
|
3794
|
+
}, 0);
|
|
3776
3795
|
});
|
|
3777
3796
|
}
|
|
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);
|
|
3797
|
+
hide() {
|
|
3798
|
+
if (this.hideOpacityTimer)
|
|
3799
|
+
clearTimeout(this.hideOpacityTimer);
|
|
3800
|
+
if (this.hideDisplayTimer)
|
|
3801
|
+
clearTimeout(this.hideDisplayTimer);
|
|
3802
|
+
this.hideOpacityTimer = setTimeout(() => {
|
|
3803
|
+
this.el.style.opacity = '0';
|
|
3804
|
+
setTransform(this.actionSheet, 'translate(0, 100%)');
|
|
3805
|
+
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
|
|
3806
|
+
}, 0);
|
|
3796
3807
|
}
|
|
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);
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
class Modal {
|
|
3811
|
+
constructor() {
|
|
3812
|
+
this.options = {
|
|
3813
|
+
title: '',
|
|
3814
|
+
content: '',
|
|
3815
|
+
showCancel: true,
|
|
3816
|
+
cancelText: '取消',
|
|
3817
|
+
cancelColor: '#000000',
|
|
3818
|
+
confirmText: '确定',
|
|
3819
|
+
confirmColor: '#3CC51F'
|
|
3820
|
+
};
|
|
3821
|
+
this.style = {
|
|
3822
|
+
maskStyle: {
|
|
3823
|
+
position: 'fixed',
|
|
3824
|
+
'z-index': '1000',
|
|
3825
|
+
top: '0',
|
|
3826
|
+
right: '0',
|
|
3827
|
+
left: '0',
|
|
3828
|
+
bottom: '0',
|
|
3829
|
+
background: 'rgba(0,0,0,0.6)'
|
|
3830
|
+
},
|
|
3831
|
+
modalStyle: {
|
|
3832
|
+
'z-index': '4999',
|
|
3833
|
+
position: 'fixed',
|
|
3834
|
+
top: '50%',
|
|
3835
|
+
left: '50%',
|
|
3836
|
+
transform: 'translate(-50%, -50%)',
|
|
3837
|
+
width: '80%',
|
|
3838
|
+
'max-width': '300px',
|
|
3839
|
+
'border-radius': '3px',
|
|
3840
|
+
'text-align': 'center',
|
|
3841
|
+
'line-height': '1.6',
|
|
3842
|
+
overflow: 'hidden',
|
|
3843
|
+
background: '#FFFFFF'
|
|
3844
|
+
},
|
|
3845
|
+
titleStyle: {
|
|
3846
|
+
padding: '20px 24px 9px',
|
|
3847
|
+
'font-size': '18px'
|
|
3848
|
+
},
|
|
3849
|
+
textStyle: {
|
|
3850
|
+
padding: '0 24px 12px',
|
|
3851
|
+
'min-height': '40px',
|
|
3852
|
+
'font-size': '15px',
|
|
3853
|
+
'line-height': '1.3',
|
|
3854
|
+
color: '#808080'
|
|
3855
|
+
},
|
|
3856
|
+
footStyle: {
|
|
3857
|
+
position: 'relative',
|
|
3858
|
+
'line-height': '48px',
|
|
3859
|
+
'font-size': '18px',
|
|
3860
|
+
display: 'flex'
|
|
3861
|
+
},
|
|
3862
|
+
btnStyle: {
|
|
3863
|
+
position: 'relative',
|
|
3864
|
+
'-webkit-box-flex': '1',
|
|
3865
|
+
'-webkit-flex': '1',
|
|
3866
|
+
flex: '1'
|
|
3867
|
+
}
|
|
3868
|
+
};
|
|
4011
3869
|
}
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
3870
|
+
create(options = {}) {
|
|
3871
|
+
return new Promise((resolve) => {
|
|
3872
|
+
// style
|
|
3873
|
+
const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style;
|
|
3874
|
+
// configuration
|
|
3875
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
3876
|
+
// wrapper
|
|
3877
|
+
this.el = document.createElement('div');
|
|
3878
|
+
this.el.className = 'taro__modal';
|
|
3879
|
+
this.el.style.opacity = '0';
|
|
3880
|
+
this.el.style.transition = 'opacity 0.2s linear';
|
|
3881
|
+
// mask
|
|
3882
|
+
const mask = document.createElement('div');
|
|
3883
|
+
mask.className = 'taro-modal__mask';
|
|
3884
|
+
mask.setAttribute('style', inlineStyle(maskStyle));
|
|
3885
|
+
// modal
|
|
3886
|
+
const modal = document.createElement('div');
|
|
3887
|
+
modal.className = 'taro-modal__content';
|
|
3888
|
+
modal.setAttribute('style', inlineStyle(modalStyle));
|
|
3889
|
+
// title
|
|
3890
|
+
const titleCSS = config.title ? titleStyle : Object.assign(Object.assign({}, titleStyle), { display: 'none' });
|
|
3891
|
+
this.title = document.createElement('div');
|
|
3892
|
+
this.title.className = 'taro-modal__title';
|
|
3893
|
+
this.title.setAttribute('style', inlineStyle(titleCSS));
|
|
3894
|
+
this.title.textContent = config.title;
|
|
3895
|
+
// text
|
|
3896
|
+
const textCSS = config.title ? textStyle : Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
3897
|
+
this.text = document.createElement('div');
|
|
3898
|
+
this.text.className = 'taro-modal__text';
|
|
3899
|
+
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
3900
|
+
this.text.textContent = config.content;
|
|
3901
|
+
// foot
|
|
3902
|
+
const foot = document.createElement('div');
|
|
3903
|
+
foot.className = 'taro-modal__foot';
|
|
3904
|
+
foot.setAttribute('style', inlineStyle(footStyle));
|
|
3905
|
+
// cancel button
|
|
3906
|
+
const cancelCSS = Object.assign(Object.assign({}, btnStyle), { color: config.cancelColor, display: config.showCancel ? 'block' : 'none' });
|
|
3907
|
+
this.cancel = document.createElement('div');
|
|
3908
|
+
this.cancel.className = 'taro-model__btn taro-model__cancel';
|
|
3909
|
+
this.cancel.setAttribute('style', inlineStyle(cancelCSS));
|
|
3910
|
+
this.cancel.textContent = config.cancelText;
|
|
3911
|
+
this.cancel.onclick = () => {
|
|
3912
|
+
this.hide();
|
|
3913
|
+
resolve('cancel');
|
|
3914
|
+
};
|
|
3915
|
+
// confirm button
|
|
3916
|
+
this.confirm = document.createElement('div');
|
|
3917
|
+
this.confirm.className = 'taro-model__btn taro-model__confirm';
|
|
3918
|
+
this.confirm.setAttribute('style', inlineStyle(btnStyle));
|
|
3919
|
+
this.confirm.style.color = config.confirmColor;
|
|
3920
|
+
this.confirm.textContent = config.confirmText;
|
|
3921
|
+
this.confirm.onclick = () => {
|
|
3922
|
+
this.hide();
|
|
3923
|
+
resolve('confirm');
|
|
3924
|
+
};
|
|
3925
|
+
// result
|
|
3926
|
+
foot.appendChild(this.cancel);
|
|
3927
|
+
foot.appendChild(this.confirm);
|
|
3928
|
+
modal.appendChild(this.title);
|
|
3929
|
+
modal.appendChild(this.text);
|
|
3930
|
+
modal.appendChild(foot);
|
|
3931
|
+
this.el.appendChild(mask);
|
|
3932
|
+
this.el.appendChild(modal);
|
|
3933
|
+
// show immediately
|
|
3934
|
+
document.body.appendChild(this.el);
|
|
3935
|
+
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
4021
3936
|
});
|
|
4022
3937
|
}
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
3938
|
+
show(options = {}) {
|
|
3939
|
+
return new Promise((resolve) => {
|
|
3940
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
3941
|
+
if (this.hideOpacityTimer)
|
|
3942
|
+
clearTimeout(this.hideOpacityTimer);
|
|
3943
|
+
if (this.hideDisplayTimer)
|
|
3944
|
+
clearTimeout(this.hideDisplayTimer);
|
|
3945
|
+
// title & text
|
|
3946
|
+
const { textStyle } = this.style;
|
|
3947
|
+
if (config.title) {
|
|
3948
|
+
this.title.textContent = config.title;
|
|
3949
|
+
// none => block
|
|
3950
|
+
this.title.style.display = 'block';
|
|
3951
|
+
this.text.setAttribute('style', inlineStyle(textStyle));
|
|
3952
|
+
}
|
|
3953
|
+
else {
|
|
3954
|
+
// block => none
|
|
3955
|
+
this.title.style.display = 'none';
|
|
3956
|
+
const textCSS = Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
3957
|
+
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
3958
|
+
}
|
|
3959
|
+
this.text.textContent = config.content || '';
|
|
3960
|
+
// showCancel
|
|
3961
|
+
this.cancel.style.display = config.showCancel ? 'block' : 'none';
|
|
3962
|
+
// cancelText
|
|
3963
|
+
this.cancel.textContent = config.cancelText || '';
|
|
3964
|
+
// cancelColor
|
|
3965
|
+
this.cancel.style.color = config.cancelColor || '';
|
|
3966
|
+
// confirmText
|
|
3967
|
+
this.confirm.textContent = config.confirmText || '';
|
|
3968
|
+
// confirmColor
|
|
3969
|
+
this.confirm.style.color = config.confirmColor || '';
|
|
3970
|
+
// cbs
|
|
3971
|
+
this.cancel.onclick = () => {
|
|
3972
|
+
this.hide();
|
|
3973
|
+
resolve('cancel');
|
|
3974
|
+
};
|
|
3975
|
+
this.confirm.onclick = () => {
|
|
3976
|
+
this.hide();
|
|
3977
|
+
resolve('confirm');
|
|
3978
|
+
};
|
|
3979
|
+
// show
|
|
3980
|
+
this.el.style.display = 'block';
|
|
3981
|
+
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
4028
3982
|
});
|
|
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
3983
|
}
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
3984
|
+
hide() {
|
|
3985
|
+
if (this.hideOpacityTimer)
|
|
3986
|
+
clearTimeout(this.hideOpacityTimer);
|
|
3987
|
+
if (this.hideDisplayTimer)
|
|
3988
|
+
clearTimeout(this.hideDisplayTimer);
|
|
3989
|
+
this.hideOpacityTimer = setTimeout(() => {
|
|
3990
|
+
this.el.style.opacity = '0';
|
|
3991
|
+
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
|
|
3992
|
+
}, 0);
|
|
4059
3993
|
}
|
|
4060
|
-
}
|
|
3994
|
+
}
|
|
4061
3995
|
|
|
4062
3996
|
class Toast {
|
|
4063
3997
|
constructor() {
|
|
@@ -4228,632 +4162,730 @@ class Toast {
|
|
|
4228
4162
|
}
|
|
4229
4163
|
}
|
|
4230
4164
|
|
|
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
|
-
};
|
|
4165
|
+
// 交互
|
|
4166
|
+
let status = 'default';
|
|
4167
|
+
// inject necessary style
|
|
4168
|
+
function init(doc) {
|
|
4169
|
+
if (status === 'ready')
|
|
4170
|
+
return;
|
|
4171
|
+
const taroStyle = doc.createElement('style');
|
|
4172
|
+
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);}';
|
|
4173
|
+
doc.querySelector('head').appendChild(taroStyle);
|
|
4174
|
+
status = 'ready';
|
|
4175
|
+
}
|
|
4176
|
+
const toast = new Toast();
|
|
4177
|
+
const modal = new Modal();
|
|
4178
|
+
const actionSheet = new ActionSheet();
|
|
4179
|
+
const showToast = (options = { title: '' }) => {
|
|
4180
|
+
init(document);
|
|
4181
|
+
options = Object.assign({
|
|
4182
|
+
title: '',
|
|
4183
|
+
icon: 'success',
|
|
4184
|
+
image: '',
|
|
4185
|
+
duration: 1500,
|
|
4186
|
+
mask: false
|
|
4187
|
+
}, options);
|
|
4188
|
+
const { success, fail, complete } = options;
|
|
4189
|
+
const handle = new MethodHandler({ name: 'showToast', success, fail, complete });
|
|
4190
|
+
if (typeof options.title !== 'string') {
|
|
4191
|
+
return handle.fail({
|
|
4192
|
+
errMsg: getParameterError({
|
|
4193
|
+
para: 'title',
|
|
4194
|
+
correct: 'String',
|
|
4195
|
+
wrong: options.title
|
|
4196
|
+
})
|
|
4197
|
+
});
|
|
4290
4198
|
}
|
|
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
|
-
|
|
4199
|
+
if (typeof options.duration !== 'number') {
|
|
4200
|
+
return handle.fail({
|
|
4201
|
+
errMsg: getParameterError({
|
|
4202
|
+
para: 'duration',
|
|
4203
|
+
correct: 'Number',
|
|
4204
|
+
wrong: options.duration
|
|
4205
|
+
})
|
|
4206
|
+
});
|
|
4207
|
+
}
|
|
4208
|
+
if (options.image && typeof options.image !== 'string')
|
|
4209
|
+
options.image = '';
|
|
4210
|
+
options.mask = !!options.mask;
|
|
4211
|
+
let errMsg = '';
|
|
4212
|
+
if (!toast.el) {
|
|
4213
|
+
errMsg = toast.create(options, 'toast');
|
|
4214
|
+
}
|
|
4215
|
+
else {
|
|
4216
|
+
errMsg = toast.show(options, 'toast');
|
|
4217
|
+
}
|
|
4218
|
+
return handle.success({ errMsg });
|
|
4219
|
+
};
|
|
4220
|
+
const hideToast = ({ success, fail, complete } = {}) => {
|
|
4221
|
+
const handle = new MethodHandler({ name: 'hideToast', success, fail, complete });
|
|
4222
|
+
if (!toast.el)
|
|
4223
|
+
return handle.success();
|
|
4224
|
+
toast.hide(0, 'toast');
|
|
4225
|
+
return handle.success();
|
|
4226
|
+
};
|
|
4227
|
+
const showLoading = (options = { title: '' }) => {
|
|
4228
|
+
init(document);
|
|
4229
|
+
options = Object.assign({
|
|
4230
|
+
title: '',
|
|
4231
|
+
mask: false
|
|
4232
|
+
}, options);
|
|
4233
|
+
const { success, fail, complete } = options;
|
|
4234
|
+
const handle = new MethodHandler({ name: 'showLoading', success, fail, complete });
|
|
4235
|
+
const config = {
|
|
4236
|
+
icon: 'loading',
|
|
4237
|
+
image: '',
|
|
4238
|
+
duration: -1
|
|
4239
|
+
};
|
|
4240
|
+
options = Object.assign({}, options, config);
|
|
4241
|
+
if (typeof options.title !== 'string') {
|
|
4242
|
+
return handle.fail({
|
|
4243
|
+
errMsg: getParameterError({
|
|
4244
|
+
para: 'title',
|
|
4245
|
+
correct: 'String',
|
|
4246
|
+
wrong: options.title
|
|
4247
|
+
})
|
|
4248
|
+
});
|
|
4249
|
+
}
|
|
4250
|
+
options.mask = !!options.mask;
|
|
4251
|
+
let errMsg = '';
|
|
4252
|
+
if (!toast.el) {
|
|
4253
|
+
errMsg = toast.create(options, 'loading');
|
|
4254
|
+
}
|
|
4255
|
+
else {
|
|
4256
|
+
errMsg = toast.show(options, 'loading');
|
|
4257
|
+
}
|
|
4258
|
+
return handle.success({ errMsg });
|
|
4259
|
+
};
|
|
4260
|
+
const hideLoading = ({ success, fail, complete } = {}) => {
|
|
4261
|
+
const handle = new MethodHandler({ name: 'hideLoading', success, fail, complete });
|
|
4262
|
+
if (!toast.el)
|
|
4263
|
+
return handle.success();
|
|
4264
|
+
toast.hide(0, 'loading');
|
|
4265
|
+
return handle.success();
|
|
4266
|
+
};
|
|
4267
|
+
const showModal = (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4268
|
+
init(document);
|
|
4269
|
+
options = Object.assign({
|
|
4270
|
+
title: '',
|
|
4271
|
+
content: '',
|
|
4272
|
+
showCancel: true,
|
|
4273
|
+
cancelText: '取消',
|
|
4274
|
+
cancelColor: '#000000',
|
|
4275
|
+
confirmText: '确定',
|
|
4276
|
+
confirmColor: '#3CC51F'
|
|
4277
|
+
}, options);
|
|
4278
|
+
const { success, fail, complete } = options;
|
|
4279
|
+
const handle = new MethodHandler({ name: 'showModal', success, fail, complete });
|
|
4280
|
+
if (typeof options.title !== 'string') {
|
|
4281
|
+
return handle.fail({
|
|
4282
|
+
errMsg: getParameterError({
|
|
4283
|
+
para: 'title',
|
|
4284
|
+
correct: 'String',
|
|
4285
|
+
wrong: options.title
|
|
4286
|
+
})
|
|
4357
4287
|
});
|
|
4358
4288
|
}
|
|
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);
|
|
4289
|
+
if (typeof options.content !== 'string') {
|
|
4290
|
+
return handle.fail({
|
|
4291
|
+
errMsg: getParameterError({
|
|
4292
|
+
para: 'content',
|
|
4293
|
+
correct: 'String',
|
|
4294
|
+
wrong: options.content
|
|
4295
|
+
})
|
|
4403
4296
|
});
|
|
4404
4297
|
}
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
}, 0);
|
|
4298
|
+
if (typeof options.cancelText !== 'string') {
|
|
4299
|
+
return handle.fail({
|
|
4300
|
+
errMsg: getParameterError({
|
|
4301
|
+
para: 'cancelText',
|
|
4302
|
+
correct: 'String',
|
|
4303
|
+
wrong: options.cancelText
|
|
4304
|
+
})
|
|
4305
|
+
});
|
|
4414
4306
|
}
|
|
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 = {};
|
|
4307
|
+
if (options.cancelText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
4308
|
+
return handle.fail({
|
|
4309
|
+
errMsg: 'cancelText length should not larger then 4 Chinese characters'
|
|
4310
|
+
});
|
|
4469
4311
|
}
|
|
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
|
-
|
|
4312
|
+
if (typeof options.confirmText !== 'string') {
|
|
4313
|
+
return handle.fail({
|
|
4314
|
+
errMsg: getParameterError({
|
|
4315
|
+
para: 'confirmText',
|
|
4316
|
+
correct: 'String',
|
|
4317
|
+
wrong: options.confirmText
|
|
4318
|
+
})
|
|
4319
|
+
});
|
|
4320
|
+
}
|
|
4321
|
+
if (options.confirmText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
4322
|
+
return handle.fail({
|
|
4323
|
+
errMsg: 'confirmText length should not larger then 4 Chinese characters'
|
|
4324
|
+
});
|
|
4325
|
+
}
|
|
4326
|
+
if (typeof options.cancelColor !== 'string') {
|
|
4327
|
+
return handle.fail({
|
|
4328
|
+
errMsg: getParameterError({
|
|
4329
|
+
para: 'cancelColor',
|
|
4330
|
+
correct: 'String',
|
|
4331
|
+
wrong: options.cancelColor
|
|
4332
|
+
})
|
|
4333
|
+
});
|
|
4334
|
+
}
|
|
4335
|
+
if (typeof options.confirmColor !== 'string') {
|
|
4336
|
+
return handle.fail({
|
|
4337
|
+
errMsg: getParameterError({
|
|
4338
|
+
para: 'confirmColor',
|
|
4339
|
+
correct: 'String',
|
|
4340
|
+
wrong: options.confirmColor
|
|
4341
|
+
})
|
|
4342
|
+
});
|
|
4343
|
+
}
|
|
4344
|
+
options.showCancel = !!options.showCancel;
|
|
4345
|
+
let result = '';
|
|
4346
|
+
if (!modal.el) {
|
|
4347
|
+
result = yield modal.create(options);
|
|
4348
|
+
}
|
|
4349
|
+
else {
|
|
4350
|
+
result = yield modal.show(options);
|
|
4351
|
+
}
|
|
4352
|
+
const res = { cancel: !1, confirm: !1 };
|
|
4353
|
+
res[result] = !0;
|
|
4354
|
+
return handle.success(res);
|
|
4355
|
+
});
|
|
4356
|
+
function hideModal() {
|
|
4357
|
+
if (!modal.el)
|
|
4358
|
+
return;
|
|
4359
|
+
modal.hide();
|
|
4360
|
+
}
|
|
4361
|
+
const showActionSheet = (options = { itemList: [] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4362
|
+
init(document);
|
|
4363
|
+
options = Object.assign({
|
|
4364
|
+
itemColor: '#000000',
|
|
4365
|
+
itemList: []
|
|
4366
|
+
}, options);
|
|
4367
|
+
const { success, fail, complete } = options;
|
|
4368
|
+
const handle = new MethodHandler({ name: 'showActionSheet', success, fail, complete });
|
|
4369
|
+
// list item String
|
|
4370
|
+
if (!Array.isArray(options.itemList)) {
|
|
4371
|
+
return handle.fail({
|
|
4372
|
+
errMsg: getParameterError({
|
|
4373
|
+
para: 'itemList',
|
|
4374
|
+
correct: 'Array',
|
|
4375
|
+
wrong: options.itemList
|
|
4376
|
+
})
|
|
4529
4377
|
});
|
|
4530
4378
|
}
|
|
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
|
-
};
|
|
4379
|
+
if (options.itemList.length < 1) {
|
|
4380
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should have at least 1 item' });
|
|
4381
|
+
}
|
|
4382
|
+
if (options.itemList.length > 6) {
|
|
4383
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should not be large than 6' });
|
|
4384
|
+
}
|
|
4385
|
+
for (let i = 0; i < options.itemList.length; i++) {
|
|
4386
|
+
if (typeof options.itemList[i] !== 'string') {
|
|
4387
|
+
return handle.fail({
|
|
4388
|
+
errMsg: getParameterError({
|
|
4389
|
+
para: `itemList[${i}]`,
|
|
4390
|
+
correct: 'String',
|
|
4391
|
+
wrong: options.itemList[i]
|
|
4392
|
+
})
|
|
4566
4393
|
});
|
|
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);
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
if (typeof options.itemColor !== 'string') {
|
|
4397
|
+
return handle.fail({
|
|
4398
|
+
errMsg: getParameterError({
|
|
4399
|
+
para: 'itemColor',
|
|
4400
|
+
correct: 'String',
|
|
4401
|
+
wrong: options.itemColor
|
|
4402
|
+
})
|
|
4581
4403
|
});
|
|
4582
4404
|
}
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4405
|
+
let result = '';
|
|
4406
|
+
if (!actionSheet.el) {
|
|
4407
|
+
result = yield actionSheet.create(options);
|
|
4408
|
+
}
|
|
4409
|
+
else {
|
|
4410
|
+
result = yield actionSheet.show(options);
|
|
4411
|
+
}
|
|
4412
|
+
if (typeof result === 'string') {
|
|
4413
|
+
return handle.fail(({ errMsg: result }));
|
|
4414
|
+
}
|
|
4415
|
+
else {
|
|
4416
|
+
return handle.success(({ tapIndex: result }));
|
|
4417
|
+
}
|
|
4418
|
+
});
|
|
4419
|
+
Taro__default["default"].eventCenter.on('__taroRouterChange', () => {
|
|
4420
|
+
hideToast();
|
|
4421
|
+
hideLoading();
|
|
4422
|
+
hideModal();
|
|
4423
|
+
});
|
|
4424
|
+
const enableAlertBeforeUnload = temporarilyNotSupport('enableAlertBeforeUnload');
|
|
4425
|
+
const disableAlertBeforeUnload = temporarilyNotSupport('disableAlertBeforeUnload');
|
|
4426
|
+
|
|
4427
|
+
// 菜单
|
|
4428
|
+
const getMenuButtonBoundingClientRect = temporarilyNotSupport('getMenuButtonBoundingClientRect');
|
|
4429
|
+
|
|
4430
|
+
// 导航栏
|
|
4431
|
+
const showNavigationBarLoading = temporarilyNotSupport('showNavigationBarLoading');
|
|
4432
|
+
function setNavigationBarTitle(options) {
|
|
4433
|
+
// options must be an Object
|
|
4434
|
+
const isObject = shouldBeObject(options);
|
|
4435
|
+
if (!isObject.flag) {
|
|
4436
|
+
const res = { errMsg: `setNavigationBarTitle:fail ${isObject.msg}` };
|
|
4437
|
+
console.error(res.errMsg);
|
|
4438
|
+
return Promise.reject(res);
|
|
4439
|
+
}
|
|
4440
|
+
const { title, success, fail, complete } = options;
|
|
4441
|
+
const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete });
|
|
4442
|
+
if (!title || typeof title !== 'string') {
|
|
4443
|
+
return handle.fail({
|
|
4444
|
+
errMsg: getParameterError({
|
|
4445
|
+
para: 'title',
|
|
4446
|
+
correct: 'String',
|
|
4447
|
+
wrong: title
|
|
4448
|
+
})
|
|
4449
|
+
});
|
|
4593
4450
|
}
|
|
4451
|
+
if (document.title !== title) {
|
|
4452
|
+
document.title = title;
|
|
4453
|
+
}
|
|
4454
|
+
return handle.success();
|
|
4594
4455
|
}
|
|
4456
|
+
/**
|
|
4457
|
+
* 设置页面导航条颜色
|
|
4458
|
+
*/
|
|
4459
|
+
const setNavigationBarColor = (options) => {
|
|
4460
|
+
const { backgroundColor, success, fail, complete } = options;
|
|
4461
|
+
const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete });
|
|
4462
|
+
const meta = document.createElement('meta');
|
|
4463
|
+
meta.setAttribute('name', 'theme-color');
|
|
4464
|
+
meta.setAttribute('content', backgroundColor);
|
|
4465
|
+
document.head.appendChild(meta);
|
|
4466
|
+
return handle.success();
|
|
4467
|
+
};
|
|
4468
|
+
const hideNavigationBarLoading = temporarilyNotSupport('hideNavigationBarLoading');
|
|
4469
|
+
const hideHomeButton = temporarilyNotSupport('hideHomeButton');
|
|
4470
|
+
|
|
4471
|
+
/**
|
|
4472
|
+
* 开始下拉刷新。调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
|
|
4473
|
+
*/
|
|
4474
|
+
const startPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
4475
|
+
const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
|
|
4476
|
+
return new Promise((resolve, reject) => {
|
|
4477
|
+
Taro__default["default"].eventCenter.trigger('__taroStartPullDownRefresh', {
|
|
4478
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4479
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4480
|
+
});
|
|
4481
|
+
});
|
|
4482
|
+
};
|
|
4483
|
+
/**
|
|
4484
|
+
* 停止当前页面下拉刷新。
|
|
4485
|
+
*/
|
|
4486
|
+
const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
4487
|
+
const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
|
|
4488
|
+
return new Promise((resolve, reject) => {
|
|
4489
|
+
Taro__default["default"].eventCenter.trigger('__taroStopPullDownRefresh', {
|
|
4490
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4491
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4492
|
+
});
|
|
4493
|
+
});
|
|
4494
|
+
};
|
|
4495
|
+
|
|
4496
|
+
let timer;
|
|
4497
|
+
const FRAME_DURATION = 17;
|
|
4498
|
+
/**
|
|
4499
|
+
* 将页面滚动到目标位置
|
|
4500
|
+
*/
|
|
4501
|
+
const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success, fail, complete }) => {
|
|
4502
|
+
let scrollFunc;
|
|
4503
|
+
const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete });
|
|
4504
|
+
return new Promise((resolve, reject) => {
|
|
4505
|
+
var _a, _b;
|
|
4506
|
+
try {
|
|
4507
|
+
if (scrollTop === undefined && !selector) {
|
|
4508
|
+
return handle.fail({
|
|
4509
|
+
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
4510
|
+
}, reject);
|
|
4511
|
+
}
|
|
4512
|
+
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');
|
|
4513
|
+
const el = (id
|
|
4514
|
+
? document.querySelector(`.taro_page#${id}`)
|
|
4515
|
+
: document.querySelector('.taro_page') ||
|
|
4516
|
+
document.querySelector('.taro_router'));
|
|
4517
|
+
if (!scrollFunc) {
|
|
4518
|
+
if (!el) {
|
|
4519
|
+
scrollFunc = pos => {
|
|
4520
|
+
if (pos === undefined) {
|
|
4521
|
+
return window.pageYOffset;
|
|
4522
|
+
}
|
|
4523
|
+
else {
|
|
4524
|
+
window.scrollTo(0, pos);
|
|
4525
|
+
}
|
|
4526
|
+
};
|
|
4527
|
+
}
|
|
4528
|
+
else {
|
|
4529
|
+
scrollFunc = pos => {
|
|
4530
|
+
if (pos === undefined) {
|
|
4531
|
+
return el.scrollTop;
|
|
4532
|
+
}
|
|
4533
|
+
else {
|
|
4534
|
+
el.scrollTop = pos;
|
|
4535
|
+
}
|
|
4536
|
+
};
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
if (scrollTop && selector) {
|
|
4540
|
+
console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector');
|
|
4541
|
+
}
|
|
4542
|
+
const from = scrollFunc();
|
|
4543
|
+
let to;
|
|
4544
|
+
if (typeof scrollTop === 'number') {
|
|
4545
|
+
to = scrollTop;
|
|
4546
|
+
}
|
|
4547
|
+
else {
|
|
4548
|
+
const el = document.querySelector(selector);
|
|
4549
|
+
to = (el === null || el === void 0 ? void 0 : el.offsetTop) || 0;
|
|
4550
|
+
}
|
|
4551
|
+
const delta = to - from;
|
|
4552
|
+
const frameCnt = duration / FRAME_DURATION;
|
|
4553
|
+
const easeFunc = getTimingFunc(easeInOut, frameCnt);
|
|
4554
|
+
const scroll = (frame = 0) => {
|
|
4555
|
+
const dest = from + delta * easeFunc(frame);
|
|
4556
|
+
scrollFunc(dest);
|
|
4557
|
+
if (frame < frameCnt) {
|
|
4558
|
+
timer && clearTimeout(timer);
|
|
4559
|
+
timer = setTimeout(() => {
|
|
4560
|
+
scroll(frame + 1);
|
|
4561
|
+
}, FRAME_DURATION);
|
|
4562
|
+
}
|
|
4563
|
+
else {
|
|
4564
|
+
return handle.success({}, resolve);
|
|
4565
|
+
}
|
|
4566
|
+
};
|
|
4567
|
+
scroll();
|
|
4568
|
+
}
|
|
4569
|
+
catch (e) {
|
|
4570
|
+
return handle.fail({
|
|
4571
|
+
errMsg: e.message
|
|
4572
|
+
}, reject);
|
|
4573
|
+
}
|
|
4574
|
+
});
|
|
4575
|
+
};
|
|
4595
4576
|
|
|
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';
|
|
4577
|
+
// 置顶
|
|
4578
|
+
const setTopBarText = temporarilyNotSupport('setTopBarText');
|
|
4579
|
+
|
|
4580
|
+
let tabConf;
|
|
4581
|
+
function initTabBarApis(config = {}) {
|
|
4582
|
+
tabConf = config.tabBar;
|
|
4606
4583
|
}
|
|
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
|
-
});
|
|
4584
|
+
/**
|
|
4585
|
+
* 显示 tabBar 某一项的右上角的红点
|
|
4586
|
+
*/
|
|
4587
|
+
const showTabBarRedDot = (options) => {
|
|
4588
|
+
// options must be an Object
|
|
4589
|
+
const isObject = shouldBeObject(options);
|
|
4590
|
+
if (!isObject.flag) {
|
|
4591
|
+
const res = { errMsg: `showTabBarRedDot:fail ${isObject.msg}` };
|
|
4592
|
+
console.error(res.errMsg);
|
|
4593
|
+
return Promise.reject(res);
|
|
4629
4594
|
}
|
|
4630
|
-
|
|
4595
|
+
const { index, success, fail, complete } = options;
|
|
4596
|
+
const handle = new MethodHandler({ name: 'showTabBarRedDot', success, fail, complete });
|
|
4597
|
+
if (typeof index !== 'number') {
|
|
4631
4598
|
return handle.fail({
|
|
4632
4599
|
errMsg: getParameterError({
|
|
4633
|
-
para: '
|
|
4600
|
+
para: 'index',
|
|
4634
4601
|
correct: 'Number',
|
|
4635
|
-
wrong:
|
|
4602
|
+
wrong: index
|
|
4636
4603
|
})
|
|
4637
4604
|
});
|
|
4638
4605
|
}
|
|
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();
|
|
4606
|
+
return new Promise((resolve, reject) => {
|
|
4607
|
+
Taro__default["default"].eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
4608
|
+
index,
|
|
4609
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4610
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4611
|
+
});
|
|
4612
|
+
});
|
|
4657
4613
|
};
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
};
|
|
4671
|
-
options
|
|
4672
|
-
if (typeof options.title !== 'string') {
|
|
4614
|
+
/**
|
|
4615
|
+
* 显示 tabBar
|
|
4616
|
+
*/
|
|
4617
|
+
const showTabBar = (options = {}) => {
|
|
4618
|
+
// options must be an Object
|
|
4619
|
+
const isObject = shouldBeObject(options);
|
|
4620
|
+
if (!isObject.flag) {
|
|
4621
|
+
const res = { errMsg: `showTabBar:fail ${isObject.msg}` };
|
|
4622
|
+
console.error(res.errMsg);
|
|
4623
|
+
return Promise.reject(res);
|
|
4624
|
+
}
|
|
4625
|
+
const { animation, success, fail, complete } = options;
|
|
4626
|
+
const handle = new MethodHandler({ name: 'showTabBar', success, fail, complete });
|
|
4627
|
+
if (options.hasOwnProperty('animation') && typeof animation !== 'boolean') {
|
|
4673
4628
|
return handle.fail({
|
|
4674
4629
|
errMsg: getParameterError({
|
|
4675
|
-
para: '
|
|
4676
|
-
correct: '
|
|
4677
|
-
wrong:
|
|
4630
|
+
para: 'animation',
|
|
4631
|
+
correct: 'Boolean',
|
|
4632
|
+
wrong: animation
|
|
4678
4633
|
})
|
|
4679
4634
|
});
|
|
4680
4635
|
}
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4636
|
+
return new Promise((resolve, reject) => {
|
|
4637
|
+
Taro__default["default"].eventCenter.trigger('__taroShowTabBar', {
|
|
4638
|
+
animation,
|
|
4639
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4640
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4641
|
+
});
|
|
4642
|
+
});
|
|
4643
|
+
};
|
|
4644
|
+
/**
|
|
4645
|
+
* 动态设置 tabBar 的整体样式
|
|
4646
|
+
*/
|
|
4647
|
+
const setTabBarStyle = (options = {}) => {
|
|
4648
|
+
// options must be an Object
|
|
4649
|
+
const isObject = shouldBeObject(options);
|
|
4650
|
+
if (!isObject.flag) {
|
|
4651
|
+
const res = { errMsg: `setTabBarStyle:fail ${isObject.msg}` };
|
|
4652
|
+
console.error(res.errMsg);
|
|
4653
|
+
return Promise.reject(res);
|
|
4685
4654
|
}
|
|
4686
|
-
|
|
4687
|
-
|
|
4655
|
+
const { color, selectedColor, backgroundColor, borderStyle, success, fail, complete } = options;
|
|
4656
|
+
const handle = new MethodHandler({ name: 'setTabBarStyle', success, fail, complete });
|
|
4657
|
+
let errMsg;
|
|
4658
|
+
if (color && !isValidColor(color)) {
|
|
4659
|
+
errMsg = 'color';
|
|
4688
4660
|
}
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4661
|
+
else if (selectedColor && !isValidColor(selectedColor)) {
|
|
4662
|
+
errMsg = 'selectedColor';
|
|
4663
|
+
}
|
|
4664
|
+
else if (backgroundColor && !isValidColor(backgroundColor)) {
|
|
4665
|
+
errMsg = 'backgroundColor';
|
|
4666
|
+
}
|
|
4667
|
+
else if (borderStyle && !/^(black|white)$/.test(borderStyle)) {
|
|
4668
|
+
errMsg = 'borderStyle';
|
|
4669
|
+
}
|
|
4670
|
+
if (errMsg) {
|
|
4671
|
+
return handle.fail({ errMsg: `invalid ${errMsg}` });
|
|
4672
|
+
}
|
|
4673
|
+
if (!tabConf) {
|
|
4674
|
+
return handle.fail();
|
|
4675
|
+
}
|
|
4676
|
+
const obj = {};
|
|
4677
|
+
if (color)
|
|
4678
|
+
obj.color = color;
|
|
4679
|
+
if (selectedColor)
|
|
4680
|
+
obj.selectedColor = selectedColor;
|
|
4681
|
+
if (backgroundColor)
|
|
4682
|
+
obj.backgroundColor = backgroundColor;
|
|
4683
|
+
if (borderStyle)
|
|
4684
|
+
obj.borderStyle = borderStyle;
|
|
4685
|
+
return new Promise((resolve, reject) => {
|
|
4686
|
+
Taro__default["default"].eventCenter.trigger('__taroSetTabBarStyle', {
|
|
4687
|
+
color,
|
|
4688
|
+
selectedColor,
|
|
4689
|
+
backgroundColor,
|
|
4690
|
+
borderStyle,
|
|
4691
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4692
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4693
|
+
});
|
|
4694
|
+
});
|
|
4697
4695
|
};
|
|
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
|
|
4696
|
+
/**
|
|
4697
|
+
* 动态设置 tabBar 某一项的内容
|
|
4698
|
+
*/
|
|
4699
|
+
const setTabBarItem = (options) => {
|
|
4700
|
+
// options must be an Object
|
|
4701
|
+
const isObject = shouldBeObject(options);
|
|
4702
|
+
if (!isObject.flag) {
|
|
4703
|
+
const res = { errMsg: `setTabBarItem:fail ${isObject.msg}` };
|
|
4704
|
+
console.error(res.errMsg);
|
|
4705
|
+
return Promise.reject(res);
|
|
4706
|
+
}
|
|
4707
|
+
const { index, text, iconPath, selectedIconPath, success, fail, complete } = options;
|
|
4708
|
+
const handle = new MethodHandler({ name: 'setTabBarItem', success, fail, complete });
|
|
4709
|
+
if (typeof index !== 'number') {
|
|
4712
4710
|
return handle.fail({
|
|
4713
4711
|
errMsg: getParameterError({
|
|
4714
|
-
para: '
|
|
4715
|
-
correct: '
|
|
4716
|
-
wrong:
|
|
4712
|
+
para: 'index',
|
|
4713
|
+
correct: 'Number',
|
|
4714
|
+
wrong: index
|
|
4717
4715
|
})
|
|
4718
4716
|
});
|
|
4719
4717
|
}
|
|
4720
|
-
|
|
4718
|
+
return new Promise((resolve, reject) => {
|
|
4719
|
+
Taro__default["default"].eventCenter.trigger('__taroSetTabBarItem', {
|
|
4720
|
+
index,
|
|
4721
|
+
text,
|
|
4722
|
+
iconPath,
|
|
4723
|
+
selectedIconPath,
|
|
4724
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4725
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4726
|
+
});
|
|
4727
|
+
});
|
|
4728
|
+
};
|
|
4729
|
+
/**
|
|
4730
|
+
* 为 tabBar 某一项的右上角添加文本
|
|
4731
|
+
*/
|
|
4732
|
+
const setTabBarBadge = (options) => {
|
|
4733
|
+
// options must be an Object
|
|
4734
|
+
const isObject = shouldBeObject(options);
|
|
4735
|
+
if (!isObject.flag) {
|
|
4736
|
+
const res = { errMsg: `setTabBarBadge:fail ${isObject.msg}` };
|
|
4737
|
+
console.error(res.errMsg);
|
|
4738
|
+
return Promise.reject(res);
|
|
4739
|
+
}
|
|
4740
|
+
const { index, text, success, fail, complete } = options;
|
|
4741
|
+
const handle = new MethodHandler({ name: 'setTabBarBadge', success, fail, complete });
|
|
4742
|
+
if (typeof index !== 'number') {
|
|
4721
4743
|
return handle.fail({
|
|
4722
4744
|
errMsg: getParameterError({
|
|
4723
|
-
para: '
|
|
4724
|
-
correct: '
|
|
4725
|
-
wrong:
|
|
4745
|
+
para: 'index',
|
|
4746
|
+
correct: 'Number',
|
|
4747
|
+
wrong: index
|
|
4726
4748
|
})
|
|
4727
4749
|
});
|
|
4728
4750
|
}
|
|
4729
|
-
if (typeof
|
|
4751
|
+
if (typeof text !== 'string') {
|
|
4730
4752
|
return handle.fail({
|
|
4731
4753
|
errMsg: getParameterError({
|
|
4732
|
-
para: '
|
|
4754
|
+
para: 'text',
|
|
4733
4755
|
correct: 'String',
|
|
4734
|
-
wrong:
|
|
4756
|
+
wrong: text
|
|
4735
4757
|
})
|
|
4736
4758
|
});
|
|
4737
4759
|
}
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4760
|
+
return new Promise((resolve, reject) => {
|
|
4761
|
+
Taro__default["default"].eventCenter.trigger('__taroSetTabBarBadge', {
|
|
4762
|
+
index,
|
|
4763
|
+
text,
|
|
4764
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4765
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4741
4766
|
});
|
|
4767
|
+
});
|
|
4768
|
+
};
|
|
4769
|
+
/**
|
|
4770
|
+
* 移除 tabBar 某一项右上角的文本
|
|
4771
|
+
*/
|
|
4772
|
+
const removeTabBarBadge = (options) => {
|
|
4773
|
+
// options must be an Object
|
|
4774
|
+
const isObject = shouldBeObject(options);
|
|
4775
|
+
if (!isObject.flag) {
|
|
4776
|
+
const res = { errMsg: `removeTabBarBadge:fail ${isObject.msg}` };
|
|
4777
|
+
console.error(res.errMsg);
|
|
4778
|
+
return Promise.reject(res);
|
|
4742
4779
|
}
|
|
4743
|
-
|
|
4780
|
+
const { index, success, fail, complete } = options;
|
|
4781
|
+
const handle = new MethodHandler({ name: 'removeTabBarBadge', success, fail, complete });
|
|
4782
|
+
if (typeof index !== 'number') {
|
|
4744
4783
|
return handle.fail({
|
|
4745
4784
|
errMsg: getParameterError({
|
|
4746
|
-
para: '
|
|
4747
|
-
correct: '
|
|
4748
|
-
wrong:
|
|
4785
|
+
para: 'index',
|
|
4786
|
+
correct: 'Number',
|
|
4787
|
+
wrong: index
|
|
4749
4788
|
})
|
|
4750
4789
|
});
|
|
4751
4790
|
}
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4791
|
+
return new Promise((resolve, reject) => {
|
|
4792
|
+
Taro__default["default"].eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
4793
|
+
index,
|
|
4794
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4795
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4755
4796
|
});
|
|
4797
|
+
});
|
|
4798
|
+
};
|
|
4799
|
+
/**
|
|
4800
|
+
* 隐藏 tabBar 某一项的右上角的红点
|
|
4801
|
+
*/
|
|
4802
|
+
const hideTabBarRedDot = (options) => {
|
|
4803
|
+
// options must be an Object
|
|
4804
|
+
const isObject = shouldBeObject(options);
|
|
4805
|
+
if (!isObject.flag) {
|
|
4806
|
+
const res = { errMsg: `hideTabBarRedDot:fail ${isObject.msg}` };
|
|
4807
|
+
console.error(res.errMsg);
|
|
4808
|
+
return Promise.reject(res);
|
|
4756
4809
|
}
|
|
4757
|
-
|
|
4810
|
+
const { index, success, fail, complete } = options;
|
|
4811
|
+
const handle = new MethodHandler({ name: 'hideTabBarRedDot', success, fail, complete });
|
|
4812
|
+
if (typeof index !== 'number') {
|
|
4758
4813
|
return handle.fail({
|
|
4759
4814
|
errMsg: getParameterError({
|
|
4760
|
-
para: '
|
|
4761
|
-
correct: '
|
|
4762
|
-
wrong:
|
|
4815
|
+
para: 'index',
|
|
4816
|
+
correct: 'Number',
|
|
4817
|
+
wrong: index
|
|
4763
4818
|
})
|
|
4764
4819
|
});
|
|
4765
4820
|
}
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
wrong: options.confirmColor
|
|
4772
|
-
})
|
|
4821
|
+
return new Promise((resolve, reject) => {
|
|
4822
|
+
Taro__default["default"].eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
4823
|
+
index,
|
|
4824
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4825
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4773
4826
|
});
|
|
4827
|
+
});
|
|
4828
|
+
};
|
|
4829
|
+
/**
|
|
4830
|
+
* 隐藏 tabBar
|
|
4831
|
+
*/
|
|
4832
|
+
const hideTabBar = (options = {}) => {
|
|
4833
|
+
// options must be an Object
|
|
4834
|
+
const isObject = shouldBeObject(options);
|
|
4835
|
+
if (!isObject.flag) {
|
|
4836
|
+
const res = { errMsg: `hideTabBar:fail ${isObject.msg}` };
|
|
4837
|
+
console.error(res.errMsg);
|
|
4838
|
+
return Promise.reject(res);
|
|
4774
4839
|
}
|
|
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)) {
|
|
4840
|
+
const { animation, success, fail, complete } = options;
|
|
4841
|
+
const handle = new MethodHandler({ name: 'hideTabBar', success, fail, complete });
|
|
4842
|
+
if (options.hasOwnProperty('animation') && typeof animation !== 'boolean') {
|
|
4802
4843
|
return handle.fail({
|
|
4803
4844
|
errMsg: getParameterError({
|
|
4804
|
-
para: '
|
|
4805
|
-
correct: '
|
|
4806
|
-
wrong:
|
|
4845
|
+
para: 'animation',
|
|
4846
|
+
correct: 'Boolean',
|
|
4847
|
+
wrong: animation
|
|
4807
4848
|
})
|
|
4808
4849
|
});
|
|
4809
4850
|
}
|
|
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
|
-
})
|
|
4851
|
+
return new Promise((resolve, reject) => {
|
|
4852
|
+
Taro__default["default"].eventCenter.trigger('__taroHideTabBar', {
|
|
4853
|
+
animation,
|
|
4854
|
+
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4855
|
+
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4834
4856
|
});
|
|
4857
|
+
});
|
|
4858
|
+
};
|
|
4859
|
+
|
|
4860
|
+
const callbackManager = new CallbackManager();
|
|
4861
|
+
const resizeListener = () => {
|
|
4862
|
+
callbackManager.trigger({
|
|
4863
|
+
windowWidth: window.screen.width,
|
|
4864
|
+
windowHeight: window.screen.height
|
|
4865
|
+
});
|
|
4866
|
+
};
|
|
4867
|
+
/**
|
|
4868
|
+
* 设置窗口大小,该接口仅适用于 PC 平台,使用细则请参见指南
|
|
4869
|
+
*/
|
|
4870
|
+
const setWindowSize = temporarilyNotSupport('setWindowSize');
|
|
4871
|
+
/**
|
|
4872
|
+
* 监听窗口尺寸变化事件
|
|
4873
|
+
*/
|
|
4874
|
+
const onWindowResize = callback => {
|
|
4875
|
+
callbackManager.add(callback);
|
|
4876
|
+
if (callbackManager.count() === 1) {
|
|
4877
|
+
window.addEventListener('resize', resizeListener);
|
|
4835
4878
|
}
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
return handle.fail(({ errMsg: result }));
|
|
4845
|
-
}
|
|
4846
|
-
else {
|
|
4847
|
-
return handle.success(({ tapIndex: result }));
|
|
4879
|
+
};
|
|
4880
|
+
/**
|
|
4881
|
+
* 取消监听窗口尺寸变化事件
|
|
4882
|
+
*/
|
|
4883
|
+
const offWindowResize = callback => {
|
|
4884
|
+
callbackManager.remove(callback);
|
|
4885
|
+
if (callbackManager.count() === 0) {
|
|
4886
|
+
window.removeEventListener('resize', resizeListener);
|
|
4848
4887
|
}
|
|
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');
|
|
4888
|
+
};
|
|
4857
4889
|
|
|
4858
4890
|
// Worker
|
|
4859
4891
|
const createWorker = temporarilyNotSupport('createWorker');
|
|
@@ -5105,35 +5137,6 @@ const createSelectorQuery = () => {
|
|
|
5105
5137
|
};
|
|
5106
5138
|
const createIntersectionObserver = temporarilyNotSupport('createIntersectionObserver');
|
|
5107
5139
|
|
|
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
5140
|
const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload } = Taro__default["default"];
|
|
5138
5141
|
const taro = {
|
|
5139
5142
|
// @ts-ignore
|