123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- "use strict";
- const common_vendor = require("../common/vendor.js");
- const config_config = require("../config/config.js");
- const stores_userDataManager = require("../stores/userDataManager.js");
- class http {
- //动态请求
- static DynamicRequest(api, post_data, call_back, isPost = true) {
- common_vendor.index.request({
- url: config_config.config.url_addr.Dynamic + api,
- data: post_data,
- method: isPost ? "POST" : "GET",
- header: {
- "token": stores_userDataManager.UserData().getUserToken()
- //自定义请求头信息
- },
- success: (res) => {
- if (call_back != null) {
- call_back(null, res);
- }
- },
- fail(res) {
- if (call_back != null) {
- call_back(res, null);
- }
- }
- });
- }
- //静态请求
- static StaticRequest(api, call_back) {
- common_vendor.index.request({
- dataType: "json",
- responseType: "json",
- url: api,
- method: "GET",
- success: (res) => {
- if (call_back != null) {
- call_back(null, res.data);
- }
- },
- fail(res) {
- if (call_back != null) {
- call_back(res, null);
- }
- }
- });
- }
- static getStaticText(api, call_back) {
- common_vendor.index.request({
- dataType: "text",
- responseType: "text",
- url: api,
- method: "GET",
- success: (res) => {
- if (call_back != null) {
- call_back(null, res.data);
- }
- },
- fail(res) {
- if (call_back != null) {
- call_back(res, null);
- }
- }
- });
- }
- }
- exports.http = http;
|