调用jsonReturn,
/**
* 生成调账单,状态获取
*/
public function getStatusCreateDebugBill(){
$endStatus = Paas::request('/sim/finance/statement/getStatusByStatement', []);
$statusMessage = array(
'26022' => '正常处理中。',
'26024' => '生成台账失败。',
'26026' => '生成台账成功。'
);
foreach ($statusMessage as $key => $value) {
if ($endStatus['status'] == $key) {
$endStatus['info'] = $value;
}
}
return jsonReturn($endStatus, '', 200);
}
commen中的代码:
function jsonReturn($data, $info = '', $status)
{
//返回前端的数据格式
$res = [
'status' => $status,
'info' => $info,
'data' => $data
];
//防跨域问题
$header = [
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Headers' => 'Origin, No-Cache, X-responseed-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expiresponse, Content-Type, X-E4M-With,userId,token,AppID,cacheKey,languageType',
'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, DELETE',
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Max-Age' => '0',
'XDomainRequestAllowed' => '1',
//'Referer Policy' => 'no-referrer-when-downgrade',
];
return json($res, 200, $header);
}