12 |
- "use strict";var P=Object.defineProperty;var k=(a,e,t)=>e in a?P(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var u=(a,e,t)=>(k(a,typeof e!="symbol"?e+"":e,t),t);const d=require("./vendor.js"),n=class n{static addExcludePath(e){this.excludePaths.push(e)}static addExcludePage(e){this.excludePages.push(e)}static isCurrentPageExcluded(){const e=getCurrentPages();if(e.length===0)return!1;const t=e[e.length-1],s=t.route||t.__route__;return this.excludePages.some(o=>s.includes(o)||o.includes(s))}static isPathExcluded(e){return this.excludePaths.some(t=>t instanceof RegExp?t.test(e):e.includes(t)||t.includes(e))}http(e,t={},s,o,x=!0){let f="https://live.test.ylrztop.com/live-api";const r=x&&!n.isPathExcluded(e)&&!n.isCurrentPageExcluded();return r&&n.loadingCount===0&&d.index.showLoading({title:"加载中",mask:!0}),r&&n.loadingCount++,new Promise((l,m)=>{let C=d.index.getStorageSync("AppToken");var g="application/x-www-form-urlencoded";o!=null&&(g=o),d.index.request({header:{"Content-Type":g,AppToken:C},url:`${f}${e}`,data:t,method:s,success:i=>{if(i.code==401){let h=getCurrentPages(),p=h[h.length-1];if(p!=null&&p.route=="/pages/home/index"){l(i.data);return}d.index.reLaunch({url:"/pages/home/index"});return}i.token&&d.index.setStorageSync("AppToken",i.token),l(i.data)},fail:i=>{m(i)},complete:i=>{r&&(n.loadingCount--,n.loadingCount<=0&&(d.index.hideLoading(),n.loadingCount=0))}})})}};u(n,"loadingCount",0),u(n,"excludePaths",[]),u(n,"excludePages",[]);let c=n;exports.Request=c;
- //# sourceMappingURL=../../.sourcemap/mp-weixin/common/request.js.map
|