function.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * mobile公共方法
  4. *
  5. * 公共方法
  6. *
  7. */
  8. defined('InShopNC') or exit('Access Invalid!');
  9. require_once(BASE_CORE_PATH . '/framework/libraries/model.php');
  10. require_once(BASE_DATA_PATH . '/model/member.model.php');
  11. function joutput_data($datas,$type='')
  12. {
  13. $data = [];
  14. $code = errcode::Success;
  15. $data['code'] = $code;
  16. $data['message'] = errcode::msg($code);
  17. $data['datas'] = $datas;
  18. if($_SESSION['client_type'] != 'ajax')
  19. {
  20. $contents = ob_get_clean();
  21. if(!empty($contents)) {
  22. Log::record($contents,Log::ERR);
  23. }
  24. ob_start();
  25. }
  26. if(!empty($type) && $type == 'web') {
  27. echo(json_encode($data,JSON_UNESCAPED_UNICODE));
  28. } else {
  29. echo(json_encode($data));
  30. }
  31. }
  32. function joutput_error($code,$message = '',$type='')
  33. {
  34. if(empty($message)) {
  35. $message = errcode::msg($code);
  36. }
  37. $data = [];
  38. $data['code'] = $code;
  39. $data['message'] = $message;
  40. $data['datas'] = [];
  41. if($_SESSION['client_type'] != 'ajax')
  42. {
  43. $contents = ob_get_clean();
  44. if(!empty($contents)) {
  45. Log::record($contents,Log::ERR);
  46. }
  47. ob_start();
  48. }
  49. Log::record("code = {$code} message = {$message}",Log::ERR);
  50. if(!empty($type) && $type == 'web') {
  51. echo(json_encode($data,JSON_UNESCAPED_UNICODE));
  52. } else {
  53. echo(json_encode($data,JSON_UNESCAPED_UNICODE));
  54. }
  55. }