You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
703 B
JavaScript

import {
getToken
} from './token.js'
import $api from '@/api/api.js'
const noLogin = [
'User/login',
'Config/get',
'Carousel/list',
'Hospital/info',
'Combo/list',
'Buy/info',
'Combo/GetComboImageList',
'YO',
]
export const $post = async ({
url,
data = {}
}) => {
let token = getToken() ? getToken() : '';
if (noLogin.indexOf(url) === -1 && token === '') {
console.log("请登录,Url:"+url)
uni.$lu.toast("请登录")
return false
}
let res = await uni.request({
url: $api(url),
method: 'post',
data,
header: {
Authorization: 'Bearer ' + token
}
});
if (!!res && res.data != '') {
return res.data
} else {
uni.$lu.toast("请求发生错误")
return false
}
}