|
@@ -5,5 +5,62 @@
|
|
|
* 公共方法
|
|
|
*
|
|
|
*/
|
|
|
-
|
|
|
defined('InShopNC') or exit('Access Invalid!');
|
|
|
+
|
|
|
+
|
|
|
+require_once(BASE_CORE_PATH . '/framework/libraries/model.php');
|
|
|
+require_once(BASE_DATA_PATH . '/model/member.model.php');
|
|
|
+require_once(BASE_HELPER_PATH . '/errcode.php');
|
|
|
+
|
|
|
+function joutput_data($datas,$type='')
|
|
|
+{
|
|
|
+ $data = [];
|
|
|
+
|
|
|
+ $code = errcode::Success;
|
|
|
+ $data['code'] = $code;
|
|
|
+ $data['message'] = errcode::msg($code);
|
|
|
+
|
|
|
+ $data['datas'] = $datas;
|
|
|
+
|
|
|
+ if($_SESSION['client_type'] != 'ajax')
|
|
|
+ {
|
|
|
+ $contents = ob_get_clean();
|
|
|
+ if(!empty($contents)) {
|
|
|
+ Log::record($contents,Log::ERR);
|
|
|
+ }
|
|
|
+ ob_start();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($type) && $type == 'web') {
|
|
|
+ echo(json_encode($data,JSON_UNESCAPED_UNICODE));
|
|
|
+ } else {
|
|
|
+ echo(json_encode($data));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function joutput_error($code,$message = '',$type='')
|
|
|
+{
|
|
|
+ if(empty($message)) {
|
|
|
+ $message = errcode::msg($code);
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $data['code'] = $code;
|
|
|
+ $data['message'] = $message;
|
|
|
+ $data['datas'] = [];
|
|
|
+
|
|
|
+ if($_SESSION['client_type'] != 'ajax')
|
|
|
+ {
|
|
|
+ $contents = ob_get_clean();
|
|
|
+ if(!empty($contents)) {
|
|
|
+ Log::record($contents,Log::ERR);
|
|
|
+ }
|
|
|
+ ob_start();
|
|
|
+ }
|
|
|
+ Log::record("code = {$code} message = {$message}",Log::ERR);
|
|
|
+ if(!empty($type) && $type == 'web') {
|
|
|
+ echo(json_encode($data,JSON_UNESCAPED_UNICODE));
|
|
|
+ } else {
|
|
|
+ echo(json_encode($data,JSON_UNESCAPED_UNICODE));
|
|
|
+ }
|
|
|
+}
|