From d957890002e533e14ff065e44990dbe2d0781315 Mon Sep 17 00:00:00 2001 From: mehaotian <490272692@qq.com> Date: Tue, 3 Sep 2019 10:41:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(stat):=20=E4=BF=AE=E5=A4=8D=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=A0=87=E9=A2=98=E4=B8=8E=E9=A1=B5=E9=9D=A2=20URL=20?= =?UTF-8?q?=E9=94=99=E4=B9=B1=E7=9A=84=20BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-stat/dist/index.js | 71 +++++++++++++++------------------ packages/uni-stat/src/stat.js | 71 +++++++++++++++------------------ 2 files changed, 66 insertions(+), 76 deletions(-) diff --git a/packages/uni-stat/dist/index.js b/packages/uni-stat/dist/index.js index 55f059937..83c5b966e 100644 --- a/packages/uni-stat/dist/index.js +++ b/packages/uni-stat/dist/index.js @@ -484,13 +484,6 @@ class Util { t: getTime(), p: this.statData.p }; - if (getPlatformName() === 'n' && this.statData.p === 'a') { - setTimeout(() => { - this.request(options); - }, 200); - return - } - this.request(options); } @@ -511,12 +504,6 @@ class Util { t: getTime(), p: this.statData.p }; - if (getPlatformName() === 'n' && this.statData.p === 'a') { - setTimeout(() => { - this.request(options, type); - }, 200); - return - } this.request(options, type); } _sendEventRequest({ @@ -642,31 +629,39 @@ class Util { this.imageRequest(optionsData); return } - - uni.request({ - url: STAT_URL, - method: 'POST', - // header: { - // 'content-type': 'application/json' // 默认值 - // }, - data: optionsData, - success: () => { - // if (process.env.NODE_ENV === 'development') { - // console.log('stat request success'); - // } - }, - fail: (e) => { - // if (process.env.NODE_ENV === 'development') { - // console.log('stat request fail', e); - // } - if (++this._retry < 3) { - setTimeout(() => { - this.request(data); - }, 1000); - } - } - }); - + + if (getPlatformName() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this._sendRequest(optionsData); + }, 200); + return + } + this._sendRequest(optionsData); + } + _sendRequest(optionsData){ + uni.request({ + url: STAT_URL, + method: 'POST', + // header: { + // 'content-type': 'application/json' // 默认值 + // }, + data: optionsData, + success: () => { + // if (process.env.NODE_ENV === 'development') { + // console.log('stat request success'); + // } + }, + fail: (e) => { + // if (process.env.NODE_ENV === 'development') { + // console.log('stat request fail', e); + // } + if (++this._retry < 3) { + setTimeout(() => { + this.request(data); + }, 1000); + } + } + }); } /** * h5 请求 diff --git a/packages/uni-stat/src/stat.js b/packages/uni-stat/src/stat.js index be1487c9a..bb501cb71 100644 --- a/packages/uni-stat/src/stat.js +++ b/packages/uni-stat/src/stat.js @@ -219,13 +219,6 @@ class Util { t: getTime(), p: this.statData.p } - if (getPlatformName() === 'n' && this.statData.p === 'a') { - setTimeout(() => { - this.request(options); - }, 200) - return - } - this.request(options); } @@ -246,12 +239,6 @@ class Util { t: getTime(), p: this.statData.p } - if (getPlatformName() === 'n' && this.statData.p === 'a') { - setTimeout(() => { - this.request(options, type) - }, 200) - return - } this.request(options, type) } _sendEventRequest({ @@ -377,31 +364,39 @@ class Util { this.imageRequest(optionsData) return } - - uni.request({ - url: STAT_URL, - method: 'POST', - // header: { - // 'content-type': 'application/json' // 默认值 - // }, - data: optionsData, - success: () => { - // if (process.env.NODE_ENV === 'development') { - // console.log('stat request success'); - // } - }, - fail: (e) => { - // if (process.env.NODE_ENV === 'development') { - // console.log('stat request fail', e); - // } - if (++this._retry < 3) { - setTimeout(() => { - this.request(data); - }, 1000); - } - } - }); - + + if (getPlatformName() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this._sendRequest(optionsData); + }, 200) + return + } + this._sendRequest(optionsData) + } + _sendRequest(optionsData){ + uni.request({ + url: STAT_URL, + method: 'POST', + // header: { + // 'content-type': 'application/json' // 默认值 + // }, + data: optionsData, + success: () => { + // if (process.env.NODE_ENV === 'development') { + // console.log('stat request success'); + // } + }, + fail: (e) => { + // if (process.env.NODE_ENV === 'development') { + // console.log('stat request fail', e); + // } + if (++this._retry < 3) { + setTimeout(() => { + this.request(data); + }, 1000); + } + } + }); } /** * h5 请求 -- GitLab