Authored by yangyang

更改order订单部分请求方式

... ... @@ -466,12 +466,24 @@ class HomeController extends AbstractAction
/*
* 我的订单页面
*/
public function orderAction() {
public function orderAction(){
$type = $this -> get('type',1);
$data = OrderModel::getNavs($type);
if(!empty($data)){
$order['navs'] = $data;
}
$this->_view->display('order', array(
'order' => $order
));
}
//ajax请求订单页面
public function getorderAction() {
//判断是不是ajax请求
// if (!$this->isAjax()) {
// $this->error();
// }
if (!$this->isAjax()) {
$this->error();
}
//获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论
$type = $this->get('type', 1);
$page = $this->get('page', 1);
... ... @@ -485,31 +497,13 @@ class HomeController extends AbstractAction
//调用模型层getOrder方法获得并处理数据
$data = OrderModel::getOrder($type, $page, $limit, $gender, $yh_channel, $uid);
//如果没有订单数据,就给一个随便逛逛链接
//print_r($data);
$order = array();
if (!empty($data)) {
$order['orders'] = $data;
} else {
$order['walkwayUrl'] = 'http://www.baidu.com';
}
$order['navs'] = array(
array(
'name' => '全部',
'active' => true,
'typeId' => '1'
),
array(
'name' => '待付款',
'typeId' => '2'
),
array(
'name' => '待发货',
'typeId' => '3'
),
array(
'name' => '待收货',
'typeId' => '4'
)
);
//渲染模板
$this->_view->display('order', array(
'order' => $order,
... ...
... ... @@ -121,5 +121,55 @@ class OrderModel
}
return $arr;
}
//根据type值设置nav属性
public function getNavs($type){
$nav = array(
array(
'name' => '全部',
'typeId' => '1'
),
array(
'name' => '待付款',
'typeId' => '2'
),
array(
'name' => '待发货',
'typeId' => '3'
),
array(
'name' => '待收货',
'typeId' => '4'
)
);
foreach($nav as $key => $vo){
switch ($type) {
case 1:
if($vo['typeId'] == 1){
$nav[$key]['active'] = true;
}
break;
case 2:
if($vo['typeId'] == 2){
$nav[$key]['active'] = true;
}
break;
case 3:
if($vo['typeId'] == 3){
$nav[$key]['active'] = true;
}
break;
case 4:
if($vo['typeId'] == 4){
$nav[$key]['active'] = true;
}
break;
default:
break;
}
}
return $nav;
}
}
... ...