/* * @Author: 廖明明 * @Date: 2022-03-30 15:54:48 * @LastEditors: 廖明明 * @LastEditTime: 2022-04-02 14:27:53 * @Description:后端服务入口文件 */ import config from "./config.js"; import "./auth.js"; import "./interceptor.js"; /** * @description:封装请求函数 * @param {string} url 接口地址,以”/“开头 * @param {object} data 请求参数 * @param {string} method 请求类型 * @param {object} header 请求头 * @return {promise} * @author: 廖明明 */ export function request({ url = "", data = {}, method = "GET", header = {} }) { return new Promise((resolve) => { uni.request({ method, url: config.baseUrl + url, data, header, dataType: "json", success(res) { resolve(res.data); }, fail(err) { uni.hideLoading(); uni.showToast({ icon: "none", title: "请求失败!", }); }, }); }); }