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