123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import {
- fetch,
- fetchfile
- } from "./fetch/interceptos.js"
- const obj = {
- headerGET: {
- "Content-type": 'application/x-www-from-urlencoded'
- },
- headerPOST: {
- "Content-type": 'application/json'
- },
- headerFORM: {
- "Content-type": 'multipart/form-data'
- }
- }
- const http = {
- // get请求
- get(url: String, params: Object) {
- let opt = {
- header: obj['headerGET'],
- method: "GET",
- data: params
- }
- return fetch(url, opt)
- },
- // post请求
- post(action: String, params: Object) {
- let opt = {
- header: obj['headerPOST'],
- method: "POST",
- data: params
- }
- if (params) {
- opt.data = {
- 'Method': action,
- 'Content': params
- }
- }
- let apiname = action;
- if (apiname.indexOf("Safe_") == 0) {
- apiname = "ExecuteSafe";
- }
- else {
- apiname = apiname === "Login" ? "Login" : "Execute"
- }
- return fetch(apiname, opt)
- },
- // post请求
- upload(action: String, params: Object) {
- return fetchfile(action, params)
- }
- }
- export default http
|