//设置基地址
const baseURL = "https://meituan.thexxdd.cn/api";
import { Base64 } from "js-base64";
//Base64.encode(要加密的字符串);
//Base64.decode(要解密的字符串);
//定义ts接口
interface httpOptions {
url: string;
method: "GET" | "POST" | "PUT" | "DELETE";
data?: any;
}
//处理token的函数
const getToken = () => {
//读取token
const token = uni.getStorageSync("wxuser").user_Token || "";
//拼接冒号
const strtoken = token + ":";
//再加密
const encodeToke = Base64.encode(strtoken);
//再通过接拼"Basic "传递给后台
return "Basic " + encodeToke;
};
//返回类型
//基于Promise封装uni.request
const request = (options: httpOptions): Promise<any&