2024-10-01 09:15:35 +08:00
|
|
|
"use strict";var e=Object.defineProperty,t=Object.defineProperties,o=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,n=(t,o,r)=>o in t?e(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r;const i=require("../common/vendor.js"),l=require("../store/user.js"),u=e=>{const u=l.useUserStore();return new Promise(((l,d)=>{var p,c;i.index.request((p=((e,t)=>{for(var o in t||(t={}))s.call(t,o)&&n(e,o,t[o]);if(r)for(var o of r(t))a.call(t,o)&&n(e,o,t[o]);return e})({},e),c={url:e.url,dataType:"json",success(t){t.statusCode>=200&&t.statusCode<300?l(t.data):401===t.statusCode?(u.clearUserInfo(),i.index.navigateTo({url:"/modules/pet/login/index"}),d(t)):(!e.hideErrorToast&&i.index.showToast({icon:"none",title:t.data.message||"请求错误"}),d(t))},fail(e){i.index.showToast({icon:"none",title:"网络错误,换个网络试试"}),d(e)}},t(p,o(c))))}))},d=(e,t)=>u({url:e,query:t,method:"GET"}),p=(e,t,o)=>u({url:e,query:o,data:t,method:"POST"}),c=(e,t,o="file",r={})=>{const s=l.useUserStore();return new Promise(((a,n)=>{i.index.uploadFile({url:e,filePath:t,name:o,formData:r,header:{satoken:`Bearer ${s.token}`},timeout:1e4,success(e){e.statusCode>=200&&e.statusCode<300?a(JSON.parse(e.data)):401===e.statusCode?(s.clearUserInfo(),i.index.navigateTo({url:"/modules/pet/login/index"}),n(e)):(i.index.showToast({icon:"none",title:"上传失败,"+(JSON.parse(e.data).message||"请稍后重试")}),n(e))},fail(e){i.index.showToast({icon:"none",title:"网络错误,换个网络试试"}),n(e)}})}))},h=(e,t,...o)=>{return r=exports,s=[e,t,...o],a=function*(e,t,o="file",r={}){const s=[];for(const n of t)try{const t=yield c(e,n,o,r);200==t.code&&s.push(t.data.url)}catch(a){}return s},new Promise(((e,t)=>{var o=e=>{try{i(a.next(e))}catch(o){t(o)}},n=e=>{try{i(a.throw(e))}catch(o){t(o)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,n);i((a=a.apply(r,s)).next())}));var r,s,a};u.uploadFile=c,u.uploadMultipleFiles=h,u.get=d,u.post=p,exports.http=u,exports.httpGet=d,exports.httpPost=p,exports.httpUploadFile=c,exports.httpUploadMultipleFiles=h;
|