commons目录下加 request.js
// 引入配置文件
import config from "./config.js";
import User from "./user.js";
export default{
config:{
baseUrl:config.webUrl,
header:{
'Content-Type':'application/json;charset=UTF-8',
'Content-Type':'application/x-www-form-urlencoded',
'Authorization':uni.getStorageSync('token'),
},
data: {},
method: "GET",
dataType: "json",
withCredentials: true
},
request(options = {}){
// options.header ||
options.header = this.config.header;
options.method = options.method || this.config.method;
options.dataType = options.dataType || this.config.dataType;
options.url = this.config.baseUrl+options.url;
// TODO:token增加等操作
if (options.Authorization) {
// 验证用户是否登录
if (!this.checkToken(options.checkToken)) return;
// 验证用户操作权限(验证是否绑定手机号码)
if (!