"use strict";const e=require("../common/vendor.js");let o="";o="http://43.143.189.195:5002",exports.get=function(n,t){return new Promise(((i,a)=>{let d=e.index.getStorageSync("token");e.index.showLoading({title:"加载中"}),e.index.request({url:o+n,data:t,header:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded",Authorization:d?"Bearer "+d:""},method:"GET",success:o=>{console.log(o),e.index.hideLoading(),401==o.data.code?(e.index.removeStorageSync("token"),e.index.navigateTo({url:"/pages/login/login"})):i(o.data)},fail:o=>{e.index.hideLoading(),e.index.showToast({title:"请求失败",icon:"error"}),a(o.response)}})}))},exports.post=function(n,t){return new Promise(((i,a)=>{let d=e.index.getStorageSync("token"),r=0,s=0;if(t&&(r=t.isJson),t&&(s=t.isFile),e.index.showLoading({title:"加载中"}),s){let d=e.index.getStorageSync("token");e.index.uploadFile({url:o+n,filePath:t.avatar,name:"avatar",header:{Authorization:d?"Bearer "+d:""},formData:t,success:o=>{console.log(o),e.index.hideLoading(),401==o.data.code?(e.index.removeStorageSync("token"),e.index.navigateTo({url:"/pages/login/login"}),a(o.data)):i(o.data)},fail:o=>{console.log("上传失败"+o.errMsg),e.index.hideLoading(),e.index.showToast({title:"请求失败",icon:"error"}),a()}})}else{let l=o;n.indexOf("concept-api")>-1&&(l="https://valuefrontier.cn"),e.index.request({url:l+n,data:t,header:{Accept:"application/json","Content-Type":r?"application/json":s?"multipart/form-data":"application/x-www-form-urlencoded",Authorization:d?"Bearer "+d:""},method:"POST",success:o=>{e.index.hideLoading(),t&&t.isNotNeedLogin||(console.log(o.data),401==o.data.code?(e.index.removeStorageSync("token"),e.index.navigateTo({url:"/pages/login/login"}),a(o.data)):i(o.data))},fail:o=>{e.index.hideLoading(),e.index.showToast({title:"请求失败",icon:"error"}),a(o.response)}})}}))};
