php根據訂單號 跟蹤物流
阿新 • • 發佈:2019-02-01
【html程式碼:】
<a href="follow?id=<? echo $order->id ?>" data-dialog="show_follow" data-height="350px" data-width="550px">[跟蹤物流]</a>
【js程式碼:】
//物流跟蹤 $(function (){ $('a[data-dialog=show_follow]').click(function (){ _this = this; window.top.art.dialog.open(_this.href,{ title:_this.title?_this.title:$(_this).text(), height:$(_this).attr('data-height'), width:$(_this).attr('data-width'), lock:true, }); return false; }); });
【php程式碼:】
/* 物流跟蹤 */ public function follow() { $id = $this->input->get('id'); $order = $this->sale_order_model->get_by_id($id); $url = $order->ex_follow; if (!$url || strstr($url, 'ERROR')) { if (!function_exists('curl_init')) {die('伺服器不支援分析');} if (!$order->ex_sn) {die('請先錄入單號');} $express = $this->sale_express_model->get_by_id($order->ex_id); if (!$express->kuaidi100_code) {die($express->name . '不支援查詢');} $key = 'e48a89f782b3fef3'; $url = (((('http://www.kuaidi100.com/applyurl?key=' . $key) . '&com=') . $express->kuaidi100_code) . '&nu=') . $order->ex_sn; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($curl, CURLOPT_TIMEOUT, 5); $get_content = curl_exec($curl); curl_close($curl); $this->sale_order_model->save($id, array('ex_follow' => $get_content)); $url = $get_content; } redirect($url); }
【效果預覽:】