Merge branch 'main' of http://git.zihai.cn/szj1219/JiaZhiQianYan-MiniProgram
# Conflicts: # unpackage/dist/dev/.sourcemap/mp-weixin/app.js.map # unpackage/dist/dev/.sourcemap/mp-weixin/common/assets.js.map # unpackage/dist/dev/.sourcemap/mp-weixin/components/LCCalendar/LCCalendar.js.map # unpackage/dist/dev/.sourcemap/mp-weixin/pages/geGuCenter/geGuCenter.js.map # unpackage/dist/dev/.sourcemap/mp-weixin/pagesStock/stockCenterDetails/bkydmx.js.map # unpackage/dist/dev/.sourcemap/mp-weixin/uni_modules/uni-popup/components/uni-popup/uni-popup.js.map # unpackage/dist/dev/mp-weixin/common/assets.js # unpackage/dist/dev/mp-weixin/common/vendor.js # unpackage/dist/dev/mp-weixin/components/zysj-view/zysj-view.js # unpackage/dist/dev/mp-weixin/pages/geGuCenter/geGuCenter.wxml # unpackage/dist/dev/mp-weixin/pages/mine/mine.js # unpackage/dist/dev/mp-weixin/pages/ztfx/ztfx.js # unpackage/dist/dev/mp-weixin/pagesMine/vip/vip.js # unpackage/dist/dev/mp-weixin/pagesMine/vipMeal/vipMeal.js # unpackage/dist/dev/mp-weixin/pagesStock/stockCenterDetails/bkydmx.js # unpackage/dist/dev/mp-weixin/pagesStock/stockCenterDetails/bkydmx.wxml # unpackage/dist/dev/mp-weixin/pagesStock/stockCenterDetails/cwDetails.js # unpackage/dist/dev/mp-weixin/pagesStock/stockCenterDetails/stockCenterDetails.js # unpackage/dist/dev/mp-weixin/pagesStock/stockCenterDetails/ztfx.js
This commit is contained in:
141
unpackage/dist/dev/mp-weixin/request/http.js
vendored
141
unpackage/dist/dev/mp-weixin/request/http.js
vendored
@@ -1,141 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../common/vendor.js");
|
||||
let baseURL = "";
|
||||
{
|
||||
baseURL = "https://api.valuefrontier.cn:5002";
|
||||
}
|
||||
function get(url, params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let token = common_vendor.index.getStorageSync("token");
|
||||
common_vendor.index.showLoading({
|
||||
title: "加载中"
|
||||
});
|
||||
let baseUrl = baseURL;
|
||||
if (url.indexOf("concept-api") > -1 || url.indexOf("news-api") > -1 || url.indexOf("report-api") > -1) {
|
||||
baseUrl = "https://api.valuefrontier.cn";
|
||||
}
|
||||
common_vendor.index.request({
|
||||
url: baseUrl + url,
|
||||
data: params,
|
||||
header: {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Authorization": token ? "Bearer " + token : ""
|
||||
},
|
||||
method: "GET",
|
||||
success: (response) => {
|
||||
common_vendor.index.__f__("log", "at request/http.js:44", response);
|
||||
common_vendor.index.hideLoading();
|
||||
if (response.data.code == 401) {
|
||||
common_vendor.index.removeStorageSync("token");
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/login/login"
|
||||
});
|
||||
} else {
|
||||
resolve(response.data);
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "请求失败",
|
||||
icon: "error"
|
||||
});
|
||||
reject(error.response);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function post(url, params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let token = common_vendor.index.getStorageSync("token");
|
||||
let isJson = 0;
|
||||
let isFile = 0;
|
||||
if (params) {
|
||||
isJson = params.isJson;
|
||||
}
|
||||
if (params) {
|
||||
isFile = params.isFile;
|
||||
}
|
||||
common_vendor.index.showLoading({
|
||||
title: "加载中"
|
||||
});
|
||||
if (isFile) {
|
||||
let token2 = common_vendor.index.getStorageSync("token");
|
||||
common_vendor.index.uploadFile({
|
||||
url: baseURL + url,
|
||||
filePath: params.avatar,
|
||||
name: "avatar",
|
||||
header: {
|
||||
"Authorization": token2 ? "Bearer " + token2 : ""
|
||||
},
|
||||
formData: params,
|
||||
success: (response) => {
|
||||
common_vendor.index.__f__("log", "at request/http.js:100", response);
|
||||
common_vendor.index.hideLoading();
|
||||
if (response.data.code == 401) {
|
||||
common_vendor.index.removeStorageSync("token");
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/login/login"
|
||||
});
|
||||
reject(response.data);
|
||||
} else {
|
||||
resolve(response.data);
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
common_vendor.index.__f__("log", "at request/http.js:113", "上传失败" + error.errMsg);
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "请求失败",
|
||||
icon: "error"
|
||||
});
|
||||
reject();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let baseUrl = baseURL;
|
||||
if (url.indexOf("concept-api") > -1 || url.indexOf("api/market/trade/batch") > -1) {
|
||||
baseUrl = "https://api.valuefrontier.cn";
|
||||
}
|
||||
common_vendor.index.request({
|
||||
url: baseUrl + url,
|
||||
data: params,
|
||||
header: {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": isJson ? "application/json" : isFile ? "multipart/form-data" : "application/x-www-form-urlencoded",
|
||||
"Authorization": token ? "Bearer " + token : ""
|
||||
},
|
||||
method: "POST",
|
||||
success: (response) => {
|
||||
common_vendor.index.hideLoading();
|
||||
if (params && params.isNotNeedLogin)
|
||||
;
|
||||
else {
|
||||
common_vendor.index.__f__("log", "at request/http.js:144", response.data);
|
||||
if (response.data.code == 401) {
|
||||
common_vendor.index.removeStorageSync("token");
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/login/login"
|
||||
});
|
||||
reject(response.data);
|
||||
} else {
|
||||
resolve(response.data);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "请求失败",
|
||||
icon: "error"
|
||||
});
|
||||
reject(error.response);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.get = get;
|
||||
exports.post = post;
|
||||
//# sourceMappingURL=../../.sourcemap/mp-weixin/request/http.js.map
|
||||
Reference in New Issue
Block a user