7.10 增加登录页面,事件详情接口对接,我的点赞,关注收藏页面搭建,接口对接

This commit is contained in:
尚政杰
2025-07-10 18:08:16 +08:00
parent c4267a0e27
commit 58b3414bdd
356 changed files with 7710 additions and 978 deletions

View File

@@ -2,23 +2,28 @@
const common_vendor = require("../common/vendor.js");
let baseURL = "";
{
baseURL = "https://app.valuefrontier.cn";
baseURL = "http://43.143.189.195:5001";
}
function get(url, params) {
return new Promise((resolve, reject) => {
let token = common_vendor.index.getStorageSync("token");
common_vendor.index.showLoading({
title: "加载中"
});
common_vendor.index.request({
url: baseURL + url,
data: params,
header: {
"Accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded",
"token": token ? token : ""
"Authorization": token ? "Bearer " + token : ""
},
method: "GET",
success: (response) => {
common_vendor.index.__f__("log", "at request/http.js:34", response);
if (response.data.code == -200) {
common_vendor.index.__f__("log", "at request/http.js:37", response);
common_vendor.index.hideLoading();
if (response.data.code == 401) {
common_vendor.index.removeStorageSync("token");
common_vendor.index.navigateTo({
url: "/pages/login/login"
});
@@ -27,10 +32,102 @@ function get(url, params) {
}
},
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:93", 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:106", "上传失败" + error.errMsg);
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "请求失败",
icon: "error"
});
reject();
}
});
} else
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.__f__("log", "at request/http.js:126", JSON.parse(JSON.stringify(response)));
common_vendor.index.hideLoading();
if (params && params.isNotNeedLogin)
;
else {
common_vendor.index.__f__("log", "at request/http.js:132", 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