request增加query参数

This commit is contained in:
TOP糯米 2023-03-08 11:09:43 +08:00
parent 9cad71a511
commit 155713faae
1 changed files with 4 additions and 2 deletions

View File

@ -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: {