From 0a25101991ca6982240d80a65051928f1e6b647c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=9D=89?= Date: Sun, 18 Feb 2024 18:43:11 +0800 Subject: [PATCH 1/5] demo: remove async --- demo/pages/Form/index.ts | 17 ++++++----- demo/pages/FormCustom/index.ts | 13 +++++---- demo/pages/FormCustomError/index.ts | 17 ++++++----- demo/pages/FormDependency/index.ts | 17 ++++++----- demo/pages/FormDynamic/index.ts | 7 +++-- demo/pages/FormImageUploadRules/index.ts | 19 ++++++------ demo/pages/FormInitialValues/index.ts | 17 ++++++----- demo/pages/FormInitialValuesAsync/index.ts | 17 ++++++----- demo/pages/FormLayout/index.ts | 18 ++++++------ demo/pages/FormMultiple/index.ts | 34 ++++++++++++---------- demo/pages/FormRules/index.ts | 21 ++++++------- demo/pages/FormValidate/index.ts | 16 +++++----- demo/pages/FormValidateMessages/index.ts | 17 ++++++----- demo/pages/FormWatch/index.ts | 18 ++++++------ demo/pages/TabsElevator/index.ts | 4 +-- demo/pages/TabsSticky/index.ts | 2 +- demo/pages/TabsVerticalElevator/index.ts | 4 +-- 17 files changed, 135 insertions(+), 123 deletions(-) diff --git a/demo/pages/Form/index.ts b/demo/pages/Form/index.ts index 7bf67d987..c582125df 100644 --- a/demo/pages/Form/index.ts +++ b/demo/pages/Form/index.ts @@ -58,15 +58,16 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values, null, 2), + submit() { + this.form.submit().then(values => { + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values, null, 2), + }); + /// #endif + console.log(values); }); - /// #endif - console.log(values); }, /// #if ALIPAY onUpload(localFile) { diff --git a/demo/pages/FormCustom/index.ts b/demo/pages/FormCustom/index.ts index b3786ebc4..c916b0e17 100644 --- a/demo/pages/FormCustom/index.ts +++ b/demo/pages/FormCustom/index.ts @@ -19,11 +19,12 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); + submit() { + this.form.submit().then(values => { + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + }) } }); diff --git a/demo/pages/FormCustomError/index.ts b/demo/pages/FormCustomError/index.ts index a8cf01d93..7715829e2 100644 --- a/demo/pages/FormCustomError/index.ts +++ b/demo/pages/FormCustomError/index.ts @@ -26,14 +26,15 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif + console.log(values); }); - /// #endif - console.log(values); }, }); diff --git a/demo/pages/FormDependency/index.ts b/demo/pages/FormDependency/index.ts index 8a1e21f86..8ef9ba1f2 100644 --- a/demo/pages/FormDependency/index.ts +++ b/demo/pages/FormDependency/index.ts @@ -48,14 +48,15 @@ Page({ }); this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif }); - /// #endif }, }); diff --git a/demo/pages/FormDynamic/index.ts b/demo/pages/FormDynamic/index.ts index ea85b1095..5abb710f3 100644 --- a/demo/pages/FormDynamic/index.ts +++ b/demo/pages/FormDynamic/index.ts @@ -59,8 +59,9 @@ Page({ list, }); }, - async submit() { - const values = await this.form.submit(); - console.log(values); + submit() { + this.form.submit().then(values => { + console.log(values); + }); }, }); diff --git a/demo/pages/FormImageUploadRules/index.ts b/demo/pages/FormImageUploadRules/index.ts index 07c94f378..1c64f340b 100644 --- a/demo/pages/FormImageUploadRules/index.ts +++ b/demo/pages/FormImageUploadRules/index.ts @@ -22,7 +22,7 @@ Page({ message: '需要上传图片', }, () => ({ - async validator(_, fileList = []) { + validator(_, fileList = []) { if (fileList.length !== 3) { throw new Error('需要上传3张图片'); } @@ -57,15 +57,16 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif }); - /// #endif }, onUpload(localFile) { return new Promise((resolve) => { diff --git a/demo/pages/FormInitialValues/index.ts b/demo/pages/FormInitialValues/index.ts index cfc88b643..491476c83 100644 --- a/demo/pages/FormInitialValues/index.ts +++ b/demo/pages/FormInitialValues/index.ts @@ -34,14 +34,15 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif }); - /// #endif }, }); diff --git a/demo/pages/FormInitialValuesAsync/index.ts b/demo/pages/FormInitialValuesAsync/index.ts index 3ae60426d..4cd1c7035 100644 --- a/demo/pages/FormInitialValuesAsync/index.ts +++ b/demo/pages/FormInitialValuesAsync/index.ts @@ -63,14 +63,15 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif }); - /// #endif }, }); diff --git a/demo/pages/FormLayout/index.ts b/demo/pages/FormLayout/index.ts index 0b65985d2..3fec4b1b6 100644 --- a/demo/pages/FormLayout/index.ts +++ b/demo/pages/FormLayout/index.ts @@ -34,15 +34,15 @@ Page({ position: this.data.position === 'horizontal' ? 'vertical' : 'horizontal', }); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif }); - /// #endif }, }); diff --git a/demo/pages/FormMultiple/index.ts b/demo/pages/FormMultiple/index.ts index 1f882140d..0d1610753 100644 --- a/demo/pages/FormMultiple/index.ts +++ b/demo/pages/FormMultiple/index.ts @@ -48,24 +48,26 @@ Page({ reset2() { this.form2.reset(); }, - async submit() { - const values = await this.form.submit(); - /// #if ALIPAY - my.alert({ - title: '表单1提交', - content: JSON.stringify(values, null, 2), + submit() { + this.form.submit().then(values => { + /// #if ALIPAY + my.alert({ + title: '表单1提交', + content: JSON.stringify(values, null, 2), + }); + /// #endif + console.log(values); }); - /// #endif - console.log(values); }, - async submit2() { - const values = await this.form2.submit(); - /// #if ALIPAY - my.alert({ - title: '表单2提交', - content: JSON.stringify(values, null, 2), + submit2() { + this.form.submit().then(values => { + /// #if ALIPAY + my.alert({ + title: '表单2提交', + content: JSON.stringify(values, null, 2), + }); + /// #endif + console.log(values); }); - /// #endif - console.log(values); }, }); diff --git a/demo/pages/FormRules/index.ts b/demo/pages/FormRules/index.ts index a8f2221e4..ddbf15148 100644 --- a/demo/pages/FormRules/index.ts +++ b/demo/pages/FormRules/index.ts @@ -16,7 +16,7 @@ Page({ message: '需要输入确认密码', }, (form) => ({ - async validator(_, value) { + validator(_, value) { if (!value || form.getFieldValue('password') === value) { return; } @@ -54,16 +54,17 @@ Page({ this.form.setFieldValue('password', '1234'); this.form.setFieldValue('confirm', '1234'); }, - async submit() { - const values = await this.form.submit(); + submit() { + this.form.submit().then(values => { - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif - console.log(values); + console.log(values); + }); }, }); diff --git a/demo/pages/FormValidate/index.ts b/demo/pages/FormValidate/index.ts index eadd7d705..28a840221 100644 --- a/demo/pages/FormValidate/index.ts +++ b/demo/pages/FormValidate/index.ts @@ -36,14 +36,14 @@ Page({ }); }); }, - async submit() { - const values = await this.form.submit(); - - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif }); - /// #endif }, }); diff --git a/demo/pages/FormValidateMessages/index.ts b/demo/pages/FormValidateMessages/index.ts index 6103feb7a..7005d3a96 100644 --- a/demo/pages/FormValidateMessages/index.ts +++ b/demo/pages/FormValidateMessages/index.ts @@ -58,15 +58,16 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); + submit() { + this.form.submit().then(values => { + console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif }); - /// #endif }, }); diff --git a/demo/pages/FormWatch/index.ts b/demo/pages/FormWatch/index.ts index a79513ced..37b9799d2 100644 --- a/demo/pages/FormWatch/index.ts +++ b/demo/pages/FormWatch/index.ts @@ -53,15 +53,15 @@ Page({ allValuesText: '', }); }, - async submit() { - const values = await this.form.submit(); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + /// #endif + console.log(values); }); - /// #endif - - console.log(values); }, }); diff --git a/demo/pages/TabsElevator/index.ts b/demo/pages/TabsElevator/index.ts index dd65c287a..542cf7101 100644 --- a/demo/pages/TabsElevator/index.ts +++ b/demo/pages/TabsElevator/index.ts @@ -43,8 +43,8 @@ Page({ ); this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - async onReady() { - await this.updateRect(); + onReady() { + this.updateRect(); }, onTap() { this.tap = true; diff --git a/demo/pages/TabsSticky/index.ts b/demo/pages/TabsSticky/index.ts index 95ef5503f..5cb65794d 100644 --- a/demo/pages/TabsSticky/index.ts +++ b/demo/pages/TabsSticky/index.ts @@ -41,7 +41,7 @@ Page({ async onReady() { this.tabsTop = (await this.getBoundingClientRect('.tabs')).top; }, - async onChange(current) { + onChange(current) { /// #if WECHAT current = current.detail; /// #endif diff --git a/demo/pages/TabsVerticalElevator/index.ts b/demo/pages/TabsVerticalElevator/index.ts index 9a8bc5883..262888b9e 100644 --- a/demo/pages/TabsVerticalElevator/index.ts +++ b/demo/pages/TabsVerticalElevator/index.ts @@ -18,8 +18,8 @@ Page({ ); this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - async onReady() { - await this.updateRect(); + onReady() { + this.updateRect(); }, onChange(current) { /// #if WECHAT From c82e2154eea38867ffc26b8b38a64d4e9529222f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=9D=89?= Date: Sun, 18 Feb 2024 18:44:40 +0800 Subject: [PATCH 2/5] demo: updated --- compiled/alipay/demo/pages/Form/index.js | 13 ++-- .../alipay/demo/pages/FormCustom/index.js | 11 ++-- .../demo/pages/FormCustomError/index.js | 13 ++-- .../alipay/demo/pages/FormDependency/index.js | 13 ++-- .../alipay/demo/pages/FormDynamic/index.js | 7 +- .../demo/pages/FormImageUploadRules/index.js | 15 +++-- .../demo/pages/FormInitialValues/index.js | 13 ++-- .../pages/FormInitialValuesAsync/index.js | 13 ++-- .../alipay/demo/pages/FormLayout/index.js | 13 ++-- .../alipay/demo/pages/FormMultiple/index.js | 26 ++++---- compiled/alipay/demo/pages/FormRules/index.js | 15 +++-- .../alipay/demo/pages/FormValidate/index.js | 11 ++-- .../demo/pages/FormValidateMessages/index.js | 13 ++-- compiled/alipay/demo/pages/FormWatch/index.js | 13 ++-- .../alipay/demo/pages/TabsElevator/index.js | 4 +- .../alipay/demo/pages/TabsSticky/index.js | 2 +- .../demo/pages/TabsVerticalElevator/index.js | 4 +- compiled/wechat/demo/pages/Form/index.js | 49 +------------- .../demo/pages/FormCustomError/index.js | 49 +------------- .../wechat/demo/pages/FormDependency/index.js | 49 +------------- .../wechat/demo/pages/FormDynamic/index.js | 49 +------------- .../demo/pages/FormImageUploadRules/index.js | 66 +++---------------- .../demo/pages/FormInitialValues/index.js | 49 +------------- .../pages/FormInitialValuesAsync/index.js | 49 +------------- .../wechat/demo/pages/FormLayout/index.js | 49 +------------- .../wechat/demo/pages/FormMultiple/index.js | 62 ++--------------- compiled/wechat/demo/pages/FormRules/index.js | 61 ++--------------- .../wechat/demo/pages/FormValidate/index.js | 47 +------------ .../demo/pages/FormValidateMessages/index.js | 49 +------------- compiled/wechat/demo/pages/FormWatch/index.js | 49 +------------- .../wechat/demo/pages/TabsElevator/index.js | 11 +--- .../wechat/demo/pages/TabsSticky/index.js | 13 ++-- .../demo/pages/TabsVerticalElevator/index.js | 11 +--- 33 files changed, 150 insertions(+), 761 deletions(-) diff --git a/compiled/alipay/demo/pages/Form/index.js b/compiled/alipay/demo/pages/Form/index.js index cc729ecdc..927fd8a4d 100644 --- a/compiled/alipay/demo/pages/Form/index.js +++ b/compiled/alipay/demo/pages/Form/index.js @@ -29,13 +29,14 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - my.alert({ - title: '提交', - content: JSON.stringify(values, null, 2), + submit() { + this.form.submit().then(values => { + my.alert({ + title: '提交', + content: JSON.stringify(values, null, 2), + }); + console.log(values); }); - console.log(values); }, onUpload(localFile) { return new Promise((resolve) => { diff --git a/compiled/alipay/demo/pages/FormCustom/index.js b/compiled/alipay/demo/pages/FormCustom/index.js index c48782535..052e6ac6f 100644 --- a/compiled/alipay/demo/pages/FormCustom/index.js +++ b/compiled/alipay/demo/pages/FormCustom/index.js @@ -17,11 +17,12 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); }); } }); diff --git a/compiled/alipay/demo/pages/FormCustomError/index.js b/compiled/alipay/demo/pages/FormCustomError/index.js index 898986ed6..27965f830 100644 --- a/compiled/alipay/demo/pages/FormCustomError/index.js +++ b/compiled/alipay/demo/pages/FormCustomError/index.js @@ -9,12 +9,13 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + console.log(values); }); - console.log(values); }, }); diff --git a/compiled/alipay/demo/pages/FormDependency/index.js b/compiled/alipay/demo/pages/FormDependency/index.js index 203cc3be4..c25232295 100644 --- a/compiled/alipay/demo/pages/FormDependency/index.js +++ b/compiled/alipay/demo/pages/FormDependency/index.js @@ -20,12 +20,13 @@ Page({ }); this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); }); }, }); diff --git a/compiled/alipay/demo/pages/FormDynamic/index.js b/compiled/alipay/demo/pages/FormDynamic/index.js index fae818ec6..9b681661c 100644 --- a/compiled/alipay/demo/pages/FormDynamic/index.js +++ b/compiled/alipay/demo/pages/FormDynamic/index.js @@ -38,8 +38,9 @@ Page({ list, }); }, - async submit() { - const values = await this.form.submit(); - console.log(values); + submit() { + this.form.submit().then(values => { + console.log(values); + }); }, }); diff --git a/compiled/alipay/demo/pages/FormImageUploadRules/index.js b/compiled/alipay/demo/pages/FormImageUploadRules/index.js index 814ba5fc0..8f45f66c6 100644 --- a/compiled/alipay/demo/pages/FormImageUploadRules/index.js +++ b/compiled/alipay/demo/pages/FormImageUploadRules/index.js @@ -19,7 +19,7 @@ Page({ message: '需要上传图片', }, () => ({ - async validator(_, fileList = []) { + validator(_, fileList = []) { if (fileList.length !== 3) { throw new Error('需要上传3张图片'); } @@ -38,12 +38,13 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); }); }, onUpload(localFile) { diff --git a/compiled/alipay/demo/pages/FormInitialValues/index.js b/compiled/alipay/demo/pages/FormInitialValues/index.js index a2a081c6d..cf6c828ef 100644 --- a/compiled/alipay/demo/pages/FormInitialValues/index.js +++ b/compiled/alipay/demo/pages/FormInitialValues/index.js @@ -16,12 +16,13 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); }); }, }); diff --git a/compiled/alipay/demo/pages/FormInitialValuesAsync/index.js b/compiled/alipay/demo/pages/FormInitialValuesAsync/index.js index c49e5d0e7..48f3834d1 100644 --- a/compiled/alipay/demo/pages/FormInitialValuesAsync/index.js +++ b/compiled/alipay/demo/pages/FormInitialValuesAsync/index.js @@ -22,12 +22,13 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); }); }, }); diff --git a/compiled/alipay/demo/pages/FormLayout/index.js b/compiled/alipay/demo/pages/FormLayout/index.js index e7c5cf664..4299614b1 100644 --- a/compiled/alipay/demo/pages/FormLayout/index.js +++ b/compiled/alipay/demo/pages/FormLayout/index.js @@ -17,12 +17,13 @@ Page({ position: this.data.position === 'horizontal' ? 'vertical' : 'horizontal', }); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); }); }, }); diff --git a/compiled/alipay/demo/pages/FormMultiple/index.js b/compiled/alipay/demo/pages/FormMultiple/index.js index 28d8e749b..9369b9aab 100644 --- a/compiled/alipay/demo/pages/FormMultiple/index.js +++ b/compiled/alipay/demo/pages/FormMultiple/index.js @@ -16,20 +16,22 @@ Page({ reset2() { this.form2.reset(); }, - async submit() { - const values = await this.form.submit(); - my.alert({ - title: '表单1提交', - content: JSON.stringify(values, null, 2), + submit() { + this.form.submit().then(values => { + my.alert({ + title: '表单1提交', + content: JSON.stringify(values, null, 2), + }); + console.log(values); }); - console.log(values); }, - async submit2() { - const values = await this.form2.submit(); - my.alert({ - title: '表单2提交', - content: JSON.stringify(values, null, 2), + submit2() { + this.form.submit().then(values => { + my.alert({ + title: '表单2提交', + content: JSON.stringify(values, null, 2), + }); + console.log(values); }); - console.log(values); }, }); diff --git a/compiled/alipay/demo/pages/FormRules/index.js b/compiled/alipay/demo/pages/FormRules/index.js index 6fb44bf4f..0e94fc595 100644 --- a/compiled/alipay/demo/pages/FormRules/index.js +++ b/compiled/alipay/demo/pages/FormRules/index.js @@ -15,7 +15,7 @@ Page({ message: '需要输入确认密码', }, (form) => ({ - async validator(_, value) { + validator(_, value) { if (!value || form.getFieldValue('password') === value) { return; } @@ -37,12 +37,13 @@ Page({ this.form.setFieldValue('password', '1234'); this.form.setFieldValue('confirm', '1234'); }, - async submit() { - const values = await this.form.submit(); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + console.log(values); }); - console.log(values); }, }); diff --git a/compiled/alipay/demo/pages/FormValidate/index.js b/compiled/alipay/demo/pages/FormValidate/index.js index 203e0b6d5..64f7517bd 100644 --- a/compiled/alipay/demo/pages/FormValidate/index.js +++ b/compiled/alipay/demo/pages/FormValidate/index.js @@ -19,11 +19,12 @@ Page({ }); }); }, - async submit() { - const values = await this.form.submit(); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); }); }, }); diff --git a/compiled/alipay/demo/pages/FormValidateMessages/index.js b/compiled/alipay/demo/pages/FormValidateMessages/index.js index 8ec676857..e6f9b9850 100644 --- a/compiled/alipay/demo/pages/FormValidateMessages/index.js +++ b/compiled/alipay/demo/pages/FormValidateMessages/index.js @@ -39,12 +39,13 @@ Page({ reset() { this.form.reset(); }, - async submit() { - const values = await this.form.submit(); - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); }); }, }); diff --git a/compiled/alipay/demo/pages/FormWatch/index.js b/compiled/alipay/demo/pages/FormWatch/index.js index 3d7cd8567..b642d8a23 100644 --- a/compiled/alipay/demo/pages/FormWatch/index.js +++ b/compiled/alipay/demo/pages/FormWatch/index.js @@ -35,12 +35,13 @@ Page({ allValuesText: '', }); }, - async submit() { - const values = await this.form.submit(); - my.alert({ - title: '提交', - content: JSON.stringify(values), + submit() { + this.form.submit().then(values => { + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); + console.log(values); }); - console.log(values); }, }); diff --git a/compiled/alipay/demo/pages/TabsElevator/index.js b/compiled/alipay/demo/pages/TabsElevator/index.js index c1608abd1..2d2d39ba7 100644 --- a/compiled/alipay/demo/pages/TabsElevator/index.js +++ b/compiled/alipay/demo/pages/TabsElevator/index.js @@ -33,8 +33,8 @@ Page({ this.itemRectList = await Promise.all(this.data.items.map((item, index) => this.getBoundingClientRect(`#tab-item-${index}`))); this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - async onReady() { - await this.updateRect(); + onReady() { + this.updateRect(); }, onTap() { this.tap = true; diff --git a/compiled/alipay/demo/pages/TabsSticky/index.js b/compiled/alipay/demo/pages/TabsSticky/index.js index d2c2b5d89..26b483de3 100644 --- a/compiled/alipay/demo/pages/TabsSticky/index.js +++ b/compiled/alipay/demo/pages/TabsSticky/index.js @@ -35,7 +35,7 @@ Page({ async onReady() { this.tabsTop = (await this.getBoundingClientRect('.tabs')).top; }, - async onChange(current) { + onChange(current) { this.setData({ current, }); diff --git a/compiled/alipay/demo/pages/TabsVerticalElevator/index.js b/compiled/alipay/demo/pages/TabsVerticalElevator/index.js index a5370c51b..b56eba644 100644 --- a/compiled/alipay/demo/pages/TabsVerticalElevator/index.js +++ b/compiled/alipay/demo/pages/TabsVerticalElevator/index.js @@ -13,8 +13,8 @@ Page({ this.itemRectList = await Promise.all(this.data.items.map((item, index) => this.getBoundingClientRect(`#tab-item-${index}`))); this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - async onReady() { - await this.updateRect(); + onReady() { + this.updateRect(); }, onChange(current) { this.tap = true; diff --git a/compiled/wechat/demo/pages/Form/index.js b/compiled/wechat/demo/pages/Form/index.js index dc8c57a9a..55f0dd7b7 100644 --- a/compiled/wechat/demo/pages/Form/index.js +++ b/compiled/wechat/demo/pages/Form/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; import cityList from './city'; Page({ @@ -83,17 +47,8 @@ Page({ this.form.reset(); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, showToast: function () { diff --git a/compiled/wechat/demo/pages/FormCustomError/index.js b/compiled/wechat/demo/pages/FormCustomError/index.js index 7e525ac1e..7a29925a1 100644 --- a/compiled/wechat/demo/pages/FormCustomError/index.js +++ b/compiled/wechat/demo/pages/FormCustomError/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -55,17 +19,8 @@ Page({ this.form.reset(); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/FormDependency/index.js b/compiled/wechat/demo/pages/FormDependency/index.js index 505b1adfc..300d1534c 100644 --- a/compiled/wechat/demo/pages/FormDependency/index.js +++ b/compiled/wechat/demo/pages/FormDependency/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -71,17 +35,8 @@ Page({ this.form.reset(); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/FormDynamic/index.js b/compiled/wechat/demo/pages/FormDynamic/index.js index 906aaf144..6cddab043 100644 --- a/compiled/wechat/demo/pages/FormDynamic/index.js +++ b/compiled/wechat/demo/pages/FormDynamic/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { @@ -97,17 +61,8 @@ Page({ }); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/FormImageUploadRules/index.js b/compiled/wechat/demo/pages/FormImageUploadRules/index.js index f8576aaf9..3f6c95eb2 100644 --- a/compiled/wechat/demo/pages/FormImageUploadRules/index.js +++ b/compiled/wechat/demo/pages/FormImageUploadRules/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ data: { @@ -58,17 +22,12 @@ Page({ function () { return ({ validator: function (_, fileList) { if (fileList === void 0) { fileList = []; } - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (fileList.length !== 3) { - throw new Error('需要上传3张图片'); - } - if (fileList.find(function (file) { return file.status !== 'done'; })) { - throw new Error('图片需要上传完成'); - } - return [2 /*return*/]; - }); - }); + if (fileList.length !== 3) { + throw new Error('需要上传3张图片'); + } + if (fileList.find(function (file) { return file.status !== 'done'; })) { + throw new Error('图片需要上传完成'); + } }, }); }, ], @@ -90,17 +49,8 @@ Page({ this.form.reset(); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, onUpload: function (localFile) { diff --git a/compiled/wechat/demo/pages/FormInitialValues/index.js b/compiled/wechat/demo/pages/FormInitialValues/index.js index d840f822c..deaeed5b1 100644 --- a/compiled/wechat/demo/pages/FormInitialValues/index.js +++ b/compiled/wechat/demo/pages/FormInitialValues/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -62,17 +26,8 @@ Page({ this.form.reset(); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js b/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js index 023cca183..ba58a227b 100644 --- a/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js +++ b/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -72,17 +36,8 @@ Page({ this.form.reset(); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/FormLayout/index.js b/compiled/wechat/demo/pages/FormLayout/index.js index e7b0e1a77..d347930f0 100644 --- a/compiled/wechat/demo/pages/FormLayout/index.js +++ b/compiled/wechat/demo/pages/FormLayout/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ data: { @@ -63,17 +27,8 @@ Page({ }); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/FormMultiple/index.js b/compiled/wechat/demo/pages/FormMultiple/index.js index 6d51a86e8..10a799aa9 100644 --- a/compiled/wechat/demo/pages/FormMultiple/index.js +++ b/compiled/wechat/demo/pages/FormMultiple/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -70,31 +34,13 @@ Page({ this.form2.reset(); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, submit2: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form2.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/FormRules/index.js b/compiled/wechat/demo/pages/FormRules/index.js index 08a5f7150..07716fc17 100644 --- a/compiled/wechat/demo/pages/FormRules/index.js +++ b/compiled/wechat/demo/pages/FormRules/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -53,14 +17,10 @@ Page({ }, function (form) { return ({ validator: function (_, value) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (!value || form.getFieldValue('password') === value) { - return [2 /*return*/]; - } - throw new Error('验证密码需要跟密码相同'); - }); - }); + if (!value || form.getFieldValue('password') === value) { + return; + } + throw new Error('验证密码需要跟密码相同'); }, }); }, ], @@ -87,17 +47,8 @@ Page({ this.form.setFieldValue('confirm', '1234'); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/FormValidate/index.js b/compiled/wechat/demo/pages/FormValidate/index.js index e78e0aa0e..956276ef6 100644 --- a/compiled/wechat/demo/pages/FormValidate/index.js +++ b/compiled/wechat/demo/pages/FormValidate/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -66,16 +30,7 @@ Page({ }); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { }); }, }); diff --git a/compiled/wechat/demo/pages/FormValidateMessages/index.js b/compiled/wechat/demo/pages/FormValidateMessages/index.js index 72b56ffcb..8f24cd7ac 100644 --- a/compiled/wechat/demo/pages/FormValidateMessages/index.js +++ b/compiled/wechat/demo/pages/FormValidateMessages/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; var validateMessages = { required: '需要输入${label}', @@ -85,17 +49,8 @@ Page({ this.form.reset(); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/FormWatch/index.js b/compiled/wechat/demo/pages/FormWatch/index.js index 7ecbb2bf9..acb391bc9 100644 --- a/compiled/wechat/demo/pages/FormWatch/index.js +++ b/compiled/wechat/demo/pages/FormWatch/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -82,17 +46,8 @@ Page({ }); }, submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); + this.form.submit().then(function (values) { + console.log(values); }); }, }); diff --git a/compiled/wechat/demo/pages/TabsElevator/index.js b/compiled/wechat/demo/pages/TabsElevator/index.js index a9c02a2fc..6dd8c4160 100644 --- a/compiled/wechat/demo/pages/TabsElevator/index.js +++ b/compiled/wechat/demo/pages/TabsElevator/index.js @@ -88,16 +88,7 @@ Page({ }); }, onReady: function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.updateRect()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); + this.updateRect(); }, onTap: function () { this.tap = true; diff --git a/compiled/wechat/demo/pages/TabsSticky/index.js b/compiled/wechat/demo/pages/TabsSticky/index.js index 44b85fd98..37000c6d4 100644 --- a/compiled/wechat/demo/pages/TabsSticky/index.js +++ b/compiled/wechat/demo/pages/TabsSticky/index.js @@ -84,16 +84,11 @@ Page({ }); }, onChange: function (current) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - current = current.detail; - this.setData({ - current: current, - }); - this.scrollTo(Math.min(this.tabsTop, this.pageScrollTop)); - return [2 /*return*/]; - }); + current = current.detail; + this.setData({ + current: current, }); + this.scrollTo(Math.min(this.tabsTop, this.pageScrollTop)); }, scrollTo: function (scrollTop) { if (typeof my === 'undefined') { diff --git a/compiled/wechat/demo/pages/TabsVerticalElevator/index.js b/compiled/wechat/demo/pages/TabsVerticalElevator/index.js index b76b5e23f..81d752511 100644 --- a/compiled/wechat/demo/pages/TabsVerticalElevator/index.js +++ b/compiled/wechat/demo/pages/TabsVerticalElevator/index.js @@ -68,16 +68,7 @@ Page({ }); }, onReady: function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.updateRect()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); + this.updateRect(); }, onChange: function (current) { current = current.detail; From 6b091a64bf251047f145a613cde51c72b524c6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=9D=89?= Date: Sun, 18 Feb 2024 18:51:40 +0800 Subject: [PATCH 3/5] Revert "demo: remove async" This reverts commit 0a25101991ca6982240d80a65051928f1e6b647c. --- demo/pages/Form/index.ts | 17 +++++------ demo/pages/FormCustom/index.ts | 13 ++++----- demo/pages/FormCustomError/index.ts | 17 +++++------ demo/pages/FormDependency/index.ts | 17 +++++------ demo/pages/FormDynamic/index.ts | 7 ++--- demo/pages/FormImageUploadRules/index.ts | 19 ++++++------ demo/pages/FormInitialValues/index.ts | 17 +++++------ demo/pages/FormInitialValuesAsync/index.ts | 17 +++++------ demo/pages/FormLayout/index.ts | 18 ++++++------ demo/pages/FormMultiple/index.ts | 34 ++++++++++------------ demo/pages/FormRules/index.ts | 21 +++++++------ demo/pages/FormValidate/index.ts | 16 +++++----- demo/pages/FormValidateMessages/index.ts | 17 +++++------ demo/pages/FormWatch/index.ts | 18 ++++++------ demo/pages/TabsElevator/index.ts | 4 +-- demo/pages/TabsSticky/index.ts | 2 +- demo/pages/TabsVerticalElevator/index.ts | 4 +-- 17 files changed, 123 insertions(+), 135 deletions(-) diff --git a/demo/pages/Form/index.ts b/demo/pages/Form/index.ts index c582125df..7bf67d987 100644 --- a/demo/pages/Form/index.ts +++ b/demo/pages/Form/index.ts @@ -58,16 +58,15 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values, null, 2), - }); - /// #endif - console.log(values); + async submit() { + const values = await this.form.submit(); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values, null, 2), }); + /// #endif + console.log(values); }, /// #if ALIPAY onUpload(localFile) { diff --git a/demo/pages/FormCustom/index.ts b/demo/pages/FormCustom/index.ts index c916b0e17..b3786ebc4 100644 --- a/demo/pages/FormCustom/index.ts +++ b/demo/pages/FormCustom/index.ts @@ -19,12 +19,11 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - }) + async submit() { + const values = await this.form.submit(); + my.alert({ + title: '提交', + content: JSON.stringify(values), + }); } }); diff --git a/demo/pages/FormCustomError/index.ts b/demo/pages/FormCustomError/index.ts index 7715829e2..a8cf01d93 100644 --- a/demo/pages/FormCustomError/index.ts +++ b/demo/pages/FormCustomError/index.ts @@ -26,15 +26,14 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif - console.log(values); + async submit() { + const values = await this.form.submit(); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif + console.log(values); }, }); diff --git a/demo/pages/FormDependency/index.ts b/demo/pages/FormDependency/index.ts index 8ef9ba1f2..8a1e21f86 100644 --- a/demo/pages/FormDependency/index.ts +++ b/demo/pages/FormDependency/index.ts @@ -48,15 +48,14 @@ Page({ }); this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif + async submit() { + const values = await this.form.submit(); + console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif }, }); diff --git a/demo/pages/FormDynamic/index.ts b/demo/pages/FormDynamic/index.ts index 5abb710f3..ea85b1095 100644 --- a/demo/pages/FormDynamic/index.ts +++ b/demo/pages/FormDynamic/index.ts @@ -59,9 +59,8 @@ Page({ list, }); }, - submit() { - this.form.submit().then(values => { - console.log(values); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/demo/pages/FormImageUploadRules/index.ts b/demo/pages/FormImageUploadRules/index.ts index 1c64f340b..07c94f378 100644 --- a/demo/pages/FormImageUploadRules/index.ts +++ b/demo/pages/FormImageUploadRules/index.ts @@ -22,7 +22,7 @@ Page({ message: '需要上传图片', }, () => ({ - validator(_, fileList = []) { + async validator(_, fileList = []) { if (fileList.length !== 3) { throw new Error('需要上传3张图片'); } @@ -57,16 +57,15 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif + async submit() { + const values = await this.form.submit(); + console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif }, onUpload(localFile) { return new Promise((resolve) => { diff --git a/demo/pages/FormInitialValues/index.ts b/demo/pages/FormInitialValues/index.ts index 491476c83..cfc88b643 100644 --- a/demo/pages/FormInitialValues/index.ts +++ b/demo/pages/FormInitialValues/index.ts @@ -34,15 +34,14 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif + async submit() { + const values = await this.form.submit(); + console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif }, }); diff --git a/demo/pages/FormInitialValuesAsync/index.ts b/demo/pages/FormInitialValuesAsync/index.ts index 4cd1c7035..3ae60426d 100644 --- a/demo/pages/FormInitialValuesAsync/index.ts +++ b/demo/pages/FormInitialValuesAsync/index.ts @@ -63,15 +63,14 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif + async submit() { + const values = await this.form.submit(); + console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif }, }); diff --git a/demo/pages/FormLayout/index.ts b/demo/pages/FormLayout/index.ts index 3fec4b1b6..0b65985d2 100644 --- a/demo/pages/FormLayout/index.ts +++ b/demo/pages/FormLayout/index.ts @@ -34,15 +34,15 @@ Page({ position: this.data.position === 'horizontal' ? 'vertical' : 'horizontal', }); }, - submit() { - this.form.submit().then(values => { - console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif + async submit() { + const values = await this.form.submit(); + console.log(values); + + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif }, }); diff --git a/demo/pages/FormMultiple/index.ts b/demo/pages/FormMultiple/index.ts index 0d1610753..1f882140d 100644 --- a/demo/pages/FormMultiple/index.ts +++ b/demo/pages/FormMultiple/index.ts @@ -48,26 +48,24 @@ Page({ reset2() { this.form2.reset(); }, - submit() { - this.form.submit().then(values => { - /// #if ALIPAY - my.alert({ - title: '表单1提交', - content: JSON.stringify(values, null, 2), - }); - /// #endif - console.log(values); + async submit() { + const values = await this.form.submit(); + /// #if ALIPAY + my.alert({ + title: '表单1提交', + content: JSON.stringify(values, null, 2), }); + /// #endif + console.log(values); }, - submit2() { - this.form.submit().then(values => { - /// #if ALIPAY - my.alert({ - title: '表单2提交', - content: JSON.stringify(values, null, 2), - }); - /// #endif - console.log(values); + async submit2() { + const values = await this.form2.submit(); + /// #if ALIPAY + my.alert({ + title: '表单2提交', + content: JSON.stringify(values, null, 2), }); + /// #endif + console.log(values); }, }); diff --git a/demo/pages/FormRules/index.ts b/demo/pages/FormRules/index.ts index ddbf15148..a8f2221e4 100644 --- a/demo/pages/FormRules/index.ts +++ b/demo/pages/FormRules/index.ts @@ -16,7 +16,7 @@ Page({ message: '需要输入确认密码', }, (form) => ({ - validator(_, value) { + async validator(_, value) { if (!value || form.getFieldValue('password') === value) { return; } @@ -54,17 +54,16 @@ Page({ this.form.setFieldValue('password', '1234'); this.form.setFieldValue('confirm', '1234'); }, - submit() { - this.form.submit().then(values => { + async submit() { + const values = await this.form.submit(); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif - - console.log(values); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif + + console.log(values); }, }); diff --git a/demo/pages/FormValidate/index.ts b/demo/pages/FormValidate/index.ts index 28a840221..eadd7d705 100644 --- a/demo/pages/FormValidate/index.ts +++ b/demo/pages/FormValidate/index.ts @@ -36,14 +36,14 @@ Page({ }); }); }, - submit() { - this.form.submit().then(values => { - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif + async submit() { + const values = await this.form.submit(); + + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif }, }); diff --git a/demo/pages/FormValidateMessages/index.ts b/demo/pages/FormValidateMessages/index.ts index 7005d3a96..6103feb7a 100644 --- a/demo/pages/FormValidateMessages/index.ts +++ b/demo/pages/FormValidateMessages/index.ts @@ -58,16 +58,15 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); + async submit() { + const values = await this.form.submit(); + console.log(values); - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif }, }); diff --git a/demo/pages/FormWatch/index.ts b/demo/pages/FormWatch/index.ts index 37b9799d2..a79513ced 100644 --- a/demo/pages/FormWatch/index.ts +++ b/demo/pages/FormWatch/index.ts @@ -53,15 +53,15 @@ Page({ allValuesText: '', }); }, - submit() { - this.form.submit().then(values => { - /// #if ALIPAY - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - /// #endif - console.log(values); + async submit() { + const values = await this.form.submit(); + /// #if ALIPAY + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + /// #endif + + console.log(values); }, }); diff --git a/demo/pages/TabsElevator/index.ts b/demo/pages/TabsElevator/index.ts index 542cf7101..dd65c287a 100644 --- a/demo/pages/TabsElevator/index.ts +++ b/demo/pages/TabsElevator/index.ts @@ -43,8 +43,8 @@ Page({ ); this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - onReady() { - this.updateRect(); + async onReady() { + await this.updateRect(); }, onTap() { this.tap = true; diff --git a/demo/pages/TabsSticky/index.ts b/demo/pages/TabsSticky/index.ts index 5cb65794d..95ef5503f 100644 --- a/demo/pages/TabsSticky/index.ts +++ b/demo/pages/TabsSticky/index.ts @@ -41,7 +41,7 @@ Page({ async onReady() { this.tabsTop = (await this.getBoundingClientRect('.tabs')).top; }, - onChange(current) { + async onChange(current) { /// #if WECHAT current = current.detail; /// #endif diff --git a/demo/pages/TabsVerticalElevator/index.ts b/demo/pages/TabsVerticalElevator/index.ts index 262888b9e..9a8bc5883 100644 --- a/demo/pages/TabsVerticalElevator/index.ts +++ b/demo/pages/TabsVerticalElevator/index.ts @@ -18,8 +18,8 @@ Page({ ); this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - onReady() { - this.updateRect(); + async onReady() { + await this.updateRect(); }, onChange(current) { /// #if WECHAT From 72109b85ade7e1d74ec9a232d3af870738c99f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=9D=89?= Date: Sun, 18 Feb 2024 18:51:47 +0800 Subject: [PATCH 4/5] Revert "demo: updated" This reverts commit c82e2154eea38867ffc26b8b38a64d4e9529222f. --- compiled/alipay/demo/pages/Form/index.js | 13 ++-- .../alipay/demo/pages/FormCustom/index.js | 11 ++-- .../demo/pages/FormCustomError/index.js | 13 ++-- .../alipay/demo/pages/FormDependency/index.js | 13 ++-- .../alipay/demo/pages/FormDynamic/index.js | 7 +- .../demo/pages/FormImageUploadRules/index.js | 15 ++--- .../demo/pages/FormInitialValues/index.js | 13 ++-- .../pages/FormInitialValuesAsync/index.js | 13 ++-- .../alipay/demo/pages/FormLayout/index.js | 13 ++-- .../alipay/demo/pages/FormMultiple/index.js | 26 ++++---- compiled/alipay/demo/pages/FormRules/index.js | 15 ++--- .../alipay/demo/pages/FormValidate/index.js | 11 ++-- .../demo/pages/FormValidateMessages/index.js | 13 ++-- compiled/alipay/demo/pages/FormWatch/index.js | 13 ++-- .../alipay/demo/pages/TabsElevator/index.js | 4 +- .../alipay/demo/pages/TabsSticky/index.js | 2 +- .../demo/pages/TabsVerticalElevator/index.js | 4 +- compiled/wechat/demo/pages/Form/index.js | 49 +++++++++++++- .../demo/pages/FormCustomError/index.js | 49 +++++++++++++- .../wechat/demo/pages/FormDependency/index.js | 49 +++++++++++++- .../wechat/demo/pages/FormDynamic/index.js | 49 +++++++++++++- .../demo/pages/FormImageUploadRules/index.js | 66 ++++++++++++++++--- .../demo/pages/FormInitialValues/index.js | 49 +++++++++++++- .../pages/FormInitialValuesAsync/index.js | 49 +++++++++++++- .../wechat/demo/pages/FormLayout/index.js | 49 +++++++++++++- .../wechat/demo/pages/FormMultiple/index.js | 62 +++++++++++++++-- compiled/wechat/demo/pages/FormRules/index.js | 61 +++++++++++++++-- .../wechat/demo/pages/FormValidate/index.js | 47 ++++++++++++- .../demo/pages/FormValidateMessages/index.js | 49 +++++++++++++- compiled/wechat/demo/pages/FormWatch/index.js | 49 +++++++++++++- .../wechat/demo/pages/TabsElevator/index.js | 11 +++- .../wechat/demo/pages/TabsSticky/index.js | 13 ++-- .../demo/pages/TabsVerticalElevator/index.js | 11 +++- 33 files changed, 761 insertions(+), 150 deletions(-) diff --git a/compiled/alipay/demo/pages/Form/index.js b/compiled/alipay/demo/pages/Form/index.js index 927fd8a4d..cc729ecdc 100644 --- a/compiled/alipay/demo/pages/Form/index.js +++ b/compiled/alipay/demo/pages/Form/index.js @@ -29,14 +29,13 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - my.alert({ - title: '提交', - content: JSON.stringify(values, null, 2), - }); - console.log(values); + async submit() { + const values = await this.form.submit(); + my.alert({ + title: '提交', + content: JSON.stringify(values, null, 2), }); + console.log(values); }, onUpload(localFile) { return new Promise((resolve) => { diff --git a/compiled/alipay/demo/pages/FormCustom/index.js b/compiled/alipay/demo/pages/FormCustom/index.js index 052e6ac6f..c48782535 100644 --- a/compiled/alipay/demo/pages/FormCustom/index.js +++ b/compiled/alipay/demo/pages/FormCustom/index.js @@ -17,12 +17,11 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); + async submit() { + const values = await this.form.submit(); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); } }); diff --git a/compiled/alipay/demo/pages/FormCustomError/index.js b/compiled/alipay/demo/pages/FormCustomError/index.js index 27965f830..898986ed6 100644 --- a/compiled/alipay/demo/pages/FormCustomError/index.js +++ b/compiled/alipay/demo/pages/FormCustomError/index.js @@ -9,13 +9,12 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - console.log(values); + async submit() { + const values = await this.form.submit(); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + console.log(values); }, }); diff --git a/compiled/alipay/demo/pages/FormDependency/index.js b/compiled/alipay/demo/pages/FormDependency/index.js index c25232295..203cc3be4 100644 --- a/compiled/alipay/demo/pages/FormDependency/index.js +++ b/compiled/alipay/demo/pages/FormDependency/index.js @@ -20,13 +20,12 @@ Page({ }); this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); + async submit() { + const values = await this.form.submit(); + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); }, }); diff --git a/compiled/alipay/demo/pages/FormDynamic/index.js b/compiled/alipay/demo/pages/FormDynamic/index.js index 9b681661c..fae818ec6 100644 --- a/compiled/alipay/demo/pages/FormDynamic/index.js +++ b/compiled/alipay/demo/pages/FormDynamic/index.js @@ -38,9 +38,8 @@ Page({ list, }); }, - submit() { - this.form.submit().then(values => { - console.log(values); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/alipay/demo/pages/FormImageUploadRules/index.js b/compiled/alipay/demo/pages/FormImageUploadRules/index.js index 8f45f66c6..814ba5fc0 100644 --- a/compiled/alipay/demo/pages/FormImageUploadRules/index.js +++ b/compiled/alipay/demo/pages/FormImageUploadRules/index.js @@ -19,7 +19,7 @@ Page({ message: '需要上传图片', }, () => ({ - validator(_, fileList = []) { + async validator(_, fileList = []) { if (fileList.length !== 3) { throw new Error('需要上传3张图片'); } @@ -38,13 +38,12 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); + async submit() { + const values = await this.form.submit(); + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); }, onUpload(localFile) { diff --git a/compiled/alipay/demo/pages/FormInitialValues/index.js b/compiled/alipay/demo/pages/FormInitialValues/index.js index cf6c828ef..a2a081c6d 100644 --- a/compiled/alipay/demo/pages/FormInitialValues/index.js +++ b/compiled/alipay/demo/pages/FormInitialValues/index.js @@ -16,13 +16,12 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); + async submit() { + const values = await this.form.submit(); + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); }, }); diff --git a/compiled/alipay/demo/pages/FormInitialValuesAsync/index.js b/compiled/alipay/demo/pages/FormInitialValuesAsync/index.js index 48f3834d1..c49e5d0e7 100644 --- a/compiled/alipay/demo/pages/FormInitialValuesAsync/index.js +++ b/compiled/alipay/demo/pages/FormInitialValuesAsync/index.js @@ -22,13 +22,12 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); + async submit() { + const values = await this.form.submit(); + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); }, }); diff --git a/compiled/alipay/demo/pages/FormLayout/index.js b/compiled/alipay/demo/pages/FormLayout/index.js index 4299614b1..e7c5cf664 100644 --- a/compiled/alipay/demo/pages/FormLayout/index.js +++ b/compiled/alipay/demo/pages/FormLayout/index.js @@ -17,13 +17,12 @@ Page({ position: this.data.position === 'horizontal' ? 'vertical' : 'horizontal', }); }, - submit() { - this.form.submit().then(values => { - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); + async submit() { + const values = await this.form.submit(); + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); }, }); diff --git a/compiled/alipay/demo/pages/FormMultiple/index.js b/compiled/alipay/demo/pages/FormMultiple/index.js index 9369b9aab..28d8e749b 100644 --- a/compiled/alipay/demo/pages/FormMultiple/index.js +++ b/compiled/alipay/demo/pages/FormMultiple/index.js @@ -16,22 +16,20 @@ Page({ reset2() { this.form2.reset(); }, - submit() { - this.form.submit().then(values => { - my.alert({ - title: '表单1提交', - content: JSON.stringify(values, null, 2), - }); - console.log(values); + async submit() { + const values = await this.form.submit(); + my.alert({ + title: '表单1提交', + content: JSON.stringify(values, null, 2), }); + console.log(values); }, - submit2() { - this.form.submit().then(values => { - my.alert({ - title: '表单2提交', - content: JSON.stringify(values, null, 2), - }); - console.log(values); + async submit2() { + const values = await this.form2.submit(); + my.alert({ + title: '表单2提交', + content: JSON.stringify(values, null, 2), }); + console.log(values); }, }); diff --git a/compiled/alipay/demo/pages/FormRules/index.js b/compiled/alipay/demo/pages/FormRules/index.js index 0e94fc595..6fb44bf4f 100644 --- a/compiled/alipay/demo/pages/FormRules/index.js +++ b/compiled/alipay/demo/pages/FormRules/index.js @@ -15,7 +15,7 @@ Page({ message: '需要输入确认密码', }, (form) => ({ - validator(_, value) { + async validator(_, value) { if (!value || form.getFieldValue('password') === value) { return; } @@ -37,13 +37,12 @@ Page({ this.form.setFieldValue('password', '1234'); this.form.setFieldValue('confirm', '1234'); }, - submit() { - this.form.submit().then(values => { - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - console.log(values); + async submit() { + const values = await this.form.submit(); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + console.log(values); }, }); diff --git a/compiled/alipay/demo/pages/FormValidate/index.js b/compiled/alipay/demo/pages/FormValidate/index.js index 64f7517bd..203e0b6d5 100644 --- a/compiled/alipay/demo/pages/FormValidate/index.js +++ b/compiled/alipay/demo/pages/FormValidate/index.js @@ -19,12 +19,11 @@ Page({ }); }); }, - submit() { - this.form.submit().then(values => { - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); + async submit() { + const values = await this.form.submit(); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); }, }); diff --git a/compiled/alipay/demo/pages/FormValidateMessages/index.js b/compiled/alipay/demo/pages/FormValidateMessages/index.js index e6f9b9850..8ec676857 100644 --- a/compiled/alipay/demo/pages/FormValidateMessages/index.js +++ b/compiled/alipay/demo/pages/FormValidateMessages/index.js @@ -39,13 +39,12 @@ Page({ reset() { this.form.reset(); }, - submit() { - this.form.submit().then(values => { - console.log(values); - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); + async submit() { + const values = await this.form.submit(); + console.log(values); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); }, }); diff --git a/compiled/alipay/demo/pages/FormWatch/index.js b/compiled/alipay/demo/pages/FormWatch/index.js index b642d8a23..3d7cd8567 100644 --- a/compiled/alipay/demo/pages/FormWatch/index.js +++ b/compiled/alipay/demo/pages/FormWatch/index.js @@ -35,13 +35,12 @@ Page({ allValuesText: '', }); }, - submit() { - this.form.submit().then(values => { - my.alert({ - title: '提交', - content: JSON.stringify(values), - }); - console.log(values); + async submit() { + const values = await this.form.submit(); + my.alert({ + title: '提交', + content: JSON.stringify(values), }); + console.log(values); }, }); diff --git a/compiled/alipay/demo/pages/TabsElevator/index.js b/compiled/alipay/demo/pages/TabsElevator/index.js index 2d2d39ba7..c1608abd1 100644 --- a/compiled/alipay/demo/pages/TabsElevator/index.js +++ b/compiled/alipay/demo/pages/TabsElevator/index.js @@ -33,8 +33,8 @@ Page({ this.itemRectList = await Promise.all(this.data.items.map((item, index) => this.getBoundingClientRect(`#tab-item-${index}`))); this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - onReady() { - this.updateRect(); + async onReady() { + await this.updateRect(); }, onTap() { this.tap = true; diff --git a/compiled/alipay/demo/pages/TabsSticky/index.js b/compiled/alipay/demo/pages/TabsSticky/index.js index 26b483de3..d2c2b5d89 100644 --- a/compiled/alipay/demo/pages/TabsSticky/index.js +++ b/compiled/alipay/demo/pages/TabsSticky/index.js @@ -35,7 +35,7 @@ Page({ async onReady() { this.tabsTop = (await this.getBoundingClientRect('.tabs')).top; }, - onChange(current) { + async onChange(current) { this.setData({ current, }); diff --git a/compiled/alipay/demo/pages/TabsVerticalElevator/index.js b/compiled/alipay/demo/pages/TabsVerticalElevator/index.js index b56eba644..a5370c51b 100644 --- a/compiled/alipay/demo/pages/TabsVerticalElevator/index.js +++ b/compiled/alipay/demo/pages/TabsVerticalElevator/index.js @@ -13,8 +13,8 @@ Page({ this.itemRectList = await Promise.all(this.data.items.map((item, index) => this.getBoundingClientRect(`#tab-item-${index}`))); this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - onReady() { - this.updateRect(); + async onReady() { + await this.updateRect(); }, onChange(current) { this.tap = true; diff --git a/compiled/wechat/demo/pages/Form/index.js b/compiled/wechat/demo/pages/Form/index.js index 55f0dd7b7..dc8c57a9a 100644 --- a/compiled/wechat/demo/pages/Form/index.js +++ b/compiled/wechat/demo/pages/Form/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; import cityList from './city'; Page({ @@ -47,8 +83,17 @@ Page({ this.form.reset(); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, showToast: function () { diff --git a/compiled/wechat/demo/pages/FormCustomError/index.js b/compiled/wechat/demo/pages/FormCustomError/index.js index 7a29925a1..7e525ac1e 100644 --- a/compiled/wechat/demo/pages/FormCustomError/index.js +++ b/compiled/wechat/demo/pages/FormCustomError/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -19,8 +55,17 @@ Page({ this.form.reset(); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormDependency/index.js b/compiled/wechat/demo/pages/FormDependency/index.js index 300d1534c..505b1adfc 100644 --- a/compiled/wechat/demo/pages/FormDependency/index.js +++ b/compiled/wechat/demo/pages/FormDependency/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -35,8 +71,17 @@ Page({ this.form.reset(); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormDynamic/index.js b/compiled/wechat/demo/pages/FormDynamic/index.js index 6cddab043..906aaf144 100644 --- a/compiled/wechat/demo/pages/FormDynamic/index.js +++ b/compiled/wechat/demo/pages/FormDynamic/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { @@ -61,8 +97,17 @@ Page({ }); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormImageUploadRules/index.js b/compiled/wechat/demo/pages/FormImageUploadRules/index.js index 3f6c95eb2..f8576aaf9 100644 --- a/compiled/wechat/demo/pages/FormImageUploadRules/index.js +++ b/compiled/wechat/demo/pages/FormImageUploadRules/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ data: { @@ -22,12 +58,17 @@ Page({ function () { return ({ validator: function (_, fileList) { if (fileList === void 0) { fileList = []; } - if (fileList.length !== 3) { - throw new Error('需要上传3张图片'); - } - if (fileList.find(function (file) { return file.status !== 'done'; })) { - throw new Error('图片需要上传完成'); - } + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + if (fileList.length !== 3) { + throw new Error('需要上传3张图片'); + } + if (fileList.find(function (file) { return file.status !== 'done'; })) { + throw new Error('图片需要上传完成'); + } + return [2 /*return*/]; + }); + }); }, }); }, ], @@ -49,8 +90,17 @@ Page({ this.form.reset(); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, onUpload: function (localFile) { diff --git a/compiled/wechat/demo/pages/FormInitialValues/index.js b/compiled/wechat/demo/pages/FormInitialValues/index.js index deaeed5b1..d840f822c 100644 --- a/compiled/wechat/demo/pages/FormInitialValues/index.js +++ b/compiled/wechat/demo/pages/FormInitialValues/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -26,8 +62,17 @@ Page({ this.form.reset(); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js b/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js index ba58a227b..023cca183 100644 --- a/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js +++ b/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -36,8 +72,17 @@ Page({ this.form.reset(); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormLayout/index.js b/compiled/wechat/demo/pages/FormLayout/index.js index d347930f0..e7b0e1a77 100644 --- a/compiled/wechat/demo/pages/FormLayout/index.js +++ b/compiled/wechat/demo/pages/FormLayout/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ data: { @@ -27,8 +63,17 @@ Page({ }); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormMultiple/index.js b/compiled/wechat/demo/pages/FormMultiple/index.js index 10a799aa9..6d51a86e8 100644 --- a/compiled/wechat/demo/pages/FormMultiple/index.js +++ b/compiled/wechat/demo/pages/FormMultiple/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -34,13 +70,31 @@ Page({ this.form2.reset(); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, submit2: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form2.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormRules/index.js b/compiled/wechat/demo/pages/FormRules/index.js index 07716fc17..08a5f7150 100644 --- a/compiled/wechat/demo/pages/FormRules/index.js +++ b/compiled/wechat/demo/pages/FormRules/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -17,10 +53,14 @@ Page({ }, function (form) { return ({ validator: function (_, value) { - if (!value || form.getFieldValue('password') === value) { - return; - } - throw new Error('验证密码需要跟密码相同'); + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + if (!value || form.getFieldValue('password') === value) { + return [2 /*return*/]; + } + throw new Error('验证密码需要跟密码相同'); + }); + }); }, }); }, ], @@ -47,8 +87,17 @@ Page({ this.form.setFieldValue('confirm', '1234'); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormValidate/index.js b/compiled/wechat/demo/pages/FormValidate/index.js index 956276ef6..e78e0aa0e 100644 --- a/compiled/wechat/demo/pages/FormValidate/index.js +++ b/compiled/wechat/demo/pages/FormValidate/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -30,7 +66,16 @@ Page({ }); }, submit: function () { - this.form.submit().then(function (values) { + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormValidateMessages/index.js b/compiled/wechat/demo/pages/FormValidateMessages/index.js index 8f24cd7ac..72b56ffcb 100644 --- a/compiled/wechat/demo/pages/FormValidateMessages/index.js +++ b/compiled/wechat/demo/pages/FormValidateMessages/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; var validateMessages = { required: '需要输入${label}', @@ -49,8 +85,17 @@ Page({ this.form.reset(); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/FormWatch/index.js b/compiled/wechat/demo/pages/FormWatch/index.js index acb391bc9..7ecbb2bf9 100644 --- a/compiled/wechat/demo/pages/FormWatch/index.js +++ b/compiled/wechat/demo/pages/FormWatch/index.js @@ -1,3 +1,39 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; import { Form } from '../../../src/Form/form'; Page({ onLoad: function () { @@ -46,8 +82,17 @@ Page({ }); }, submit: function () { - this.form.submit().then(function (values) { - console.log(values); + return __awaiter(this, void 0, void 0, function () { + var values; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.form.submit()]; + case 1: + values = _a.sent(); + console.log(values); + return [2 /*return*/]; + } + }); }); }, }); diff --git a/compiled/wechat/demo/pages/TabsElevator/index.js b/compiled/wechat/demo/pages/TabsElevator/index.js index 6dd8c4160..a9c02a2fc 100644 --- a/compiled/wechat/demo/pages/TabsElevator/index.js +++ b/compiled/wechat/demo/pages/TabsElevator/index.js @@ -88,7 +88,16 @@ Page({ }); }, onReady: function () { - this.updateRect(); + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.updateRect()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }, onTap: function () { this.tap = true; diff --git a/compiled/wechat/demo/pages/TabsSticky/index.js b/compiled/wechat/demo/pages/TabsSticky/index.js index 37000c6d4..44b85fd98 100644 --- a/compiled/wechat/demo/pages/TabsSticky/index.js +++ b/compiled/wechat/demo/pages/TabsSticky/index.js @@ -84,11 +84,16 @@ Page({ }); }, onChange: function (current) { - current = current.detail; - this.setData({ - current: current, + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + current = current.detail; + this.setData({ + current: current, + }); + this.scrollTo(Math.min(this.tabsTop, this.pageScrollTop)); + return [2 /*return*/]; + }); }); - this.scrollTo(Math.min(this.tabsTop, this.pageScrollTop)); }, scrollTo: function (scrollTop) { if (typeof my === 'undefined') { diff --git a/compiled/wechat/demo/pages/TabsVerticalElevator/index.js b/compiled/wechat/demo/pages/TabsVerticalElevator/index.js index 81d752511..b76b5e23f 100644 --- a/compiled/wechat/demo/pages/TabsVerticalElevator/index.js +++ b/compiled/wechat/demo/pages/TabsVerticalElevator/index.js @@ -68,7 +68,16 @@ Page({ }); }, onReady: function () { - this.updateRect(); + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.updateRect()]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }, onChange: function (current) { current = current.detail; From 2aaf5b6673c4364af062d8ad6010269c5f9f4875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=9D=89?= Date: Sun, 18 Feb 2024 18:54:57 +0800 Subject: [PATCH 5/5] fix: use different tsconfig --- .../wechat/demo/pages/ActionSheet/index.js | 28 +++--- compiled/wechat/demo/pages/Button/index.js | 2 +- .../wechat/demo/pages/ButtonCustom/index.js | 2 +- .../wechat/demo/pages/ButtonInline/index.js | 2 +- .../collapse-container/cn-day/cn-day.js | 6 +- .../collapse-container/collapse-container.js | 10 +- compiled/wechat/demo/pages/Calendar/index.js | 40 ++++---- .../wechat/demo/pages/CascaderPicker/index.js | 14 +-- compiled/wechat/demo/pages/Checkbox/index.js | 6 +- .../demo/pages/CheckboxCustomGroup/index.js | 10 +- .../wechat/demo/pages/CheckboxGroup/index.js | 4 +- compiled/wechat/demo/pages/Checklist/index.js | 4 +- compiled/wechat/demo/pages/Collapse/index.js | 2 +- .../demo/pages/CollapseAccordion/index.js | 2 +- .../demo/pages/CollapseControl/index.js | 37 +++---- .../demo/pages/CollapseWithCheckbox/index.js | 25 ++--- .../wechat/demo/pages/DatePicker/index.js | 22 ++--- compiled/wechat/demo/pages/Form/index.js | 75 +++----------- .../demo/pages/FormCustomError/index.js | 63 ++---------- .../wechat/demo/pages/FormDependency/index.js | 65 ++---------- .../wechat/demo/pages/FormDynamic/index.js | 95 ++++-------------- .../demo/pages/FormImageUploadRules/index.js | 99 +++++-------------- .../demo/pages/FormInitialValues/index.js | 63 ++---------- .../pages/FormInitialValuesAsync/index.js | 69 +++---------- .../wechat/demo/pages/FormLayout/index.js | 65 ++---------- .../wechat/demo/pages/FormMultiple/index.js | 87 +++------------- compiled/wechat/demo/pages/FormRules/index.js | 83 +++------------- .../wechat/demo/pages/FormValidate/index.js | 70 +++---------- .../demo/pages/FormValidateMessages/index.js | 67 ++----------- compiled/wechat/demo/pages/FormWatch/index.js | 90 ++++------------- compiled/wechat/demo/pages/Grid/index.js | 4 +- compiled/wechat/demo/pages/GuideTour/index.js | 17 ++-- compiled/wechat/demo/pages/Icon/index.js | 2 +- .../wechat/demo/pages/ImageUpload/index.js | 18 ++-- .../demo/pages/ImageUploadControl/index.js | 12 +-- compiled/wechat/demo/pages/Input/index.js | 12 +-- .../wechat/demo/pages/InputCustom/index.js | 14 +-- .../wechat/demo/pages/InputSearchBar/index.js | 4 +- .../wechat/demo/pages/InputTextarea/index.js | 12 +-- compiled/wechat/demo/pages/List/index.js | 4 +- compiled/wechat/demo/pages/Modal/index.js | 17 ++-- compiled/wechat/demo/pages/NoticeBar/index.js | 8 +- .../wechat/demo/pages/NumberKeyboard/index.js | 16 +-- .../demo/pages/NumberKeyboardAmount/index.js | 10 +- .../demo/pages/NumberKeyboardCode/index.js | 6 +- .../demo/pages/NumberKeyboardNumber/index.js | 6 +- compiled/wechat/demo/pages/Picker/index.js | 26 ++--- compiled/wechat/demo/pages/Popover/index.js | 4 +- .../wechat/demo/pages/PopoverList/index.js | 4 +- compiled/wechat/demo/pages/Popup/index.js | 14 +-- .../wechat/demo/pages/ProgressCircle/index.js | 20 ++-- .../wechat/demo/pages/ProgressLine/index.js | 16 +-- compiled/wechat/demo/pages/Radio/index.js | 4 +- .../wechat/demo/pages/RadioGroup/index.js | 4 +- .../demo/pages/RareWordsKeyboard/index.js | 22 ++--- compiled/wechat/demo/pages/Rate/index.js | 4 +- .../wechat/demo/pages/RateCustom/index.js | 2 +- compiled/wechat/demo/pages/Result/index.js | 4 +- compiled/wechat/demo/pages/Selector/index.js | 8 +- .../wechat/demo/pages/SelectorFilter/index.js | 10 +- compiled/wechat/demo/pages/Skeleton/index.js | 2 +- compiled/wechat/demo/pages/Slider/index.js | 8 +- compiled/wechat/demo/pages/Stepper/index.js | 20 ++-- .../wechat/demo/pages/StepsControl/index.js | 20 ++-- .../wechat/demo/pages/SwipeAction/index.js | 10 +- .../demo/pages/SwipeActionAnimation/index.js | 10 +- .../demo/pages/SwipeActionLeft/index.js | 10 +- .../demo/pages/SwipeActionLeftRight/index.js | 10 +- .../demo/pages/SwipeActionMove/index.js | 10 +- .../demo/pages/SwipeActionNumber/index.js | 10 +- .../demo/pages/SwipeActionSpeed/index.js | 10 +- .../wechat/demo/pages/SwipeActionTap/index.js | 10 +- .../demo/pages/SwipeActionWidth/index.js | 10 +- compiled/wechat/demo/pages/Switch/index.js | 6 +- compiled/wechat/demo/pages/TabBar/index.js | 2 +- compiled/wechat/demo/pages/Tabs/index.js | 10 +- .../wechat/demo/pages/TabsControl/index.js | 51 ++++------ .../wechat/demo/pages/TabsElevator/index.js | 99 ++++--------------- .../wechat/demo/pages/TabsScroll/index.js | 8 +- .../wechat/demo/pages/TabsSticky/index.js | 83 +++------------- .../wechat/demo/pages/TabsSwiper/index.js | 6 +- .../wechat/demo/pages/TabsVertical/index.js | 16 +-- .../demo/pages/TabsVerticalElevator/index.js | 99 ++++--------------- compiled/wechat/demo/pages/Toast/index.js | 22 ++--- compiled/wechat/demo/pages/index/index.js | 18 ++-- compiled/wechat/demo/utils/constants.js | 13 +-- scripts/mini-compiler.ts | 2 +- tsconfig.wechat.demo.json | 7 ++ 88 files changed, 615 insertions(+), 1478 deletions(-) create mode 100644 tsconfig.wechat.demo.json diff --git a/compiled/wechat/demo/pages/ActionSheet/index.js b/compiled/wechat/demo/pages/ActionSheet/index.js index fb850c98e..940576449 100644 --- a/compiled/wechat/demo/pages/ActionSheet/index.js +++ b/compiled/wechat/demo/pages/ActionSheet/index.js @@ -50,25 +50,23 @@ Page({ }, ], }, - handleOpenBasic: function (e) { - var _a; - var index = e.currentTarget.dataset.index; - this.setData((_a = {}, - _a["visible".concat(index)] = true, - _a)); + handleOpenBasic(e) { + const { index } = e.currentTarget.dataset; + this.setData({ + [`visible${index}`]: true, + }); }, - handleCloseBasic: function (e) { - var _a; - var index = e.currentTarget.dataset.index; - this.setData((_a = {}, - _a["visible".concat(index)] = false, - _a)); + handleCloseBasic(e) { + const { index } = e.currentTarget.dataset; + this.setData({ + [`visible${index}`]: false, + }); }, - handleAction: function (item, index, e) { - var _a = item.detail, clickItem = _a[0], clickIndex = _a[1]; + handleAction(item, index, e) { + const [clickItem, clickIndex] = item.detail; //@ts-ignore wx.showToast({ - title: "\u4F60\u70B9\u51FB\u4E86".concat(clickItem.key, "(").concat(clickIndex, ")"), + title: `你点击了${clickItem.key}(${clickIndex})`, }); }, }); diff --git a/compiled/wechat/demo/pages/Button/index.js b/compiled/wechat/demo/pages/Button/index.js index 8015a304c..93c8a5e7b 100644 --- a/compiled/wechat/demo/pages/Button/index.js +++ b/compiled/wechat/demo/pages/Button/index.js @@ -1,5 +1,5 @@ Page({ - handleTap: function (e) { + handleTap(e) { //@ts-ignore wx.showToast({ title: '点击按钮', diff --git a/compiled/wechat/demo/pages/ButtonCustom/index.js b/compiled/wechat/demo/pages/ButtonCustom/index.js index 3039b6250..e5400dba4 100644 --- a/compiled/wechat/demo/pages/ButtonCustom/index.js +++ b/compiled/wechat/demo/pages/ButtonCustom/index.js @@ -1,5 +1,5 @@ Page({ - handleTap: function (e) { + handleTap(e) { console.log(e); }, }); diff --git a/compiled/wechat/demo/pages/ButtonInline/index.js b/compiled/wechat/demo/pages/ButtonInline/index.js index 80bf3c268..6a4c2d0ef 100644 --- a/compiled/wechat/demo/pages/ButtonInline/index.js +++ b/compiled/wechat/demo/pages/ButtonInline/index.js @@ -1,5 +1,5 @@ Page({ - handleTap: function (e) { + handleTap(e) { console.log(e); my.alert({ title: '点击按钮' diff --git a/compiled/wechat/demo/pages/Calendar/collapse-container/cn-day/cn-day.js b/compiled/wechat/demo/pages/Calendar/collapse-container/cn-day/cn-day.js index 86aae593f..a68de7a51 100644 --- a/compiled/wechat/demo/pages/Calendar/collapse-container/cn-day/cn-day.js +++ b/compiled/wechat/demo/pages/Calendar/collapse-container/cn-day/cn-day.js @@ -1,10 +1,10 @@ import dayjs from 'dayjs'; import Converter from './js-calendar-converter'; import { mountComponent } from '../../../../../src/_util/component'; -var CollapseContainer = function (props) { +const CollapseContainer = (props) => { var _a, _b, _c; - var time = dayjs((_a = props.cell) === null || _a === void 0 ? void 0 : _a.time); - var vs = Converter.solar2lunar(time.get('year'), time.get('month') + 1, time.get('date')); + const time = dayjs((_a = props.cell) === null || _a === void 0 ? void 0 : _a.time); + const vs = Converter.solar2lunar(time.get('year'), time.get('month') + 1, time.get('date')); if (vs === -1) { return { cnday: '', diff --git a/compiled/wechat/demo/pages/Calendar/collapse-container/collapse-container.js b/compiled/wechat/demo/pages/Calendar/collapse-container/collapse-container.js index 249f0fb51..eb2ee114b 100644 --- a/compiled/wechat/demo/pages/Calendar/collapse-container/collapse-container.js +++ b/compiled/wechat/demo/pages/Calendar/collapse-container/collapse-container.js @@ -1,13 +1,13 @@ import { useEvent, useState } from 'functional-mini/component'; import { mountComponent } from '../../../../src/_util/component'; -var CollapseContainer = function (props) { +const CollapseContainer = (props) => { var _a; - var _b = useState((_a = props.defaultCollapse) !== null && _a !== void 0 ? _a : true), collapse = _b[0], setCollapse = _b[1]; - useEvent('handleToggle', function () { - setCollapse(function (v) { return !v; }); + const [collapse, setCollapse] = useState((_a = props.defaultCollapse) !== null && _a !== void 0 ? _a : true); + useEvent('handleToggle', () => { + setCollapse((v) => !v); }); return { - collapse: collapse, + collapse, internalHide: props.hide, containerTitle: props.title, }; diff --git a/compiled/wechat/demo/pages/Calendar/index.js b/compiled/wechat/demo/pages/Calendar/index.js index 6d02b67a9..12debc100 100644 --- a/compiled/wechat/demo/pages/Calendar/index.js +++ b/compiled/wechat/demo/pages/Calendar/index.js @@ -1,5 +1,5 @@ import dayjs from 'dayjs'; -var localeText = { +const localeText = { weekdayNames: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], title: 'YYYY/MM', today: 'Today', @@ -8,10 +8,10 @@ var localeText = { startAndEnd: 'Start/End', }; function demo8Formatter(cell) { - var isOdd = dayjs(cell.time).date() % 2 === 1; - var isNotBeginEnd = !cell.isSelectedBegin && !cell.isSelectedEnd; - var isWeekend = dayjs(cell.time).day() > 4; - var topClassName; + const isOdd = dayjs(cell.time).date() % 2 === 1; + const isNotBeginEnd = !cell.isSelectedBegin && !cell.isSelectedEnd; + const isWeekend = dayjs(cell.time).day() > 4; + let topClassName; if (isNotBeginEnd) { topClassName = isOdd ? 'odd' : 'even'; } @@ -27,7 +27,7 @@ function demo8Formatter(cell) { } function demoFormatter(cell, value) { if (Array.isArray(value) && value.length == 1) { - var current = value[0]; + const current = value[0]; return { disabled: dayjs(cell.time).diff(dayjs(current), 'days') > 3, bottom: dayjs(cell.time).diff(dayjs(current), 'days') > 3 @@ -65,7 +65,7 @@ Page({ visible: true, }, demo7: { - localeText: localeText, + localeText, visible: true, monthRange: [new Date().getTime(), new Date().getTime()], }, @@ -73,43 +73,43 @@ Page({ visible: true, monthRange: [new Date().getTime(), new Date().getTime()], }, - demoFormatter: demoFormatter, - demo8Formatter: demo8Formatter, + demoFormatter, + demo8Formatter, demo9: { visible: true, value: Date.now(), monthRange: [new Date().getTime(), new Date().getTime()], }, }, - demo3NextMonth: function () { - var current = this.data.demo3.monthRange[0]; - var newMonth = dayjs(current).add(1, 'month').toDate().getTime(); + demo3NextMonth() { + const current = this.data.demo3.monthRange[0]; + const newMonth = dayjs(current).add(1, 'month').toDate().getTime(); this.setData({ 'demo3.title': dayjs(newMonth).format('YYYY年MM月'), 'demo3.monthRange': [newMonth, newMonth], }); }, - demo3PreviousMonth: function () { - var current = this.data.demo3.monthRange[0]; - var newMonth = dayjs(current).add(-1, 'month').toDate().getTime(); + demo3PreviousMonth() { + const current = this.data.demo3.monthRange[0]; + const newMonth = dayjs(current).add(-1, 'month').toDate().getTime(); this.setData({ 'demo3.title': dayjs(newMonth).format('YYYY年MM月'), 'demo3.monthRange': [newMonth, newMonth], }); }, - demoFormatter: demoFormatter, - demo8Formatter: demo8Formatter, - demo9HandleChange: function (value) { + demoFormatter, + demo8Formatter, + demo9HandleChange(value) { this.setData({ 'demo9.value': value.detail, }); }, - demo9HandlePreviousDay: function () { + demo9HandlePreviousDay() { this.setData({ 'demo9.value': this.data.demo9.value - 1000 * 24 * 3600, }); }, - demo9HandleNextDay: function () { + demo9HandleNextDay() { this.setData({ 'demo9.value': this.data.demo9.value + 1000 * 24 * 3600, }); diff --git a/compiled/wechat/demo/pages/CascaderPicker/index.js b/compiled/wechat/demo/pages/CascaderPicker/index.js index df78b3e96..0ff21bacb 100644 --- a/compiled/wechat/demo/pages/CascaderPicker/index.js +++ b/compiled/wechat/demo/pages/CascaderPicker/index.js @@ -1,26 +1,26 @@ import cityList from './city'; Page({ data: { - cityList: cityList, + cityList, value: ['34', '330'], }, - handleCityPickerChange: function (value, selectedOption, e) { + handleCityPickerChange(value, selectedOption, e) { console.log('cityChange', value, selectedOption, e); }, - handleCityOnOk: function (value, selectedOption, e) { + handleCityOnOk(value, selectedOption, e) { console.log('cityOk', value, selectedOption, e); }, - handleOk: function (value, selectedOption, e) { + handleOk(value, selectedOption, e) { this.setData({ value: value.detail[0] }); console.log('cityOk', value, selectedOption, e); }, - handleChangeControlled: function () { + handleChangeControlled() { this.setData({ value: ['31', '310'] }); }, - handleClearControlled: function () { + handleClearControlled() { this.setData({ value: [] }); }, - handleDismiss: function (e) { + handleDismiss(e) { console.log('handleDismiss', e); }, }); diff --git a/compiled/wechat/demo/pages/Checkbox/index.js b/compiled/wechat/demo/pages/Checkbox/index.js index f0d296c42..95d66b981 100644 --- a/compiled/wechat/demo/pages/Checkbox/index.js +++ b/compiled/wechat/demo/pages/Checkbox/index.js @@ -2,15 +2,15 @@ Page({ data: { checked: false, }, - onChange: function (value, e) { + onChange(value, e) { console.log(value, e); }, - handleChange: function (checked) { + handleChange(checked) { this.setData({ checked: checked.detail, }); }, - toggleChange: function () { + toggleChange() { this.setData({ checked: !this.data.checked, }); diff --git a/compiled/wechat/demo/pages/CheckboxCustomGroup/index.js b/compiled/wechat/demo/pages/CheckboxCustomGroup/index.js index 90bb7cc55..483df2a42 100644 --- a/compiled/wechat/demo/pages/CheckboxCustomGroup/index.js +++ b/compiled/wechat/demo/pages/CheckboxCustomGroup/index.js @@ -38,16 +38,16 @@ Page({ ], value: [], }, - onChange: function (checked, e) { - var value = this.data.value; - var event = checked; + onChange(checked, e) { + let value = this.data.value; + const event = checked; if (event.detail) { value = value.concat(event.target.dataset.value); } else { - value = value.filter(function (v) { return v !== event.target.dataset.value; }); + value = value.filter((v) => v !== event.target.dataset.value); } - this.setData({ value: value }); + this.setData({ value }); console.log(value); }, }); diff --git a/compiled/wechat/demo/pages/CheckboxGroup/index.js b/compiled/wechat/demo/pages/CheckboxGroup/index.js index bad09ee46..4245f79c8 100644 --- a/compiled/wechat/demo/pages/CheckboxGroup/index.js +++ b/compiled/wechat/demo/pages/CheckboxGroup/index.js @@ -7,10 +7,10 @@ Page({ { value: 'banana', label: '香蕉' }, ], }, - onChange: function (value, e) { + onChange(value, e) { console.log(value, e); }, - handleChange: function (value) { + handleChange(value) { this.setData({ value: value.detail, }); diff --git a/compiled/wechat/demo/pages/Checklist/index.js b/compiled/wechat/demo/pages/Checklist/index.js index 09f7afb24..3d4846089 100644 --- a/compiled/wechat/demo/pages/Checklist/index.js +++ b/compiled/wechat/demo/pages/Checklist/index.js @@ -66,10 +66,10 @@ Page({ }, ], }, - onChange: function (v, items, e) { + onChange(v, items, e) { console.log('当前选中的值为:', v, items, e); }, - onChangeControlled: function (value) { + onChangeControlled(value) { this.setData({ value: value.detail[0] }); }, }); diff --git a/compiled/wechat/demo/pages/Collapse/index.js b/compiled/wechat/demo/pages/Collapse/index.js index d427cf286..bf259243f 100644 --- a/compiled/wechat/demo/pages/Collapse/index.js +++ b/compiled/wechat/demo/pages/Collapse/index.js @@ -19,7 +19,7 @@ Page({ } ] }, - onChange: function (current) { + onChange(current) { console.log(current); } }); diff --git a/compiled/wechat/demo/pages/CollapseAccordion/index.js b/compiled/wechat/demo/pages/CollapseAccordion/index.js index 773c99e22..0f1605307 100644 --- a/compiled/wechat/demo/pages/CollapseAccordion/index.js +++ b/compiled/wechat/demo/pages/CollapseAccordion/index.js @@ -15,7 +15,7 @@ Page({ }, ] }, - onChange: function (current) { + onChange(current) { console.log(current); } }); diff --git a/compiled/wechat/demo/pages/CollapseControl/index.js b/compiled/wechat/demo/pages/CollapseControl/index.js index fd6e812aa..548b9d769 100644 --- a/compiled/wechat/demo/pages/CollapseControl/index.js +++ b/compiled/wechat/demo/pages/CollapseControl/index.js @@ -1,12 +1,3 @@ -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; Page({ data: { current: [0], @@ -25,38 +16,38 @@ Page({ }, ], }, - onChange: function (current) { + onChange(current) { current = current.detail; this.setData({ - current: current, + current, }); }, - changeContent: function () { - var items = __spreadArray([], this.data.items, true); + changeContent() { + const items = [...this.data.items]; items[0].content = Math.random() + ' ' + items[0].content; this.setData({ - items: items, + items, }); }, - addItems: function () { - var items = __spreadArray(__spreadArray([], this.data.items, true), [ + addItems() { + const items = [ + ...this.data.items, { title: this.data.items.length, content: 'Pariatur dolore commodo commodo elit adipisicing sunt adipisicing ex duis labore nisi sunt. Magna ut minim deserunt. Sunt velit occaecat incididunt aliqua. Dolore officia voluptate aute reprehenderit anim excepteur elit.', }, - ], false); + ]; this.setData({ - items: items, + items, current: [this.data.items.length], }); }, - toggle: function () { - var _this = this; + toggle() { this.setData({ current: this.data.items - .map(function (item, index) { return index; }) - .filter(function (item) { - return _this.data.current.indexOf(item) < 0; + .map((item, index) => index) + .filter((item) => { + return this.data.current.indexOf(item) < 0; }), }); }, diff --git a/compiled/wechat/demo/pages/CollapseWithCheckbox/index.js b/compiled/wechat/demo/pages/CollapseWithCheckbox/index.js index 839f383a8..6a21dc633 100644 --- a/compiled/wechat/demo/pages/CollapseWithCheckbox/index.js +++ b/compiled/wechat/demo/pages/CollapseWithCheckbox/index.js @@ -1,13 +1,4 @@ -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -var items = [ +const items = [ { title: '第一项', content: 'Pariatur dolore commodo commodo elit adipisicing sunt adipisicing ex duis labore nisi sunt. Magna ut minim deserunt. Sunt velit occaecat incididunt aliqua. Dolore officia voluptate aute reprehenderit anim excepteur elit.', @@ -24,18 +15,18 @@ var items = [ ]; Page({ data: { - checkboxList: items.map(function (item) { return false; }), - items: items, + checkboxList: items.map((item) => false), + items, }, - onChange: function (checked, e) { - var index = e.currentTarget.dataset.index; - var checkboxList = __spreadArray([], this.data.checkboxList, true); + onChange(checked, e) { + const { index } = e.currentTarget.dataset; + const checkboxList = [...this.data.checkboxList]; checkboxList[index] = checked; this.setData({ - checkboxList: checkboxList, + checkboxList, }); }, - onTap: function () { + onTap() { my.alert({ content: this.data.checkboxList, }); diff --git a/compiled/wechat/demo/pages/DatePicker/index.js b/compiled/wechat/demo/pages/DatePicker/index.js index 47f92e55a..d464ef025 100644 --- a/compiled/wechat/demo/pages/DatePicker/index.js +++ b/compiled/wechat/demo/pages/DatePicker/index.js @@ -11,40 +11,40 @@ Page({ new Date('2022/03/21').getTime(), new Date('2022/05/20').getTime(), ], - handleFormatLabel: function (type, value) { + handleFormatLabel(type, value) { return String(value); }, }, - handleControlledRangeOk: function (value) { + handleControlledRangeOk(value) { console.log('handleControlledRangeOk'); console.log(value); this.setData({ // 微信只支持传递时间戳 - controlledDateRange: value.detail[0].map(function (o) { return o.getTime(); }), + controlledDateRange: value.detail[0].map((o) => o.getTime()), }); }, - handlePickerChange: function (date, dateStr, e) { + handlePickerChange(date, dateStr, e) { console.log('onPickerChange', date, dateStr, e); }, - handleOk: function (date, format, e) { + handleOk(date, format, e) { console.log('onOk', date, format, e); }, - handlePickerRangeChange: function (type, date, dateStr, e) { + handlePickerRangeChange(type, date, dateStr, e) { console.log('onPickerRangeChange', type, date, dateStr, e); }, - handleRangeOk: function (date, format, e) { + handleRangeOk(date, format, e) { console.log('onRangeOk', date, format, e); }, - handleChangeDate: function () { + handleChangeDate() { this.setData({ defaultDate: new Date('2019/05/02').getTime() }); }, - handleTriggerPicker: function (visible, e) { + handleTriggerPicker(visible, e) { console.log('onVisibleChange', visible, e); }, - handleDismiss: function (e) { + handleDismiss(e) { console.log('e', e); }, - handleFormatLabel: function (type, value) { + handleFormatLabel(type, value) { return String(value); }, }); diff --git a/compiled/wechat/demo/pages/Form/index.js b/compiled/wechat/demo/pages/Form/index.js index dc8c57a9a..6b224e290 100644 --- a/compiled/wechat/demo/pages/Form/index.js +++ b/compiled/wechat/demo/pages/Form/index.js @@ -1,53 +1,17 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; import cityList from './city'; Page({ data: { - onUpload: function (localFile) { - return new Promise(function (resolve) { + onUpload(localFile) { + return new Promise((resolve) => { console.log('上传的图片为:', localFile); - setTimeout(function () { + setTimeout(() => { resolve('https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ'); }, 2000); }); }, fruitList: ['苹果', '香蕉', '橘子', '西瓜'], - cityList: cityList, + cityList, radioGroupOptions: [ { value: 'cat', label: '🐱' }, { value: 'fox', label: '🦊' }, @@ -64,44 +28,33 @@ Page({ ], toastShow: false, }, - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form(); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, - showToast: function () { + showToast() { this.setData({ toastShow: true, }); }, - handleCloseToast: function () { + handleCloseToast() { this.setData({ toastShow: false, }); diff --git a/compiled/wechat/demo/pages/FormCustomError/index.js b/compiled/wechat/demo/pages/FormCustomError/index.js index 7e525ac1e..80bc970fe 100644 --- a/compiled/wechat/demo/pages/FormCustomError/index.js +++ b/compiled/wechat/demo/pages/FormCustomError/index.js @@ -1,71 +1,24 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form(); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/FormDependency/index.js b/compiled/wechat/demo/pages/FormDependency/index.js index 505b1adfc..db2711284 100644 --- a/compiled/wechat/demo/pages/FormDependency/index.js +++ b/compiled/wechat/demo/pages/FormDependency/index.js @@ -1,51 +1,14 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form(); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (this.form) { this.form.addItem(ref.detail); } @@ -59,29 +22,19 @@ Page({ data: { needFruit: false, }, - onChange: function (value) { + onChange(value) { this.setData({ needFruit: value.detail, }); }, - reset: function () { + reset() { this.setData({ needFruit: false, }); this.form.reset(); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/FormDynamic/index.js b/compiled/wechat/demo/pages/FormDynamic/index.js index 906aaf144..96bbc6cbc 100644 --- a/compiled/wechat/demo/pages/FormDynamic/index.js +++ b/compiled/wechat/demo/pages/FormDynamic/index.js @@ -1,71 +1,25 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; import { Form } from '../../../src/Form/form'; -var account = 1; +let account = 1; Page({ data: { list: [ { - id: "Account".concat(account++), + id: `Account${account++}`, }, { - id: "Account".concat(account++), + id: `Account${account++}`, }, ], }, - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form(); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (this.form) { this.form.addItem(ref.detail); } @@ -76,38 +30,29 @@ Page({ this.formRefList.push(ref.detail); } }, - reset: function () { + reset() { this.form.reset(); }, - add: function () { + add() { this.setData({ - list: __spreadArray(__spreadArray([], this.data.list, true), [ + list: [ + ...this.data.list, { - id: "Account".concat(account++), + id: `Account${account++}`, }, - ], false), + ], }); }, - minus: function (e) { - var index = e.currentTarget.dataset.index; - var list = __spreadArray([], this.data.list, true); + minus(e) { + const { index } = e.currentTarget.dataset; + const list = [...this.data.list]; list.splice(index, 1); this.setData({ - list: list, + list, }); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/FormImageUploadRules/index.js b/compiled/wechat/demo/pages/FormImageUploadRules/index.js index f8576aaf9..4d8c5aa12 100644 --- a/compiled/wechat/demo/pages/FormImageUploadRules/index.js +++ b/compiled/wechat/demo/pages/FormImageUploadRules/index.js @@ -1,53 +1,16 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ data: { - onUpload: function (localFile) { - return new Promise(function (resolve) { + onUpload(localFile) { + return new Promise((resolve) => { console.log('上传的图片为:', localFile); - setTimeout(function () { + setTimeout(() => { resolve('https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ'); }, 2000); }); }, }, - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form({ rules: { imageList: [ @@ -55,58 +18,42 @@ Page({ required: true, message: '需要上传图片', }, - function () { return ({ - validator: function (_, fileList) { - if (fileList === void 0) { fileList = []; } - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (fileList.length !== 3) { - throw new Error('需要上传3张图片'); - } - if (fileList.find(function (file) { return file.status !== 'done'; })) { - throw new Error('图片需要上传完成'); - } - return [2 /*return*/]; - }); - }); + () => ({ + async validator(_, fileList = []) { + if (fileList.length !== 3) { + throw new Error('需要上传3张图片'); + } + if (fileList.find((file) => file.status !== 'done')) { + throw new Error('图片需要上传完成'); + } }, - }); }, + }), ], }, }); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, - onUpload: function (localFile) { - return new Promise(function (resolve) { + onUpload(localFile) { + return new Promise((resolve) => { console.log('上传的图片为:', localFile); - setTimeout(function () { + setTimeout(() => { resolve('https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ'); }, 2000); }); diff --git a/compiled/wechat/demo/pages/FormInitialValues/index.js b/compiled/wechat/demo/pages/FormInitialValues/index.js index d840f822c..b04702d0f 100644 --- a/compiled/wechat/demo/pages/FormInitialValues/index.js +++ b/compiled/wechat/demo/pages/FormInitialValues/index.js @@ -1,43 +1,6 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form({ initialValues: { account: 'lily', @@ -47,32 +10,22 @@ Page({ }, }); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js b/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js index 023cca183..7d10abaef 100644 --- a/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js +++ b/compiled/wechat/demo/pages/FormInitialValuesAsync/index.js @@ -1,47 +1,10 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form(); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } // eslint-disable-next-line @typescript-eslint/ban-ts-comment @@ -49,40 +12,30 @@ Page({ wx.showLoading({ title: '加载中', }); - setTimeout(function () { - _this.form.setInitialValues({ + setTimeout(() => { + this.form.setInitialValues({ account: 'lily', address: 'alipay', needDelivery: true, quantity: 1, }); - _this.form.reset(); + this.form.reset(); // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore wx.hideLoading(); }, 1000); }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/FormLayout/index.js b/compiled/wechat/demo/pages/FormLayout/index.js index e7b0e1a77..8f14e20f1 100644 --- a/compiled/wechat/demo/pages/FormLayout/index.js +++ b/compiled/wechat/demo/pages/FormLayout/index.js @@ -1,79 +1,32 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ data: { position: 'horizontal', }, - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form(); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - toggle: function () { + toggle() { this.setData({ position: this.data.position === 'horizontal' ? 'vertical' : 'horizontal', }); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/FormMultiple/index.js b/compiled/wechat/demo/pages/FormMultiple/index.js index 6d51a86e8..8cb9d1549 100644 --- a/compiled/wechat/demo/pages/FormMultiple/index.js +++ b/compiled/wechat/demo/pages/FormMultiple/index.js @@ -1,100 +1,43 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form(); this.form2 = new Form(); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } if (this.form2RefList) { - this.form2RefList.forEach(function (ref) { - _this.form2.addItem(ref); + this.form2RefList.forEach((ref) => { + this.form2.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - handleRef2: function (ref) { + handleRef2(ref) { if (!this.form2RefList) { this.form2RefList = []; } this.form2RefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - reset2: function () { + reset2() { this.form2.reset(); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, - submit2: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form2.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit2() { + const values = await this.form2.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/FormRules/index.js b/compiled/wechat/demo/pages/FormRules/index.js index 08a5f7150..f38111468 100644 --- a/compiled/wechat/demo/pages/FormRules/index.js +++ b/compiled/wechat/demo/pages/FormRules/index.js @@ -1,43 +1,6 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form({ rules: { password: [ @@ -51,53 +14,39 @@ Page({ required: true, message: '需要输入确认密码', }, - function (form) { return ({ - validator: function (_, value) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (!value || form.getFieldValue('password') === value) { - return [2 /*return*/]; - } - throw new Error('验证密码需要跟密码相同'); - }); - }); + (form) => ({ + async validator(_, value) { + if (!value || form.getFieldValue('password') === value) { + return; + } + throw new Error('验证密码需要跟密码相同'); }, - }); }, + }), ], }, }); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - fill: function () { + fill() { this.form.setFieldValue('account', 'lily'); this.form.setFieldValue('password', '1234'); this.form.setFieldValue('confirm', '1234'); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/FormValidate/index.js b/compiled/wechat/demo/pages/FormValidate/index.js index e78e0aa0e..faebd6b0c 100644 --- a/compiled/wechat/demo/pages/FormValidate/index.js +++ b/compiled/wechat/demo/pages/FormValidate/index.js @@ -1,81 +1,33 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form(); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - onReady: function () { - var _this = this; - setTimeout(function () { + onReady() { + setTimeout(() => { // 填入表单及校验 - _this.form.setFieldValue('fruit', '橘子'); - _this.form.setFieldValidatorStatus('fruit', { + this.form.setFieldValue('fruit', '橘子'); + this.form.setFieldValidatorStatus('fruit', { status: 'error', errors: ['后台服务返回: 橘子还在进货,请换一个'], }); }); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); }, }); diff --git a/compiled/wechat/demo/pages/FormValidateMessages/index.js b/compiled/wechat/demo/pages/FormValidateMessages/index.js index 72b56ffcb..b577524d3 100644 --- a/compiled/wechat/demo/pages/FormValidateMessages/index.js +++ b/compiled/wechat/demo/pages/FormValidateMessages/index.js @@ -1,41 +1,5 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; -var validateMessages = { +const validateMessages = { required: '需要输入${label}', string: { min: '${label}最少${min}个字符', @@ -45,10 +9,9 @@ var validateMessages = { }, }; Page({ - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form({ - validateMessages: validateMessages, + validateMessages, rules: { account: [ { @@ -70,32 +33,22 @@ Page({ }, }); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/FormWatch/index.js b/compiled/wechat/demo/pages/FormWatch/index.js index 7ecbb2bf9..25f7fd989 100644 --- a/compiled/wechat/demo/pages/FormWatch/index.js +++ b/compiled/wechat/demo/pages/FormWatch/index.js @@ -1,47 +1,10 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; import { Form } from '../../../src/Form/form'; Page({ - onLoad: function () { - var _this = this; + onLoad() { this.form = new Form(); if (this.formRefList) { - this.formRefList.forEach(function (ref) { - _this.form.addItem(ref); + this.formRefList.forEach((ref) => { + this.form.addItem(ref); }); } }, @@ -49,50 +12,39 @@ Page({ changedValuesText: '', allValuesText: '', }, - onReady: function () { - var _this = this; - this.form.onValuesChange(function (changedValues, allValues) { - var changedValuesText = ''; - var allValuesText = ''; - Object.keys(changedValues).forEach(function (name) { - var value = changedValues[name]; - changedValuesText += "".concat(name, ": ").concat(value, ";"); + onReady() { + this.form.onValuesChange((changedValues, allValues) => { + let changedValuesText = ''; + let allValuesText = ''; + Object.keys(changedValues).forEach((name) => { + const value = changedValues[name]; + changedValuesText += `${name}: ${value};`; }); - Object.keys(allValues).forEach(function (name) { - var value = allValues[name]; - allValuesText += "".concat(name, ": ").concat(value, ";"); + Object.keys(allValues).forEach((name) => { + const value = allValues[name]; + allValuesText += `${name}: ${value};`; }); - _this.setData({ - changedValuesText: changedValuesText, - allValuesText: allValuesText, + this.setData({ + changedValuesText, + allValuesText, }); }); }, - handleRef: function (ref) { + handleRef(ref) { if (!this.formRefList) { this.formRefList = []; } this.formRefList.push(ref.detail); }, - reset: function () { + reset() { this.form.reset(); this.setData({ changedValuesText: '', allValuesText: '', }); }, - submit: function () { - return __awaiter(this, void 0, void 0, function () { - var values; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.form.submit()]; - case 1: - values = _a.sent(); - console.log(values); - return [2 /*return*/]; - } - }); - }); + async submit() { + const values = await this.form.submit(); + console.log(values); }, }); diff --git a/compiled/wechat/demo/pages/Grid/index.js b/compiled/wechat/demo/pages/Grid/index.js index 6bc6079e5..5ef77d6eb 100644 --- a/compiled/wechat/demo/pages/Grid/index.js +++ b/compiled/wechat/demo/pages/Grid/index.js @@ -118,12 +118,12 @@ Page({ }, ], }, - onLoad: function () { + onLoad() { this.setData({ scrollItems: this.data.items4.concat(this.data.items4), }); }, - handleTapItem: function (item) { + handleTapItem(item) { //@ts-ignore wx.showToast({ title: '点击', diff --git a/compiled/wechat/demo/pages/GuideTour/index.js b/compiled/wechat/demo/pages/GuideTour/index.js index b6d7b8640..ccf5db4b0 100644 --- a/compiled/wechat/demo/pages/GuideTour/index.js +++ b/compiled/wechat/demo/pages/GuideTour/index.js @@ -25,20 +25,19 @@ Page({ }, ], }, - onChange: function (index) { + onChange(index) { console.log('index', index); }, - onChangeControlled: function (index) { + onChangeControlled(index) { this.setData({ current: index }); }, - openTour: function (e) { - var _a; - this.setData((_a = {}, - _a[e.target.dataset.field] = true, - _a.current = 0, - _a)); + openTour(e) { + this.setData({ + [e.target.dataset.field]: true, + current: 0, + }); }, - closeTour: function () { + closeTour() { this.setData({ baseVisible: false, moreVisible: false, diff --git a/compiled/wechat/demo/pages/Icon/index.js b/compiled/wechat/demo/pages/Icon/index.js index 1b0097ddb..dc794f208 100644 --- a/compiled/wechat/demo/pages/Icon/index.js +++ b/compiled/wechat/demo/pages/Icon/index.js @@ -1,5 +1,5 @@ Page({ - handleTap: function (e) { + handleTap(e) { console.log(e); console.log('detail', e.detail); console.log('e.currentTarget.dataset', e.currentTarget.dataset); diff --git a/compiled/wechat/demo/pages/ImageUpload/index.js b/compiled/wechat/demo/pages/ImageUpload/index.js index 04f17ee1e..cc367b3b7 100644 --- a/compiled/wechat/demo/pages/ImageUpload/index.js +++ b/compiled/wechat/demo/pages/ImageUpload/index.js @@ -1,5 +1,5 @@ function onRemove(file) { - return new Promise(function (resolve) { + return new Promise((resolve) => { console.log('即将移除的图片为:', file); // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore @@ -27,27 +27,27 @@ Page({ status: 'done', }, ], - onRemove: onRemove, - onUpload: function (file) { - return new Promise(function (resolve) { + onRemove, + onUpload(file) { + return new Promise((resolve) => { console.log('上传的图片为:', file); - setTimeout(function () { + setTimeout(() => { resolve('https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ'); }, 2000); }); }, - onBeforeUpload: function (localFileList) { + onBeforeUpload(localFileList) { console.log('即将上传的图片列表为:', localFileList); - localFileList = localFileList.filter(function (item) { return item.size < 10000; }); + localFileList = localFileList.filter((item) => item.size < 10000); console.log('修改上传的图片列表为:', localFileList); return localFileList; }, }, - onChange: function (fileList) { + onChange(fileList) { // 这里的数据包括上传失败和成功的图片列表,如果需要筛选出上传成功的图片需要在此处理 console.log('图片列表:', fileList); }, - onPreview: function (file) { + onPreview(file) { console.log('preview', file); }, }); diff --git a/compiled/wechat/demo/pages/ImageUploadControl/index.js b/compiled/wechat/demo/pages/ImageUploadControl/index.js index cb22aa460..0659291d8 100644 --- a/compiled/wechat/demo/pages/ImageUploadControl/index.js +++ b/compiled/wechat/demo/pages/ImageUploadControl/index.js @@ -1,14 +1,14 @@ function onUpload(file) { console.log('当前上传的图片为:', file); - return new Promise(function (resolve) { - setTimeout(function () { + return new Promise((resolve) => { + setTimeout(() => { resolve('https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ'); }, 2000); }); } Page({ data: { - onUpload: onUpload, + onUpload, fileList: [ { url: 'https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*znK_ToIL8rQAAAAAAAAAAAAAARQnAQ', @@ -24,16 +24,16 @@ Page({ }, ], }, - onChange: function (fileList) { + onChange(fileList) { this.setData({ fileList: fileList.detail, }); }, - handleUploaderRef: function (ref) { + handleUploaderRef(ref) { console.log('handleUploaderRef', ref); this.handleUploaderRef = ref.detail; }, - upload: function () { + upload() { this.handleUploaderRef.chooseImage(); }, }); diff --git a/compiled/wechat/demo/pages/Input/index.js b/compiled/wechat/demo/pages/Input/index.js index 7f2ea1256..4b0b0765b 100644 --- a/compiled/wechat/demo/pages/Input/index.js +++ b/compiled/wechat/demo/pages/Input/index.js @@ -3,15 +3,15 @@ Page({ value: '', money: '', }, - onChange: function (value, e) { + onChange(value, e) { console.log(value, e); }, - handleChange: function (value) { + handleChange(value) { this.setData({ value: value.detail, }); }, - handleMoney: function (value) { + handleMoney(value) { console.log(value); if (isNaN(Number(value.detail))) { return; @@ -20,15 +20,15 @@ Page({ money: value.detail, }); }, - clear: function () { + clear() { this.setData({ value: '', }); }, - handleRef: function (input) { + handleRef(input) { this.input = input.detail; }, - clearByInputRef: function () { + clearByInputRef() { this.input.update(''); }, }); diff --git a/compiled/wechat/demo/pages/InputCustom/index.js b/compiled/wechat/demo/pages/InputCustom/index.js index 0c3a843c3..d28de2f3a 100644 --- a/compiled/wechat/demo/pages/InputCustom/index.js +++ b/compiled/wechat/demo/pages/InputCustom/index.js @@ -3,15 +3,15 @@ Page({ value: '', money: '', }, - onChange: function (value, e) { + onChange(value, e) { console.log(value, e); }, - handleChange: function (value) { + handleChange(value) { this.setData({ - value: value, + value, }); }, - handleMoney: function (value) { + handleMoney(value) { console.log(value); if (isNaN(Number(value))) { return; @@ -20,15 +20,15 @@ Page({ money: value, }); }, - clear: function () { + clear() { this.setData({ value: '', }); }, - handleRef: function (input) { + handleRef(input) { this.input = input; }, - clearByInputRef: function () { + clearByInputRef() { this.input.update(''); } }); diff --git a/compiled/wechat/demo/pages/InputSearchBar/index.js b/compiled/wechat/demo/pages/InputSearchBar/index.js index 2fa298cfa..b2fa7c6b3 100644 --- a/compiled/wechat/demo/pages/InputSearchBar/index.js +++ b/compiled/wechat/demo/pages/InputSearchBar/index.js @@ -1,8 +1,8 @@ Page({ - onChange: function (value, e) { + onChange(value, e) { console.log(value, e); }, - onConfirm: function (value) { + onConfirm(value) { my.alert({ content: value, }); diff --git a/compiled/wechat/demo/pages/InputTextarea/index.js b/compiled/wechat/demo/pages/InputTextarea/index.js index 188036540..0185442df 100644 --- a/compiled/wechat/demo/pages/InputTextarea/index.js +++ b/compiled/wechat/demo/pages/InputTextarea/index.js @@ -4,15 +4,15 @@ Page({ value: '', money: '', }, - onChange: function (value, e) { + onChange(value, e) { console.log(value, e); }, - handleChange: function (value) { + handleChange(value) { this.setData({ value: resolveEventValue(value), }); }, - handleMoney: function (value) { + handleMoney(value) { console.log(value); if (isNaN(Number(resolveEventValue(value)))) { return; @@ -21,15 +21,15 @@ Page({ money: resolveEventValue(value), }); }, - clear: function () { + clear() { this.setData({ value: '', }); }, - handleRef: function (input) { + handleRef(input) { this.input = resolveEventValue(input); }, - clearByInputRef: function () { + clearByInputRef() { this.input.update(''); }, }); diff --git a/compiled/wechat/demo/pages/List/index.js b/compiled/wechat/demo/pages/List/index.js index 72b86dd84..bb3c638c2 100644 --- a/compiled/wechat/demo/pages/List/index.js +++ b/compiled/wechat/demo/pages/List/index.js @@ -2,10 +2,10 @@ Page({ data: { radius: false, }, - handleTap: function (e) { + handleTap(e) { console.log(e); }, - handleSetRadius: function (checked) { + handleSetRadius(checked) { this.setData({ radius: checked, }); diff --git a/compiled/wechat/demo/pages/Modal/index.js b/compiled/wechat/demo/pages/Modal/index.js index 130cf18b9..bf50b43a3 100644 --- a/compiled/wechat/demo/pages/Modal/index.js +++ b/compiled/wechat/demo/pages/Modal/index.js @@ -10,12 +10,11 @@ Page({ customVisible: false, customBodyVisible: false, }, - handleOpen: function (e) { - var _a; - var field = e.target.dataset.field; - this.setData((_a = {}, _a[field] = true, _a)); + handleOpen(e) { + const { field } = e.target.dataset; + this.setData({ [field]: true }); }, - handleClose: function () { + handleClose() { this.setData({ basicVisible: false, withTitleVisible: false, @@ -28,19 +27,19 @@ Page({ customBodyVisible: false, }); }, - handlePrimaryButtonTap: function () { + handlePrimaryButtonTap() { this.handleClose(); this.showToast('点击主要按钮'); }, - handleSecondaryButtonTap: function () { + handleSecondaryButtonTap() { this.handleClose(); this.showToast('点击辅助按钮'); }, - handleCancelButtonTap: function () { + handleCancelButtonTap() { this.handleClose(); this.showToast('点击取消按钮'); }, - showToast: function (content) { + showToast(content) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore wx.showToast({ diff --git a/compiled/wechat/demo/pages/NoticeBar/index.js b/compiled/wechat/demo/pages/NoticeBar/index.js index f7dab67c9..2271eb485 100644 --- a/compiled/wechat/demo/pages/NoticeBar/index.js +++ b/compiled/wechat/demo/pages/NoticeBar/index.js @@ -2,16 +2,16 @@ Page({ data: { typeList: ['default', 'error', 'info', 'primary'], }, - handleTapAction: function () { + handleTapAction() { this.showToast('点击按钮'); }, - handleTapLink: function () { + handleTapLink() { this.showToast('link 类型被点击了'); }, - handleClose: function () { + handleClose() { this.showToast('点击关闭'); }, - showToast: function (content) { + showToast(content) { //@ts-ignore wx.showToast({ title: content, diff --git a/compiled/wechat/demo/pages/NumberKeyboard/index.js b/compiled/wechat/demo/pages/NumberKeyboard/index.js index 50ef09492..2d16209f9 100644 --- a/compiled/wechat/demo/pages/NumberKeyboard/index.js +++ b/compiled/wechat/demo/pages/NumberKeyboard/index.js @@ -10,35 +10,35 @@ Page({ visible7: false, }, // 默认键盘 - onTap: function () { + onTap() { this.setData({ visible: !this.data.visible }); }, // 没有小数点 - onTap1: function () { + onTap1() { this.setData({ visible1: !this.data.visible1 }); }, // 带确认按钮 - onTap2: function () { + onTap2() { this.setData({ visible2: !this.data.visible2 }); }, // 带向下箭头 - onTap3: function () { + onTap3() { this.setData({ visible3: !this.data.visible3 }); }, // 乱序键盘 - onTap4: function () { + onTap4() { this.setData({ visible4: !this.data.visible4 }); }, // 带标题 - onTap5: function () { + onTap5() { this.setData({ visible5: !this.data.visible5 }); }, // 自定义标题 - onTap6: function () { + onTap6() { this.setData({ visible6: !this.data.visible6 }); }, // 自定义确认按钮 - onTap7: function () { + onTap7() { this.setData({ visible7: !this.data.visible7 }); }, }); diff --git a/compiled/wechat/demo/pages/NumberKeyboardAmount/index.js b/compiled/wechat/demo/pages/NumberKeyboardAmount/index.js index 2110afc38..f433e3ed3 100644 --- a/compiled/wechat/demo/pages/NumberKeyboardAmount/index.js +++ b/compiled/wechat/demo/pages/NumberKeyboardAmount/index.js @@ -3,10 +3,10 @@ Page({ value: '', visible: false, }, - onAmountFocus: function () { + onAmountFocus() { this.setData({ visible: true }); }, - onChange: function (e) { + onChange(e) { e = e.detail; // 第一位输入0,第二位输入1,直接展示1 if (e[0] === '0' && e[1] && e[1] !== '.') { @@ -19,16 +19,16 @@ Page({ return; } // 不允许多个小数点 - var onePoint = e && e[e.length - 1] === '.' && e.length - 1 !== e.indexOf('.'); + const onePoint = e && e[e.length - 1] === '.' && e.length - 1 !== e.indexOf('.'); // 限制小数点后2位 - var precision2 = e && e.split('.').length > 1 && e.split('.')[1].length === 3; + const precision2 = e && e.split('.').length > 1 && e.split('.')[1].length === 3; if (onePoint || precision2) { this.setData({ value: e.slice(0, e.length - 1) }); return; } this.setData({ value: e }); }, - onClose: function () { + onClose() { // 失去焦点时如果末尾是小数点,自动去掉 if (this.data.value[this.data.value.length - 1] === '.') { this.setData({ diff --git a/compiled/wechat/demo/pages/NumberKeyboardCode/index.js b/compiled/wechat/demo/pages/NumberKeyboardCode/index.js index 237e2fd04..6305bae49 100644 --- a/compiled/wechat/demo/pages/NumberKeyboardCode/index.js +++ b/compiled/wechat/demo/pages/NumberKeyboardCode/index.js @@ -3,15 +3,15 @@ Page({ value: '', visible: false, }, - onCodeFocus: function () { + onCodeFocus() { this.setData({ visible: true }); }, - onChange: function (e) { + onChange(e) { e = e.detail; this.setData({ value: e }); e.length === 4 && this.onClose(); }, - onClose: function () { + onClose() { this.setData({ visible: false }); }, }); diff --git a/compiled/wechat/demo/pages/NumberKeyboardNumber/index.js b/compiled/wechat/demo/pages/NumberKeyboardNumber/index.js index 6126f289e..7d79b39e9 100644 --- a/compiled/wechat/demo/pages/NumberKeyboardNumber/index.js +++ b/compiled/wechat/demo/pages/NumberKeyboardNumber/index.js @@ -3,14 +3,14 @@ Page({ value: '', visible: false, }, - onNumberFocus: function () { + onNumberFocus() { this.setData({ visible: true }); }, - onChange: function (e) { + onChange(e) { e = e.detail; this.setData({ value: e ? parseFloat(e) : '' }); }, - onClose: function () { + onClose() { this.setData({ visible: false }); }, }); diff --git a/compiled/wechat/demo/pages/Picker/index.js b/compiled/wechat/demo/pages/Picker/index.js index 06f115a8a..c867347df 100644 --- a/compiled/wechat/demo/pages/Picker/index.js +++ b/compiled/wechat/demo/pages/Picker/index.js @@ -4,8 +4,8 @@ Page({ defaultValue: '上海', value: '上海', list: ['北京', '上海', '深圳', '广州', '南京', '武汉', '无锡', '苏州'], - formatTime: function (value, column) { - return column.map(function (c) { return c && c.label; }).join(''); + formatTime: (value, column) => { + return column.map((c) => c && c.label).join(''); }, weekList: [ { @@ -64,42 +64,42 @@ Page({ ], ], }, - handleDismissPicker: function (e) { + handleDismissPicker(e) { }, - handleClearControlled: function () { + handleClearControlled() { this.setData({ value: '', }); }, - handleChangeControlled: function () { + handleChangeControlled() { this.setData({ value: '深圳', }); }, - handleControlledOk: function (value) { + handleControlledOk(value) { this.setData({ - value: value, + value, }); }, - handleOk: function (value, column, e) { + handleOk(value, column, e) { console.log('onOk value', value, 'onOk column', column, e); }, - handleChange: function (value, column, e) { + handleChange(value, column, e) { console.log('onChange value', value, 'onChange column', column, e); }, - handleOnOk: function (value, column) { + handleOnOk(value, column) { console.log('value', value, 'column', column); }, - handleTriggerPicker: function (visible, e) { + handleTriggerPicker(visible, e) { console.log('onVisibleChange', visible, e); }, - handleTriggerControlledPicker: function (visible, e) { + handleTriggerControlledPicker(visible, e) { console.log('handleTriggerControlledPicker', visible); this.setData({ pickerVisible: visible.detail, }); }, - handleOpenPicker: function () { + handleOpenPicker() { this.setData({ pickerVisible: true, }); diff --git a/compiled/wechat/demo/pages/Popover/index.js b/compiled/wechat/demo/pages/Popover/index.js index b91c68fdb..a34a05209 100644 --- a/compiled/wechat/demo/pages/Popover/index.js +++ b/compiled/wechat/demo/pages/Popover/index.js @@ -16,10 +16,10 @@ Page({ 'right-bottom', ], }, - onVisibleChange: function (visible, e) { + onVisibleChange(visible, e) { console.log('onVisibleChange', visible, e); }, - handleVisibleChange: function () { + handleVisibleChange() { this.setData({ visible: !this.data.visible, }); diff --git a/compiled/wechat/demo/pages/PopoverList/index.js b/compiled/wechat/demo/pages/PopoverList/index.js index 24e4441d2..6e61a9079 100644 --- a/compiled/wechat/demo/pages/PopoverList/index.js +++ b/compiled/wechat/demo/pages/PopoverList/index.js @@ -3,11 +3,11 @@ Page({ visible: true, url: 'https://gw.alipayobjects.com/mdn/rms_ce4c6f/afts/img/A*XMCgSYx3f50AAAAAAAAAAABkARQnAQ', }, - handleVisibleChange: function (visible, e) { + handleVisibleChange(visible, e) { console.log(visible, e); this.setData({ visible: visible.detail }); }, - handleTapItem: function (e) { + handleTapItem(e) { console.log(e); this.setData({ visible: false }); }, diff --git a/compiled/wechat/demo/pages/Popup/index.js b/compiled/wechat/demo/pages/Popup/index.js index 4c29e21dc..7b72e8287 100644 --- a/compiled/wechat/demo/pages/Popup/index.js +++ b/compiled/wechat/demo/pages/Popup/index.js @@ -6,27 +6,27 @@ Page({ scrollVisible: false, closeVisible: false, }, - handlePopupClose: function () { + handlePopupClose() { this.setData({ basicVisible: false, scrollVisible: false, closeVisible: false, }); }, - handleShowBasic: function (e) { - var position = e.target.dataset.position; + handleShowBasic(e) { + const { position } = e.target.dataset; this.setData({ - position: position, + position, basicVisible: true, }); }, - handleShowScroll: function () { + handleShowScroll() { this.setData({ scrollVisible: true }); }, - handleChangeAnimation: function (checked) { + handleChangeAnimation(checked) { this.setData({ animation: checked.detail }); }, - handleShowClose: function () { + handleShowClose() { this.setData({ closeVisible: true }); }, }); diff --git a/compiled/wechat/demo/pages/ProgressCircle/index.js b/compiled/wechat/demo/pages/ProgressCircle/index.js index 9eb8027e8..ea5a0b85a 100644 --- a/compiled/wechat/demo/pages/ProgressCircle/index.js +++ b/compiled/wechat/demo/pages/ProgressCircle/index.js @@ -7,44 +7,44 @@ Page({ percent5: 60, speed1: 6 }, - handleAdd: function () { - var newPercent = this.data.percent1 + 20; + handleAdd() { + const newPercent = this.data.percent1 + 20; this.setData({ percent1: Math.max(Math.min(100, newPercent), 0) }); }, - handleDelete: function () { - var newPercent = this.data.percent1 - 20; + handleDelete() { + const newPercent = this.data.percent1 - 20; this.setData({ percent1: Math.max(Math.min(100, newPercent), 0) }); }, - handleInput1Change: function (e) { + handleInput1Change(e) { this.setData({ percent1: +(e.detail.value) }); }, - handleInput2Change: function (e) { + handleInput2Change(e) { this.setData({ percent2: +(e.detail.value) }); }, - handleInput3Change: function (e) { + handleInput3Change(e) { this.setData({ percent3: +(e.detail.value) }); }, - handleInput4Change: function (e) { + handleInput4Change(e) { this.setData({ percent4: +(e.detail.value) }); }, - handleInput5Change: function (e) { + handleInput5Change(e) { this.setData({ speed1: +(e.detail.value) }); }, - handleInput6Change: function (e) { + handleInput6Change(e) { this.setData({ percent5: +(e.detail.value) }); diff --git a/compiled/wechat/demo/pages/ProgressLine/index.js b/compiled/wechat/demo/pages/ProgressLine/index.js index 1a2f8d96b..0182a5d30 100644 --- a/compiled/wechat/demo/pages/ProgressLine/index.js +++ b/compiled/wechat/demo/pages/ProgressLine/index.js @@ -5,34 +5,34 @@ Page({ progress3: 50, progress4: 50, }, - handleAdd: function () { - var progress1 = this.data.progress1 + 20; + handleAdd() { + const progress1 = this.data.progress1 + 20; this.setData({ progress1: Math.max(Math.min(progress1, 100), 0) }); }, - handleDelete: function () { - var progress1 = this.data.progress1 - 20; + handleDelete() { + const progress1 = this.data.progress1 - 20; this.setData({ progress1: Math.max(Math.min(progress1, 100), 0) }); }, - handleInputChange1: function (num) { + handleInputChange1(num) { this.setData({ progress1: +num }); }, - handleInputChange2: function (num) { + handleInputChange2(num) { this.setData({ progress2: +num }); }, - handleInputChange3: function (num) { + handleInputChange3(num) { this.setData({ progress3: +num }); }, - handleInputChange4: function (num) { + handleInputChange4(num) { this.setData({ progress4: +num }); diff --git a/compiled/wechat/demo/pages/Radio/index.js b/compiled/wechat/demo/pages/Radio/index.js index e802133ea..cc7420a8e 100644 --- a/compiled/wechat/demo/pages/Radio/index.js +++ b/compiled/wechat/demo/pages/Radio/index.js @@ -2,10 +2,10 @@ Page({ data: { checked: false, }, - onChange: function (value, e) { + onChange(value, e) { console.log(value, e); }, - handleChange: function (checked) { + handleChange(checked) { this.setData({ checked: checked.detail, }); diff --git a/compiled/wechat/demo/pages/RadioGroup/index.js b/compiled/wechat/demo/pages/RadioGroup/index.js index cb3c95579..087995047 100644 --- a/compiled/wechat/demo/pages/RadioGroup/index.js +++ b/compiled/wechat/demo/pages/RadioGroup/index.js @@ -13,10 +13,10 @@ Page({ { value: 'banana', label: '香蕉' }, ], }, - onChange: function (value, e) { + onChange(value, e) { console.log(value, e); }, - handleChange: function (value) { + handleChange(value) { this.setData({ value: value.detail, }); diff --git a/compiled/wechat/demo/pages/RareWordsKeyboard/index.js b/compiled/wechat/demo/pages/RareWordsKeyboard/index.js index 25549babc..5150afced 100644 --- a/compiled/wechat/demo/pages/RareWordsKeyboard/index.js +++ b/compiled/wechat/demo/pages/RareWordsKeyboard/index.js @@ -5,38 +5,38 @@ Page({ visible2: false, visible3: false, }, - onInputChange: function (value) { + onInputChange(value) { value = value.detail; - this.setData({ value: value }); + this.setData({ value }); }, // 默认键盘 - onTap: function () { + onTap() { this.setData({ visible: true }); }, // 关闭键盘 - onClose: function () { + onClose() { this.setData({ visible: false }); }, // 不带蒙层 - onTap2: function () { + onTap2() { this.setData({ visible2: true }); }, - onClose2: function () { + onClose2() { this.setData({ visible2: false }); }, // 监听各种事件 - onTap3: function () { + onTap3() { this.setData({ visible3: true }); }, - onClose3: function () { + onClose3() { this.setData({ visible3: false }); }, - onChange: function (value) { + onChange(value) { value = value.detail; - var curValue = this.data.value; + const curValue = this.data.value; this.setData({ value: curValue + value }); }, - onKeyBoardError: function (err) { + onKeyBoardError(err) { err = err.detail; my.showToast({ content: 'onError ' + err.toString() }); }, diff --git a/compiled/wechat/demo/pages/Rate/index.js b/compiled/wechat/demo/pages/Rate/index.js index 9ea2a8ecd..bf8a4f27f 100644 --- a/compiled/wechat/demo/pages/Rate/index.js +++ b/compiled/wechat/demo/pages/Rate/index.js @@ -2,10 +2,10 @@ Page({ data: { value: 3, }, - onChange: function (value) { + onChange(value) { console.log(value); }, - handleChange: function (value) { + handleChange(value) { console.log(value); this.setData({ value: value.detail, diff --git a/compiled/wechat/demo/pages/RateCustom/index.js b/compiled/wechat/demo/pages/RateCustom/index.js index f7a80473c..1a855d133 100644 --- a/compiled/wechat/demo/pages/RateCustom/index.js +++ b/compiled/wechat/demo/pages/RateCustom/index.js @@ -1,5 +1,5 @@ Page({ - onChange: function (value) { + onChange(value) { console.log(value); }, }); diff --git a/compiled/wechat/demo/pages/Result/index.js b/compiled/wechat/demo/pages/Result/index.js index 1dac28ca1..8687ed457 100644 --- a/compiled/wechat/demo/pages/Result/index.js +++ b/compiled/wechat/demo/pages/Result/index.js @@ -11,9 +11,9 @@ Page({ }, ], }, - handleTabBtn: function (e) { + handleTabBtn(e) { my.alert({ - content: "\u5F53\u524D\u70B9\u51FB\u7684\u662F\u7B2C ".concat(e + 1, " \u4E2A\u6309\u94AE\uFF1A").concat(this.data.buttons[e].text), + content: `当前点击的是第 ${e + 1} 个按钮:${this.data.buttons[e].text}`, }); }, }); diff --git a/compiled/wechat/demo/pages/Selector/index.js b/compiled/wechat/demo/pages/Selector/index.js index 419b15988..5eacc596d 100644 --- a/compiled/wechat/demo/pages/Selector/index.js +++ b/compiled/wechat/demo/pages/Selector/index.js @@ -20,18 +20,18 @@ Page({ ], value: '1', }, - handleChangeValue: function () { + handleChangeValue() { this.setData({ value: '3', }); }, - handleChange: function (value, items, e) { + handleChange(value, items, e) { this.setData({ value: value.detail[0], }); console.log(value, items, e); }, - onSelectMin: function (value, item) { + onSelectMin(value, item) { console.log(value, item); // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore @@ -39,7 +39,7 @@ Page({ content: '不允许清空', }); }, - onSelectMax: function () { + onSelectMax() { // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore wx.showModal({ diff --git a/compiled/wechat/demo/pages/SelectorFilter/index.js b/compiled/wechat/demo/pages/SelectorFilter/index.js index 4225b87bd..df1f41eee 100644 --- a/compiled/wechat/demo/pages/SelectorFilter/index.js +++ b/compiled/wechat/demo/pages/SelectorFilter/index.js @@ -46,14 +46,14 @@ Page({ }, ], }, - handleChange: function (value, items, e) { + handleChange(value, items, e) { console.log(value, items, e); }, - onTapItem: function (e) { + onTapItem(e) { console.log(e); - var index = e.currentTarget.dataset.index; - var currentOpen = this.data.currentOpen; - var value = index; + const { index } = e.currentTarget.dataset; + const { currentOpen } = this.data; + let value = index; if (currentOpen === index) { value = -1; } diff --git a/compiled/wechat/demo/pages/Skeleton/index.js b/compiled/wechat/demo/pages/Skeleton/index.js index d68ada7f9..05c9b92bd 100644 --- a/compiled/wechat/demo/pages/Skeleton/index.js +++ b/compiled/wechat/demo/pages/Skeleton/index.js @@ -5,7 +5,7 @@ Page({ rows: 4, }, }, - handleToggleShowLoading: function () { + handleToggleShowLoading() { this.setData({ showLoading: !this.data.showLoading }); }, }); diff --git a/compiled/wechat/demo/pages/Slider/index.js b/compiled/wechat/demo/pages/Slider/index.js index 5af4ed361..71cc3dbc8 100644 --- a/compiled/wechat/demo/pages/Slider/index.js +++ b/compiled/wechat/demo/pages/Slider/index.js @@ -2,18 +2,18 @@ Page({ data: { value: 80, }, - onChange: function (value, e) { + onChange(value, e) { console.log('slider changed:', value, e); }, - onAfterChange: function (value, e) { + onAfterChange(value, e) { console.log('当前值:', value, e); // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore wx.showToast({ - title: "value: ".concat(value.detail), + title: `value: ${value.detail}`, }); }, - handleChange: function (value, e) { + handleChange(value, e) { console.log('slider changed:', value, e); this.setData({ value: value.detail, diff --git a/compiled/wechat/demo/pages/Stepper/index.js b/compiled/wechat/demo/pages/Stepper/index.js index d4026f900..b4b1f60bd 100644 --- a/compiled/wechat/demo/pages/Stepper/index.js +++ b/compiled/wechat/demo/pages/Stepper/index.js @@ -1,42 +1,42 @@ Page({ data: {}, - onChange: function (value) { + onChange(value) { console.log('onChange', value); }, - onFocus: function (value) { + onFocus(value) { console.log('onFocus', value); }, - onConfirm: function (value) { + onConfirm(value) { console.log('onConfirm', value); }, - onBlur: function (value) { + onBlur(value) { console.log('onBlur', value); }, - handleChange: function (value) { + handleChange(value) { console.log('onChange', value); this.setData({ value: value.detail, }); }, - add: function () { + add() { this.setData({ value: (this.data.value || 0) + 1, }); }, - minus: function () { + minus() { this.setData({ value: (this.data.value || 0) - 1, }); }, - clear: function () { + clear() { this.setData({ value: null, }); }, - handleAddValue: function () { + handleAddValue() { this.setData({ value: this.data.value + 1 }); }, - handleMinusValue: function () { + handleMinusValue() { this.setData({ value: this.data.value - 1 }); }, }); diff --git a/compiled/wechat/demo/pages/StepsControl/index.js b/compiled/wechat/demo/pages/StepsControl/index.js index 18fe92321..0d59b31eb 100644 --- a/compiled/wechat/demo/pages/StepsControl/index.js +++ b/compiled/wechat/demo/pages/StepsControl/index.js @@ -1,12 +1,3 @@ -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; Page({ data: { current: 0, @@ -30,7 +21,7 @@ Page({ 'StarFill' ], }, - onNextTap: function () { + onNextTap() { if (this.data.current === this.data.items.length - 1) { my.alert({ content: '完成', @@ -41,7 +32,7 @@ Page({ current: this.data.current + 1, }); }, - onPrevTap: function () { + onPrevTap() { if (this.data.current === 0) { return; } @@ -49,13 +40,14 @@ Page({ current: this.data.current - 1, }); }, - onAddTap: function () { + onAddTap() { this.setData({ - items: __spreadArray(__spreadArray([], this.data.items, true), [ + items: [ + ...this.data.items, { title: '步骤' + this.data.items.length } - ], false) + ] }); } }); diff --git a/compiled/wechat/demo/pages/SwipeAction/index.js b/compiled/wechat/demo/pages/SwipeAction/index.js index 185cf90a0..daad73981 100644 --- a/compiled/wechat/demo/pages/SwipeAction/index.js +++ b/compiled/wechat/demo/pages/SwipeAction/index.js @@ -19,17 +19,17 @@ Page({ ], swipeIndex: -1, }, - onSwipeStart: function () { + onSwipeStart() { this.setData({ swipeIndex: '' }); }, - onSwipeEnd: function (args1, args2) { - var e, data; + onSwipeEnd(args1, args2) { + let e, data; e = args1; data = args1.detail; - var index = e.target.dataset.item.index; + const { index } = e.target.dataset.item; data.swiped && this.setData({ swipeIndex: index }); }, - onButtonTap: function (data, e) { + onButtonTap(data, e) { console.log(data, e); }, }); diff --git a/compiled/wechat/demo/pages/SwipeActionAnimation/index.js b/compiled/wechat/demo/pages/SwipeActionAnimation/index.js index cda525b63..245d75eda 100644 --- a/compiled/wechat/demo/pages/SwipeActionAnimation/index.js +++ b/compiled/wechat/demo/pages/SwipeActionAnimation/index.js @@ -19,17 +19,17 @@ Page({ ], swipeIndex: -1, }, - onSwipeStart: function () { + onSwipeStart() { this.setData({ swipeIndex: '' }); }, - onSwipeEnd: function (args1, args2) { - var e, data; + onSwipeEnd(args1, args2) { + let e, data; e = args1; data = args1.detail; - var index = e.target.dataset.item.index; + const { index } = e.target.dataset.item; data.swiped && this.setData({ swipeIndex: index }); }, - onButtonTap: function (data, e) { + onButtonTap(data, e) { console.log(data, e); }, }); diff --git a/compiled/wechat/demo/pages/SwipeActionLeft/index.js b/compiled/wechat/demo/pages/SwipeActionLeft/index.js index 96e5493f8..f319f5213 100644 --- a/compiled/wechat/demo/pages/SwipeActionLeft/index.js +++ b/compiled/wechat/demo/pages/SwipeActionLeft/index.js @@ -19,17 +19,17 @@ Page({ ], swipeIndex: -1, }, - onSwipeStart: function () { + onSwipeStart() { this.setData({ swipeIndex: '' }); }, - onSwipeEnd: function (args1, args2) { - var e, data; + onSwipeEnd(args1, args2) { + let e, data; e = args1; data = args1.detail; - var index = e.target.dataset.item.index; + const { index } = e.target.dataset.item; data.swiped && this.setData({ swipeIndex: index }); }, - onButtonTap: function (data, e) { + onButtonTap(data, e) { console.log(data, e); }, }); diff --git a/compiled/wechat/demo/pages/SwipeActionLeftRight/index.js b/compiled/wechat/demo/pages/SwipeActionLeftRight/index.js index c35156c13..98d21f6b8 100644 --- a/compiled/wechat/demo/pages/SwipeActionLeftRight/index.js +++ b/compiled/wechat/demo/pages/SwipeActionLeftRight/index.js @@ -19,17 +19,17 @@ Page({ ], swipeIndex: -1, }, - onSwipeStart: function () { + onSwipeStart() { this.setData({ swipeIndex: '' }); }, - onSwipeEnd: function (args1, args2) { - var e, data; + onSwipeEnd(args1, args2) { + let e, data; e = args1; data = args1.detail; - var index = e.target.dataset.item.index; + const { index } = e.target.dataset.item; data.swiped && this.setData({ swipeIndex: index }); }, - onButtonTap: function (data, e) { + onButtonTap(data, e) { console.log(data, e); }, }); diff --git a/compiled/wechat/demo/pages/SwipeActionMove/index.js b/compiled/wechat/demo/pages/SwipeActionMove/index.js index da8ff2dda..9e245697f 100644 --- a/compiled/wechat/demo/pages/SwipeActionMove/index.js +++ b/compiled/wechat/demo/pages/SwipeActionMove/index.js @@ -21,17 +21,17 @@ Page({ ], swipeIndex: -1, }, - onSwipeStart: function () { + onSwipeStart() { this.setData({ swipeIndex: '' }); }, - onSwipeEnd: function (args1, args2) { - var e, data; + onSwipeEnd(args1, args2) { + let e, data; e = args1; data = args1.detail; - var index = e.target.dataset.item.index; + const { index } = e.target.dataset.item; data.swiped && this.setData({ swipeIndex: index }); }, - onButtonTap: function (data, e) { + onButtonTap(data, e) { console.log(data, e); }, }); diff --git a/compiled/wechat/demo/pages/SwipeActionNumber/index.js b/compiled/wechat/demo/pages/SwipeActionNumber/index.js index cda525b63..245d75eda 100644 --- a/compiled/wechat/demo/pages/SwipeActionNumber/index.js +++ b/compiled/wechat/demo/pages/SwipeActionNumber/index.js @@ -19,17 +19,17 @@ Page({ ], swipeIndex: -1, }, - onSwipeStart: function () { + onSwipeStart() { this.setData({ swipeIndex: '' }); }, - onSwipeEnd: function (args1, args2) { - var e, data; + onSwipeEnd(args1, args2) { + let e, data; e = args1; data = args1.detail; - var index = e.target.dataset.item.index; + const { index } = e.target.dataset.item; data.swiped && this.setData({ swipeIndex: index }); }, - onButtonTap: function (data, e) { + onButtonTap(data, e) { console.log(data, e); }, }); diff --git a/compiled/wechat/demo/pages/SwipeActionSpeed/index.js b/compiled/wechat/demo/pages/SwipeActionSpeed/index.js index cda525b63..245d75eda 100644 --- a/compiled/wechat/demo/pages/SwipeActionSpeed/index.js +++ b/compiled/wechat/demo/pages/SwipeActionSpeed/index.js @@ -19,17 +19,17 @@ Page({ ], swipeIndex: -1, }, - onSwipeStart: function () { + onSwipeStart() { this.setData({ swipeIndex: '' }); }, - onSwipeEnd: function (args1, args2) { - var e, data; + onSwipeEnd(args1, args2) { + let e, data; e = args1; data = args1.detail; - var index = e.target.dataset.item.index; + const { index } = e.target.dataset.item; data.swiped && this.setData({ swipeIndex: index }); }, - onButtonTap: function (data, e) { + onButtonTap(data, e) { console.log(data, e); }, }); diff --git a/compiled/wechat/demo/pages/SwipeActionTap/index.js b/compiled/wechat/demo/pages/SwipeActionTap/index.js index 168aa1664..1dfa710e8 100644 --- a/compiled/wechat/demo/pages/SwipeActionTap/index.js +++ b/compiled/wechat/demo/pages/SwipeActionTap/index.js @@ -21,17 +21,17 @@ Page({ ], swipeIndex: -1, }, - onSwipeStart: function () { + onSwipeStart() { this.setData({ swipeIndex: '' }); }, - onSwipeEnd: function (args1, args2) { - var e, data; + onSwipeEnd(args1, args2) { + let e, data; e = args1; data = args1.detail; - var index = e.target.dataset.item.index; + const { index } = e.target.dataset.item; data.swiped && this.setData({ swipeIndex: index }); }, - onButtonTap: function (data, e) { + onButtonTap(data, e) { console.log(data, e); }, }); diff --git a/compiled/wechat/demo/pages/SwipeActionWidth/index.js b/compiled/wechat/demo/pages/SwipeActionWidth/index.js index 712344ea3..30c65f898 100644 --- a/compiled/wechat/demo/pages/SwipeActionWidth/index.js +++ b/compiled/wechat/demo/pages/SwipeActionWidth/index.js @@ -21,17 +21,17 @@ Page({ ], swipeIndex: -1, }, - onSwipeStart: function () { + onSwipeStart() { this.setData({ swipeIndex: '' }); }, - onSwipeEnd: function (args1, args2) { - var e, data; + onSwipeEnd(args1, args2) { + let e, data; e = args1; data = args1.detail; - var index = e.target.dataset.item.index; + const { index } = e.target.dataset.item; data.swiped && this.setData({ swipeIndex: index }); }, - onButtonTap: function (data, e) { + onButtonTap(data, e) { console.log(data, e); }, }); diff --git a/compiled/wechat/demo/pages/Switch/index.js b/compiled/wechat/demo/pages/Switch/index.js index 137532034..4c72baeb5 100644 --- a/compiled/wechat/demo/pages/Switch/index.js +++ b/compiled/wechat/demo/pages/Switch/index.js @@ -2,15 +2,15 @@ Page({ data: { checked: true, }, - onChange: function (checked, e) { + onChange(checked, e) { console.log(checked); }, - handleChange: function (checked, e) { + handleChange(checked, e) { this.setData({ checked: checked.detail, }); }, - handleChangeByButton: function () { + handleChangeByButton() { console.log(this.data.checked); this.setData({ checked: !this.data.checked, diff --git a/compiled/wechat/demo/pages/TabBar/index.js b/compiled/wechat/demo/pages/TabBar/index.js index eb3335ad2..9ef5eab32 100644 --- a/compiled/wechat/demo/pages/TabBar/index.js +++ b/compiled/wechat/demo/pages/TabBar/index.js @@ -70,7 +70,7 @@ Page({ ], current: 0, }, - handleChange: function (index) { + handleChange(index) { this.setData({ current: index.detail }); }, }); diff --git a/compiled/wechat/demo/pages/Tabs/index.js b/compiled/wechat/demo/pages/Tabs/index.js index 3dc00bf10..6ff4731aa 100644 --- a/compiled/wechat/demo/pages/Tabs/index.js +++ b/compiled/wechat/demo/pages/Tabs/index.js @@ -38,20 +38,20 @@ Page({ }, ], }, - onChange: function (current) { + onChange(current) { current = current.detail; this.alert('current ' + current); }, - handleChange: function (current) { + handleChange(current) { current = current.detail; this.setData({ - current: current, + current, }); }, - onPlus: function () { + onPlus() { this.alert('plus'); }, - alert: function (content) { + alert(content) { //@ts-ignore wx.showToast({ title: content, diff --git a/compiled/wechat/demo/pages/TabsControl/index.js b/compiled/wechat/demo/pages/TabsControl/index.js index 450d098bc..027868d1e 100644 --- a/compiled/wechat/demo/pages/TabsControl/index.js +++ b/compiled/wechat/demo/pages/TabsControl/index.js @@ -1,75 +1,66 @@ -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; Page({ data: { current: 0, items: [], }, - onLoad: function () { - var items = new Array(3).fill(null).map(function (_, index) { + onLoad() { + const items = new Array(3).fill(null).map((_, index) => { return { - title: "Tab ".concat(index), - content: "Content of tab ".concat(index), + title: `Tab ${index}`, + content: `Content of tab ${index}`, }; }); this.setData({ - items: items, + items, }); }, - onChange: function (current) { + onChange(current) { current = current.detail; this.setData({ - current: current, + current, }); }, - onPrevTap: function () { + onPrevTap() { if (this.data.items.length === 0) { return; } - var current = this.data.current === 0 + const current = this.data.current === 0 ? this.data.items.length - 1 : this.data.current - 1; this.setData({ - current: current, + current, }); }, - onNextTap: function () { + onNextTap() { if (this.data.items.length === 0) { return; } - var current = this.data.current >= this.data.items.length - 1 + const current = this.data.current >= this.data.items.length - 1 ? 0 : this.data.current + 1; this.setData({ - current: current, + current, }); }, - onAddTap: function () { - var items = __spreadArray([], this.data.items, true); + onAddTap() { + const items = [...this.data.items]; items.push({ - title: "Tab ".concat(items.length), - content: "Content of tab ".concat(items.length), + title: `Tab ${items.length}`, + content: `Content of tab ${items.length}`, }); this.setData({ - items: items, + items, current: items.length - 1, }); }, - onMinusTap: function () { + onMinusTap() { if (this.data.items.length === 1) { return; } - var items = __spreadArray([], this.data.items, true); + const items = [...this.data.items]; items.splice(items.length - 1, 1); this.setData({ - items: items, + items, current: Math.min(this.data.current, items.length - 1), }); }, diff --git a/compiled/wechat/demo/pages/TabsElevator/index.js b/compiled/wechat/demo/pages/TabsElevator/index.js index a9c02a2fc..a5fac38f0 100644 --- a/compiled/wechat/demo/pages/TabsElevator/index.js +++ b/compiled/wechat/demo/pages/TabsElevator/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; Page({ data: { current: 0, @@ -65,68 +29,41 @@ Page({ ], scrollTop: 0, }, - updateRect: function () { - return __awaiter(this, void 0, void 0, function () { - var _a, _b; - var _this = this; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = this; - return [4 /*yield*/, Promise.all(this.data.items.map(function (item, index) { - return _this.getBoundingClientRect("#tab-item-".concat(index)); - }))]; - case 1: - _a.itemRectList = _c.sent(); - _b = this; - return [4 /*yield*/, this.getBoundingClientRect('#scroll-view')]; - case 2: - _b.scrollViewRect = _c.sent(); - return [2 /*return*/]; - } - }); - }); + async updateRect() { + this.itemRectList = await Promise.all(this.data.items.map((item, index) => this.getBoundingClientRect(`#tab-item-${index}`))); + this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - onReady: function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.updateRect()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); + async onReady() { + await this.updateRect(); }, - onTap: function () { + onTap() { this.tap = true; - var scrollTop = this.itemRectList[this.data.current].top - this.scrollViewRect.top; + const scrollTop = this.itemRectList[this.data.current].top - this.scrollViewRect.top; this.setData({ scrollTop: scrollTop + Math.random(), }); }, - onChange: function (current) { + onChange(current) { current = current.detail; this.tap = true; this.setData({ scrollTop: this.itemRectList[current].top - this.scrollViewRect.top + Math.random(), - current: current, + current, }); }, - onTouchStart: function () { + onTouchStart() { this.tap = false; }, - onScroll: function (e) { + onScroll(e) { if (this.tap) { return; } this.scrollTop = e.detail.scrollTop; - var scrollTop = this.scrollTop + this.itemRectList[0].top; - for (var i = 0; i < this.itemRectList.length - 1; i++) { - var item = this.itemRectList[i]; + const scrollTop = this.scrollTop + this.itemRectList[0].top; + for (let i = 0; i < this.itemRectList.length - 1; i++) { + const item = this.itemRectList[i]; if (scrollTop > item.top && scrollTop < this.itemRectList[i + 1].top && i !== this.data.current) { @@ -137,19 +74,19 @@ Page({ } } }, - getBoundingClientRect: function (id) { + getBoundingClientRect(id) { if (typeof my === 'undefined') { return this.getInstanceBoundingClientRect(this, id); } return this.getInstanceBoundingClientRect(my, id); }, - getInstanceBoundingClientRect: function (instance, selector) { - return new Promise(function (resolve) { + getInstanceBoundingClientRect(instance, selector) { + return new Promise((resolve) => { instance .createSelectorQuery() .select(selector) .boundingClientRect() - .exec(function (ret) { + .exec((ret) => { if (ret && ret[0]) { resolve(ret[0]); } diff --git a/compiled/wechat/demo/pages/TabsScroll/index.js b/compiled/wechat/demo/pages/TabsScroll/index.js index 97b0ecefc..604efbedf 100644 --- a/compiled/wechat/demo/pages/TabsScroll/index.js +++ b/compiled/wechat/demo/pages/TabsScroll/index.js @@ -2,15 +2,15 @@ Page({ data: { items: [], }, - onLoad: function () { - var items = new Array(30).fill(null).map(function (_, index) { + onLoad() { + const items = new Array(30).fill(null).map((_, index) => { return { - title: "Tab ".concat(index), + title: `Tab ${index}`, subTitle: "描述文案", }; }); this.setData({ - items: items, + items, }); }, }); diff --git a/compiled/wechat/demo/pages/TabsSticky/index.js b/compiled/wechat/demo/pages/TabsSticky/index.js index 44b85fd98..6054e403c 100644 --- a/compiled/wechat/demo/pages/TabsSticky/index.js +++ b/compiled/wechat/demo/pages/TabsSticky/index.js @@ -1,39 +1,3 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; Page({ data: { current: 0, @@ -65,60 +29,43 @@ Page({ }, ], }, - onPageScroll: function (e) { + onPageScroll(e) { this.pageScrollTop = e.scrollTop; }, - onReady: function () { - return __awaiter(this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - _a = this; - return [4 /*yield*/, this.getBoundingClientRect('.tabs')]; - case 1: - _a.tabsTop = (_b.sent()).top; - return [2 /*return*/]; - } - }); - }); + async onReady() { + this.tabsTop = (await this.getBoundingClientRect('.tabs')).top; }, - onChange: function (current) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - current = current.detail; - this.setData({ - current: current, - }); - this.scrollTo(Math.min(this.tabsTop, this.pageScrollTop)); - return [2 /*return*/]; - }); + async onChange(current) { + current = current.detail; + this.setData({ + current, }); + this.scrollTo(Math.min(this.tabsTop, this.pageScrollTop)); }, - scrollTo: function (scrollTop) { + scrollTo(scrollTop) { if (typeof my === 'undefined') { //@ts-ignore return wx.pageScrollTo({ - scrollTop: scrollTop, + scrollTop, }); } my.pageScrollTo({ - scrollTop: scrollTop, + scrollTop, }); }, - getBoundingClientRect: function (id) { + getBoundingClientRect(id) { if (typeof my === 'undefined') { return this.getInstanceBoundingClientRect(this, id); } return this.getInstanceBoundingClientRect(my, id); }, - getInstanceBoundingClientRect: function (instance, selector) { - return new Promise(function (resolve) { + getInstanceBoundingClientRect(instance, selector) { + return new Promise((resolve) => { instance .createSelectorQuery() .select(selector) .boundingClientRect() - .exec(function (ret) { + .exec((ret) => { if (ret && ret[0]) { resolve(ret[0]); } diff --git a/compiled/wechat/demo/pages/TabsSwiper/index.js b/compiled/wechat/demo/pages/TabsSwiper/index.js index 3cd37eeb2..94ecb393e 100644 --- a/compiled/wechat/demo/pages/TabsSwiper/index.js +++ b/compiled/wechat/demo/pages/TabsSwiper/index.js @@ -19,15 +19,15 @@ Page({ }, ], }, - onSwipeChange: function (e) { + onSwipeChange(e) { this.setData({ current: e.detail.current, }); }, - onChange: function (current) { + onChange(current) { current = current.detail; this.setData({ - current: current, + current, }); }, }); diff --git a/compiled/wechat/demo/pages/TabsVertical/index.js b/compiled/wechat/demo/pages/TabsVertical/index.js index 8ce8a0eec..46d4e1e60 100644 --- a/compiled/wechat/demo/pages/TabsVertical/index.js +++ b/compiled/wechat/demo/pages/TabsVertical/index.js @@ -4,22 +4,22 @@ Page({ scrollTop: 0, items: [], }, - onLoad: function () { - var items = []; - for (var i = 0; i < 20; i++) { + onLoad() { + const items = []; + for (let i = 0; i < 20; i++) { items.push({ - title: "\u7B2C".concat(i + 1, "\u9879"), - content: "\u7B2C".concat(i + 1, "\u9879 Est voluptate sunt consequat laboris proident eu ut qui incididunt sint sint pariatur qui. Ut labore in duis labore cupidatat in ad quis duis aliquip irure occaecat officia reprehenderit consectetur. Enim consequat veniam nulla. Enim do nisi cillum aute pariatur ex dolor mollit ut nisi. Irure non pariatur anim Lorem ad do in elit irure minim exercitation. Dolor aliquip nisi adipisicing sunt adipisicing sunt nisi ad in non laboris in magna dolore. Fugiat aliqua labore elit occaecat consequat. Ipsum officia excepteur anim sint ipsum exercitation laborum. Excepteur exercitation ea occaecat cupidatat et consectetur exercitation non. Incididunt aliqua esse velit nisi ullamco. Do dolore ad ut. Esse ad tempor aliqua cillum consequat occaecat enim dolore enim aliquip aliquip irure. Id aliquip qui nulla dolor dolore et est. Non adipisicing mollit consequat magna sit laborum mollit nulla est consequat. Veniam in eu nisi ex sint deserunt ad sit consequat excepteur qui. Ea est sint adipisicing ea aliqua eiusmod amet pariatur officia ex voluptate. Consectetur in ipsum cillum nulla minim quis aute consequat. Et adipisicing officia nostrud id reprehenderit tempor. Laborum anim aliqua ut enim et pariatur elit tempor tempor incididunt deserunt nulla deserunt enim. Esse deserunt pariatur veniam sunt fugiat irure ullamco excepteur et Lorem. Sit adipisicing nisi consectetur nulla qui sint culpa. In aute cupidatat ad consequat proident est non sint ullamco dolor nisi irure fugiat amet deserunt. Laboris nostrud tempor aute non cillum magna labore ipsum duis ut dolor velit. Qui proident dolor occaecat consequat qui laboris sit est culpa excepteur aliqua pariatur veniam irure voluptate. Cillum adipisicing deserunt nisi quis anim fugiat ipsum incididunt veniam laboris et eiusmod minim. Tempor esse ex reprehenderit occaecat velit non do magna consequat consequat exercitation tempor elit. Ea pariatur irure laborum ipsum reprehenderit sunt sit minim excepteur pariatur magna deserunt aliqua velit non. Culpa irure dolore commodo quis do. Nulla ea consectetur ullamco deserunt laborum consectetur. Amet sunt in esse cupidatat excepteur veniam do. Est quis commodo consequat reprehenderit reprehenderit. Magna laboris dolor dolor laborum. Culpa officia dolor labore aute commodo ex nisi incididunt officia in aute incididunt voluptate. Do nisi dolore ea veniam adipisicing voluptate reprehenderit ea proident aliquip. Labore enim in minim. Aliquip cillum do consequat labore Lorem exercitation. Laborum anim aute in nisi aliqua nulla commodo nostrud laborum. Lorem cillum ut cillum laborum occaecat consequat elit duis. Dolore dolor deserunt nisi dolore laborum sit ea deserunt ipsum dolor ut sit minim. Reprehenderit esse consectetur dolore esse nostrud. Commodo laborum tempor magna cillum Lorem ad qui nisi consequat sit in amet veniam. Ex pariatur eiusmod labore aute id dolor et sunt cupidatat id et non proident enim sint. Duis duis id in et in incididunt Lorem veniam aliquip. Culpa duis deserunt eiusmod laborum labore ea non sit eu ipsum eu."), + title: `第${i + 1}项`, + content: `第${i + 1}项 Est voluptate sunt consequat laboris proident eu ut qui incididunt sint sint pariatur qui. Ut labore in duis labore cupidatat in ad quis duis aliquip irure occaecat officia reprehenderit consectetur. Enim consequat veniam nulla. Enim do nisi cillum aute pariatur ex dolor mollit ut nisi. Irure non pariatur anim Lorem ad do in elit irure minim exercitation. Dolor aliquip nisi adipisicing sunt adipisicing sunt nisi ad in non laboris in magna dolore. Fugiat aliqua labore elit occaecat consequat. Ipsum officia excepteur anim sint ipsum exercitation laborum. Excepteur exercitation ea occaecat cupidatat et consectetur exercitation non. Incididunt aliqua esse velit nisi ullamco. Do dolore ad ut. Esse ad tempor aliqua cillum consequat occaecat enim dolore enim aliquip aliquip irure. Id aliquip qui nulla dolor dolore et est. Non adipisicing mollit consequat magna sit laborum mollit nulla est consequat. Veniam in eu nisi ex sint deserunt ad sit consequat excepteur qui. Ea est sint adipisicing ea aliqua eiusmod amet pariatur officia ex voluptate. Consectetur in ipsum cillum nulla minim quis aute consequat. Et adipisicing officia nostrud id reprehenderit tempor. Laborum anim aliqua ut enim et pariatur elit tempor tempor incididunt deserunt nulla deserunt enim. Esse deserunt pariatur veniam sunt fugiat irure ullamco excepteur et Lorem. Sit adipisicing nisi consectetur nulla qui sint culpa. In aute cupidatat ad consequat proident est non sint ullamco dolor nisi irure fugiat amet deserunt. Laboris nostrud tempor aute non cillum magna labore ipsum duis ut dolor velit. Qui proident dolor occaecat consequat qui laboris sit est culpa excepteur aliqua pariatur veniam irure voluptate. Cillum adipisicing deserunt nisi quis anim fugiat ipsum incididunt veniam laboris et eiusmod minim. Tempor esse ex reprehenderit occaecat velit non do magna consequat consequat exercitation tempor elit. Ea pariatur irure laborum ipsum reprehenderit sunt sit minim excepteur pariatur magna deserunt aliqua velit non. Culpa irure dolore commodo quis do. Nulla ea consectetur ullamco deserunt laborum consectetur. Amet sunt in esse cupidatat excepteur veniam do. Est quis commodo consequat reprehenderit reprehenderit. Magna laboris dolor dolor laborum. Culpa officia dolor labore aute commodo ex nisi incididunt officia in aute incididunt voluptate. Do nisi dolore ea veniam adipisicing voluptate reprehenderit ea proident aliquip. Labore enim in minim. Aliquip cillum do consequat labore Lorem exercitation. Laborum anim aute in nisi aliqua nulla commodo nostrud laborum. Lorem cillum ut cillum laborum occaecat consequat elit duis. Dolore dolor deserunt nisi dolore laborum sit ea deserunt ipsum dolor ut sit minim. Reprehenderit esse consectetur dolore esse nostrud. Commodo laborum tempor magna cillum Lorem ad qui nisi consequat sit in amet veniam. Ex pariatur eiusmod labore aute id dolor et sunt cupidatat id et non proident enim sint. Duis duis id in et in incididunt Lorem veniam aliquip. Culpa duis deserunt eiusmod laborum labore ea non sit eu ipsum eu.`, }); } this.setData({ - items: items, + items, }); }, - onChange: function (current) { + onChange(current) { current = current.detail; this.setData({ - current: current, + current, scrollTop: Math.random(), }); }, diff --git a/compiled/wechat/demo/pages/TabsVerticalElevator/index.js b/compiled/wechat/demo/pages/TabsVerticalElevator/index.js index b76b5e23f..ce7424a99 100644 --- a/compiled/wechat/demo/pages/TabsVerticalElevator/index.js +++ b/compiled/wechat/demo/pages/TabsVerticalElevator/index.js @@ -1,105 +1,42 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; Page({ data: { current: 0, - items: new Array(20).fill(0).map(function (_, i) { + items: new Array(20).fill(0).map((_, i) => { return { - title: "\u7B2C".concat(i + 1, "\u9879"), + title: `第${i + 1}项`, content: 'Est voluptate sunt consequat laboris proident eu ut qui incididunt sint sint pariatur qui. Ut labore in duis labore cupidatat in ad quis duis aliquip irure occaecat officia reprehenderit consectetur. Enim consequat veniam nulla. Enim do nisi cillum aute pariatur ex dolor mollit ut nisi. Irure non pariatur anim Lorem ad do in elit irure minim exercitation. Dolor aliquip nisi adipisicing sunt adipisicing sunt nisi ad in non laboris in magna dolore. Fugiat aliqua labore elit occaecat consequat. Ipsum officia excepteur anim sint ipsum exercitation laborum. Excepteur exercitation ea occaecat cupidatat et consectetur exercitation non. Incididunt aliqua esse velit nisi ullamco. Do dolore ad ut. Esse ad tempor aliqua cillum consequat occaecat enim dolore enim aliquip aliquip irure. Id aliquip qui nulla dolor dolore et est. Non adipisicing mollit consequat magna sit laborum mollit nulla est consequat. Veniam in eu nisi ex sint deserunt ad sit consequat excepteur qui. Ea est sint adipisicing ea aliqua eiusmod amet pariatur officia ex voluptate. Consectetur in ipsum cillum nulla minim quis aute consequat. Et adipisicing officia nostrud id reprehenderit tempor. Laborum anim aliqua ut enim et pariatur elit tempor tempor incididunt deserunt nulla deserunt enim. Esse deserunt pariatur veniam sunt fugiat irure ullamco excepteur et Lorem. Sit adipisicing nisi consectetur nulla qui sint culpa. In aute cupidatat ad consequat proident est non sint ullamco dolor nisi irure fugiat amet deserunt. Laboris nostrud tempor aute non cillum magna labore ipsum duis ut dolor velit. Qui proident dolor occaecat consequat qui laboris sit est culpa excepteur aliqua pariatur veniam irure voluptate. Cillum adipisicing deserunt nisi quis anim fugiat ipsum incididunt veniam laboris et eiusmod minim. Tempor esse ex reprehenderit occaecat velit non do magna consequat consequat exercitation tempor elit. Ea pariatur irure laborum ipsum reprehenderit sunt sit minim excepteur pariatur magna deserunt aliqua velit non. Culpa irure dolore commodo quis do. Nulla ea consectetur ullamco deserunt laborum consectetur. Amet sunt in esse cupidatat excepteur veniam do. Est quis commodo consequat reprehenderit reprehenderit. Magna laboris dolor dolor laborum. Culpa officia dolor labore aute commodo ex nisi incididunt officia in aute incididunt voluptate. Do nisi dolore ea veniam adipisicing voluptate reprehenderit ea proident aliquip. Labore enim in minim. Aliquip cillum do consequat labore Lorem exercitation. Laborum anim aute in nisi aliqua nulla commodo nostrud laborum. Lorem cillum ut cillum laborum occaecat consequat elit duis. Dolore dolor deserunt nisi dolore laborum sit ea deserunt ipsum dolor ut sit minim. Reprehenderit esse consectetur dolore esse nostrud. Commodo laborum tempor magna cillum Lorem ad qui nisi consequat sit in amet veniam. Ex pariatur eiusmod labore aute id dolor et sunt cupidatat id et non proident enim sint. Duis duis id in et in incididunt Lorem veniam aliquip. Culpa duis deserunt eiusmod laborum labore ea non sit eu ipsum eu.', }; }), scrollTop: 0, }, - updateRect: function () { - return __awaiter(this, void 0, void 0, function () { - var _a, _b; - var _this = this; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = this; - return [4 /*yield*/, Promise.all(this.data.items.map(function (item, index) { - return _this.getBoundingClientRect("#tab-item-".concat(index)); - }))]; - case 1: - _a.itemRectList = _c.sent(); - _b = this; - return [4 /*yield*/, this.getBoundingClientRect('#scroll-view')]; - case 2: - _b.scrollViewRect = _c.sent(); - return [2 /*return*/]; - } - }); - }); + async updateRect() { + this.itemRectList = await Promise.all(this.data.items.map((item, index) => this.getBoundingClientRect(`#tab-item-${index}`))); + this.scrollViewRect = await this.getBoundingClientRect('#scroll-view'); }, - onReady: function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.updateRect()]; - case 1: - _a.sent(); - return [2 /*return*/]; - } - }); - }); + async onReady() { + await this.updateRect(); }, - onChange: function (current) { + onChange(current) { current = current.detail; this.tap = true; this.setData({ scrollTop: this.itemRectList[current].top - this.scrollViewRect.top + Math.random(), - current: current, + current, }); }, - onTouchStart: function () { + onTouchStart() { this.tap = false; }, - onScroll: function (e) { + onScroll(e) { if (this.tap) { return; } this.scrollTop = e.detail.scrollTop; - var scrollTop = this.scrollTop + this.itemRectList[0].top; - for (var i = 0; i < this.itemRectList.length; i++) { - var item = this.itemRectList[i]; + const scrollTop = this.scrollTop + this.itemRectList[0].top; + for (let i = 0; i < this.itemRectList.length; i++) { + const item = this.itemRectList[i]; if (scrollTop > item.top && (!this.itemRectList[i + 1] || scrollTop < this.itemRectList[i + 1].top) && @@ -111,19 +48,19 @@ Page({ } } }, - getBoundingClientRect: function (id) { + getBoundingClientRect(id) { if (typeof my === 'undefined') { return this.getInstanceBoundingClientRect(this, id); } return this.getInstanceBoundingClientRect(my, id); }, - getInstanceBoundingClientRect: function (instance, selector) { - return new Promise(function (resolve) { + getInstanceBoundingClientRect(instance, selector) { + return new Promise((resolve) => { instance .createSelectorQuery() .select(selector) .boundingClientRect() - .exec(function (ret) { + .exec((ret) => { if (ret && ret[0]) { resolve(ret[0]); } diff --git a/compiled/wechat/demo/pages/Toast/index.js b/compiled/wechat/demo/pages/Toast/index.js index 16a908ab4..caf1a5bce 100644 --- a/compiled/wechat/demo/pages/Toast/index.js +++ b/compiled/wechat/demo/pages/Toast/index.js @@ -10,9 +10,8 @@ Page({ toast8Show: false, toast9Show: false, }, - handleShowToast: function (e) { - var _a; - var index = e.target.dataset.index; + handleShowToast(e) { + const { index } = e.target.dataset; this.setData({ toast1Show: false, toast2Show: false, @@ -22,16 +21,15 @@ Page({ toast6Show: false, toast7Show: false }); - this.setData((_a = {}, - _a["toast".concat(index, "Show")] = true, - _a)); + this.setData({ + [`toast${index}Show`]: true + }); console.log(this.data); }, - handleCloseToast: function (e) { - var _a; - var index = e.target.dataset.index; - this.setData((_a = {}, - _a["toast".concat(index, "Show")] = false, - _a)); + handleCloseToast(e) { + const { index } = e.target.dataset; + this.setData({ + [`toast${index}Show`]: false + }); } }); diff --git a/compiled/wechat/demo/pages/index/index.js b/compiled/wechat/demo/pages/index/index.js index 85e353738..836bf53e0 100644 --- a/compiled/wechat/demo/pages/index/index.js +++ b/compiled/wechat/demo/pages/index/index.js @@ -2,34 +2,34 @@ import { componentList, allComponents } from '../../utils/constants'; Page({ data: { - componentList: componentList, + componentList, finding: false, searchResult: [], }, - onShow: function () { + onShow() { this.setData({ finding: false, searchResult: [], }); }, - onClearSearch: function () { + onClearSearch() { this.setData({ finding: false, searchResult: [], }); }, - onSearch: function (e) { + onSearch(e) { e = e.detail; if (e.length > 0) { - var result_1 = []; - allComponents.forEach(function (searchKey) { + const result = []; + allComponents.forEach((searchKey) => { if (searchKey.name.toLowerCase().match(e)) { - result_1.push(searchKey); + result.push(searchKey); } }); this.setData({ finding: true, - searchResult: result_1, + searchResult: result, }); } else { @@ -39,7 +39,7 @@ Page({ }); } }, - listPress: function (e) { + listPress(e) { console.log('11'); if (typeof my === 'undefined') { console.log('navigateTo', e.currentTarget.dataset.url); diff --git a/compiled/wechat/demo/utils/constants.js b/compiled/wechat/demo/utils/constants.js index 3f731c937..98aad38f7 100644 --- a/compiled/wechat/demo/utils/constants.js +++ b/compiled/wechat/demo/utils/constants.js @@ -1,13 +1,4 @@ -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -export var componentList = [ +export const componentList = [ { type: '通用', list: [ @@ -449,4 +440,4 @@ export var componentList = [ ], }, ]; -export var allComponents = componentList.reduce(function (re, v) { return __spreadArray(__spreadArray([], re, true), v.list, true); }, []); +export const allComponents = componentList.reduce((re, v) => [...re, ...v.list], []); diff --git a/scripts/mini-compiler.ts b/scripts/mini-compiler.ts index d04975dfc..abc38b8d8 100644 --- a/scripts/mini-compiler.ts +++ b/scripts/mini-compiler.ts @@ -328,7 +328,7 @@ export async function compileAntdMini(watch: boolean) { }); miniCompiler({ - tsconfig: resolve(__dirname, '..', 'tsconfig.wechat.json'), + tsconfig: resolve(__dirname, '..', 'tsconfig.wechat.demo.json'), source: resolve(__dirname, '..', 'demo'), dest: resolve(__dirname, '..', 'compiled', 'wechat', 'demo'), watch, diff --git a/tsconfig.wechat.demo.json b/tsconfig.wechat.demo.json new file mode 100644 index 000000000..8fb629d56 --- /dev/null +++ b/tsconfig.wechat.demo.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "target": "ES2019", + "importHelpers": false + } +}