0 ? $day.'天' : ''; $hour = floor(($remain_time % (3600*24)) / 3600); $hour = $hour > 0 ? $hour.'小时' : ''; if($is_hour && $is_minutes) { $minutes = floor((($remain_time % (3600*24)) % 3600) / 60); $minutes = $minutes > 0 ? $minutes.'分钟' : ''; return $day.$hour.$minutes; } if($hour) { return $day.$hour; } return $day; } //获取全图片地址 $image_data function image_path($image_data){ if(empty($image_data)){ return $image_data; } if (strpos($image_data,'|')!==false){ $image_res = explode('|',$image_data); }elseif(strpos($image_data,',')!==false){ $image_res = explode(',',$image_data); }else{ $image_res = array($image_data); } return $image_res; } // 获取模板区域 function get_city_area() { $field=['id','pid','name']; $list=Db::table('store_area')->where('pid',0)->field($field)->select(); foreach ($list as $k=>&$v){ $v['children']= Db::table('store_area')->where('pid',$v['id'])->field($field)->select(); } return $list; } function http_curl($url,$type='get',$res='json',$arr=''){ $headers = array(); //根据API的要求,定义相对应的Content-Type array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8;application/json"); $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $type); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); $output = curl_exec($curl); curl_close($curl); if($res=='json'){ if($output === false){ //请求失败,返回错误信息 return curl_error($curl); }else{ //请求成功,返回信息 return json_decode($output,true); } } } // 获取物流信息 function get_delivery($send_no = 'JD0053309649641',$express_code=''){ error_reporting(E_ALL || ~E_NOTICE); $AppKey = 204008273; $AppSecret ='t9PavvfCeK5v2XidwyK5pWDp8b0hzMq4'; $AppCode ='47f640e3529d43e28365311a530db2b7';//开通服务后 买家中心-查看AppCode $host = "https://wuliu.market.alicloudapi.com";//api访问链接 $path = "/kdi";//API访问后缀 $method = "GET"; $body =''; $headers = array(); array_push($headers, "Authorization:APPCODE " . $AppCode); $querys = "no={$send_no}&type={$express_code}"; //参数写在这里 $url = $host . $path . "?" . $querys; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); if (1 == strpos("$" . $host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } $out_put = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); list($header, $body) = explode("\r\n\r\n", $out_put, 2); if ($httpCode == 200) { return json_decode($body,true)['result']; } else { return []; } } // 元石日志 function crystal_log($user_id,$crystal,$desc,$type,$rel_id=0) { $log_data = [ 'user_id' => $user_id, 'create_at' => date('Y-m-d H:i:s'), 'crystal' => $crystal, 'desc' => $desc, 'type' => $type, 'rel_id' => $rel_id, ]; Db::table('crystal_info')->insert($log_data); } // 实名认证 function user_certification($id_card,$name){ $host = "http://checkone.market.alicloudapi.com"; $path = "/chinadatapay/1882"; $method = "POST"; $appcode = "17fd1c7d9b1a439e8007f3675450c454"; $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); //根据API的要求,定义相对应的Content-Type array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8"); $bodys = "idcard=".$id_card."&name=".$name; $url = $host . $path; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); if (1 == strpos("$".$host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys); $res = curl_exec($curl); if($res){ $res = json_decode($res,true); if($res['data']['result'] == 1){ return 1; }else{ return 0; } }else{ return 0; } } // 刷新页面 function to_reload() { if(input('reloaded') !=1) { echo ""; } } function shoucang(){ $host = "http://180.76.141.31:8888/cz/call"; $method = "POST"; $headers = array(); array_push($headers, "Content-Type".":"."application/json; charset=UTF-8"); $bodys = array( 'key' => 'test2', 'userkey' => '12344', 'product' => json_encode(array('name'=>'test','count'=>7)) ); $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $host); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); if (1 == strpos("$".$host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($bodys)); $res = curl_exec($curl); var_dump($res);exit(); }