diff --git a/common/plugins/msbUniRequest.js b/common/plugins/msbUniRequest.js index deb1eb9..272a883 100644 --- a/common/plugins/msbUniRequest.js +++ b/common/plugins/msbUniRequest.js @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2022-03-17 16:36:59 * @LastEditors: ch - * @LastEditTime: 2022-04-20 11:57:58 + * @LastEditTime: 2022-04-20 16:07:24 * @Description: 针对uniapp request请求做了一次封装,使用思维参考axios * * @@ -70,7 +70,6 @@ class MsbUniRequest { return option } return new Promise((resolve, reject)=>{ - console.log(option); uni.request({ ...option, success: res => { diff --git a/common/utils/requset.js b/common/utils/requset.js index 45158e8..f7aea60 100644 --- a/common/utils/requset.js +++ b/common/utils/requset.js @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2022-03-17 17:42:32 * @LastEditors: ch - * @LastEditTime: 2022-04-20 15:34:09 + * @LastEditTime: 2022-04-20 19:49:51 * @Description: 项目接口请求统一处理器,返回一个需要token和不需要token的请求封装方法 */ @@ -53,10 +53,15 @@ let repeatFlag = []; * @param {*} option */ const repeatVerify = (option)=>{ - if(repeatFlag.includes(JSON.stringify(option))){ + let flag = { + url : option.url, + method : option.method, + data : option.data + } + if(repeatFlag.includes(JSON.stringify(flag))){ return Promise.reject({message:'请勿频繁操作'}); } - repeatFlag.push(JSON.stringify(option)); + repeatFlag.push(JSON.stringify(flag)); return false; }; /** @@ -64,9 +69,16 @@ const repeatVerify = (option)=>{ * @param {*} option */ const clearRepeat = (option) =>{ + + console.log(repeatFlag) repeatFlag = repeatFlag.filter( i => { - return i !== JSON.stringify(option) + return i !== JSON.stringify({ + url : option.url, + method : option.method, + data : option.data + }) }); + console.log(repeatFlag) } // 不需要token的接口封装 @@ -74,7 +86,6 @@ const MsbRequest = new MsbUniRequest(); MsbRequest.baseUrl = BASE_URL[ENV]; MsbRequest.use('request', (option) => { - console.log('option',option); if(option.header.repeat){ // 如果当前请求不允许重复调用,则检查重复请求,当前接口有正在请求则不发起请求 const isRepeatVerify = repeatVerify(option); diff --git a/h5/index.html b/h5/index.html index 8473316..461df0f 100644 --- a/h5/index.html +++ b/h5/index.html @@ -1,2 +1,2 @@