| | |
| | | import storage from './storage' // 缓存封装 |
| | | import store from '../store/index.js' |
| | | export default { |
| | | console(options) { |
| | | if (config.debug) { |
| | |
| | | // loading加载 |
| | | uni.showLoading({ title: '加载中', }) |
| | | // 拼接路劲,下面的配置文件会提到 |
| | | // uni.showLoading({ title: baseUrl, }) |
| | | options.url = baseUrl + '' + options.url |
| | | // 请求方式 |
| | | options.method = options.method || 'GET' |
| | | // 判断登录是否 |
| | | if (isLogin) { |
| | | let token = storage.get('token') |
| | | console.log('tokentoken', token) |
| | | let token = uni.getStorageSync('tonken') |
| | | console.log('token', token) |
| | | if (token !== null) { |
| | | // options.header["token"] = token; |
| | | options.header = { |
| | |
| | | return new Promise((resolve, reject) => { |
| | | uni.request(options).then(data => { |
| | | var [error, res] = data |
| | | if (error != null) { |
| | | if (error !== null) { |
| | | reject(error) |
| | | } else { |
| | | // 相应拦截、根据后端的状态码来写,可以自行判断和封装 |