refactor: 统一API请求路径并优化请求逻辑

将多个页面中的API请求路径统一为相对路径,并在`utils/login.js`中自动补全为完整URL。优化了请求方法,默认为POST,同时支持GET请求。简化了代码结构,提高了代码的可维护性和一致性。
This commit is contained in:
2025-04-10 19:01:02 +08:00
parent 764df18ad0
commit 1af84dc1ee
11 changed files with 235 additions and 247 deletions

View File

@@ -21,7 +21,7 @@ Page({
var n = this;
wx.showLoading({
title: ""
}), e.request(t.globalData.config.user.log, {}, !0).then(function(t) {
}), e.request('/miniprogram/user', {}, !0).then(function(t) {
if (wx.hideLoading(), 200 != t.code) return wx.showModal({
title: "提示",
content: t.message
@@ -71,7 +71,7 @@ Page({
success: function(uploadRes) {
var data = JSON.parse(uploadRes.data);
if (data.code == 200) {
e.request('https://t-jm.v0750.com/miniprogram/user/update', {
e.request('/miniprogram/user/update', {
avatar: data.data.url
}, true).then(function(res) {
if (res.code == 200) {
@@ -101,7 +101,8 @@ Page({
placeholderText: '请输入新昵称',
success: function(res) {
if (res.confirm && res.content) {
e.request('https://t-jm.v0750.com/miniprogram/user/update', {
// 发送请求到后端,更新用户昵称
e.request('/miniprogram/user/update', {
nickname: res.content
}, true).then(function(res) {
if (res.code == 200) {