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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import {
getToken
} from './token.js'
import $api from '@/api/api.js'
let requests = { } ;
const noLogin = [
'YO' ,
'ReportInfo' ,
'ReportList' ,
'ReportContrast' ,
'AnalysisTypeList' ,
'ReportAnalysis' ,
'ReportDown' ,
'HospitalExtraReportStatus' ,
'PrepareCheckReport'
]
const getParams = ( key ) => {
const pages = getCurrentPages ( ) ;
if ( pages . length === 0 ) return false ;
const currentPage = pages [ pages . length - 1 ] ;
// uni-app 中页面参数统一在 options 里( H5 的 query / 小程序的 options)
const value = currentPage . options ? . [ key ] ;
return value || false ;
} ;
export const $post = async ( {
url ,
data = { }
} ) => {
console . log ( data )
let token = getToken ( ) ? getToken ( ) : '' ;
if ( noLogin . indexOf ( url ) === - 1 && token === '' ) {
uni . $lu . toast ( "请登录" )
return false
}
if ( requests [ url ] ) return false ;
requests [ url ] = true
data . hospital = getParams ( 'hospital' ) || '4'
let res = await uni . request ( {
url : $api ( url ) ,
method : 'post' ,
data ,
header : {
Authorization : 'Bearer ' + token
}
} ) ;
requests [ url ] = false
if ( ! ! res && res . data != '' ) {
return res . data
} else {
uni . $lu . toast ( "请求发生错误" )
return false
}
}