diff --git a/packages/uni-stat/dist/index.js b/packages/uni-stat/dist/index.js index 55f059937522aa16e41d4f60e0e738b465e9e947..83c5b966e31949943889809810876a4e5e4867a1 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 be1487c9a3ae83f43484eb911e3969e640218f53..bb501cb710c9d2f83e3485a52212de509e743994 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 请求