【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);
}
【效果预览:】