From 155713faae7781b43ef312cd9298312a8e9aa465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TOP=E7=B3=AF=E7=B1=B3?= <1130395124@qq.com> Date: Wed, 8 Mar 2023 11:09:43 +0800 Subject: [PATCH] =?UTF-8?q?request=E5=A2=9E=E5=8A=A0query=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/request.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/request.js b/src/core/request.js index c5d14c5..a60b67e 100644 --- a/src/core/request.js +++ b/src/core/request.js @@ -20,11 +20,13 @@ function findRule(name) { } const request = async (args) => { - let rule = findRule(args.api || {}); + let rule = findRule(args.api || ''); if (JSON.stringify(rule) === "{}") { throw "找不到API:" + args.api; } + let query = (args.query) ? '?' + args.query : ''; + if (typeof rule.auth !== "undefined" && rule.auth === true && !$store.state.user.token) { $store.commit("user/showLoginModal", true); throw "需要登录"; @@ -37,7 +39,7 @@ const request = async (args) => { }; const [error, response] = await uni.request({ - url: prototype.$config.root + rule.url, + url: prototype.$config.root + rule.url + query, method: rule.method || 'post', data: args.data, header: {