From b22ad6c8a1dff42538dc97224ac273589f63a30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=B5=E7=A7=B0=E9=87=8D=E8=A6=81=E5=90=97?= Date: Wed, 12 May 2021 16:54:51 +0800 Subject: [PATCH 1/3] vcx --- .../qiun-data-charts/qiun-data-charts.vue" | 63 ++++++++++++++----- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git "a/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" "b/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" index dbcf19c..64196d7 100644 --- "a/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" +++ "b/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" @@ -202,6 +202,33 @@ function getFormatDate(date) { var lastMoveTime = null; +/** + * 防抖 + * + * @param {Object} fn 要执行的方法 + * @param {Object} wait 防抖多少秒 + * + * 在 vue 中使用(注意:不能使用箭头函数,否则this指向不对,并且不能再次封装如: + * move(){ // 错误调用方式 + * debounce(function () { + * console.log(this.title); + * }, 1000)}); + * 应该直接使用:() + * move: debounce(function () {// 正确调用方式 + * console.log(this.title); + * }, 1000) + */ +export function debounce(fn, wait) { + let timer; + return function() { + clearTimeout(timer); + timer = setTimeout(() => { + fn.apply(this, arguments) // 把参数传进去 + }, wait); + } +} + + export default { name: 'qiun-data-charts', mixins: [uniCloud.mixinDatacom], @@ -423,22 +450,26 @@ export default { this.beforeInit(); }) // #ifndef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || APP-PLUS - uni.onWindowResize(res => { - if (this.mixinDatacomLoading == true) { - return; - } - let errmsg = this.mixinDatacomErrorMessage - if(errmsg !== null && errmsg !== 'null' && errmsg !== ''){ - return; - } - setTimeout(() => { - if(this.echarts){ - this.echartsResize = !this.echartsResize - }else{ - this.resizeHandler() - } - }, 200); - }); + let time = 200; + // #ifdef H5 + time = 400; + // #endif + uni.onWindowResize( + debounce(function (res) { + if (this.mixinDatacomLoading == true) { + return; + } + let errmsg = this.mixinDatacomErrorMessage; + if (errmsg !== null && errmsg !== 'null' && errmsg !== '') { + return; + } + if (this.echarts) { + this.echartsResize = !this.echartsResize; + } else { + this.resizeHandler(); + } + }, time) + ); // #endif }, destroyed(){ -- Gitee From 400f383dcf131f67a60cd8ad3a97ef24189689b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=B5=E7=A7=B0=E9=87=8D=E8=A6=81=E5=90=97?= Date: Wed, 12 May 2021 17:01:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=98=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/qiun-data-charts/qiun-data-charts.vue" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" "b/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" index 64196d7..9ddf0f7 100644 --- "a/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" +++ "b/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" @@ -452,7 +452,7 @@ export default { // #ifndef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || APP-PLUS let time = 200; // #ifdef H5 - time = 400; + time = 400; // #endif uni.onWindowResize( debounce(function (res) { -- Gitee From a8597b261a3f7f438d7ade7055e89e1c3386c447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=B5=E7=A7=B0=E9=87=8D=E8=A6=81=E5=90=97?= Date: Wed, 12 May 2021 17:21:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=98=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qiun-data-charts/qiun-data-charts.vue" | 60 +++++++++---------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git "a/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" "b/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" index 9ddf0f7..82dbfec 100644 --- "a/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" +++ "b/qiun-data-charts\357\274\210uni-modules\357\274\211/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue" @@ -201,34 +201,32 @@ function getFormatDate(date) { } var lastMoveTime = null; - /** * 防抖 - * + * * @param {Object} fn 要执行的方法 * @param {Object} wait 防抖多少秒 - * + * * 在 vue 中使用(注意:不能使用箭头函数,否则this指向不对,并且不能再次封装如: * move(){ // 错误调用方式 * debounce(function () { * console.log(this.title); - * }, 1000)}); + * }, 1000)}); * 应该直接使用:() * move: debounce(function () {// 正确调用方式 * console.log(this.title); * }, 1000) */ export function debounce(fn, wait) { - let timer; - return function() { - clearTimeout(timer); - timer = setTimeout(() => { - fn.apply(this, arguments) // 把参数传进去 - }, wait); - } + let timer; + return function() { + clearTimeout(timer); + timer = setTimeout(() => { + fn.apply(this, arguments); // 把参数传进去 + }, wait); + }; } - export default { name: 'qiun-data-charts', mixins: [uniCloud.mixinDatacom], @@ -450,26 +448,24 @@ export default { this.beforeInit(); }) // #ifndef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || APP-PLUS - let time = 200; - // #ifdef H5 - time = 400; - // #endif - uni.onWindowResize( - debounce(function (res) { - if (this.mixinDatacomLoading == true) { - return; - } - let errmsg = this.mixinDatacomErrorMessage; - if (errmsg !== null && errmsg !== 'null' && errmsg !== '') { - return; - } - if (this.echarts) { - this.echartsResize = !this.echartsResize; - } else { - this.resizeHandler(); - } - }, time) - ); + const time = this.inH5 ? 500 : 200; + const _this = this; + uni.onWindowResize( + debounce(function(res) { + if (_this.mixinDatacomLoading == true) { + return; + } + let errmsg = _this.mixinDatacomErrorMessage; + if (errmsg !== null && errmsg !== 'null' && errmsg !== '') { + return; + } + if (_this.echarts) { + _this.echartsResize = !_this.echartsResize; + } else { + _this.resizeHandler(); + } + }, time) + ); // #endif }, destroyed(){ -- Gitee