public function indexAction()
 {
     $cid = intval($this->param('cid', 0));
     if (!$cid) {
         $url = ComTool::url("index");
         ComTool::redirect($url);
     }
     $category = CategoryData::getById($cid);
     if (!$category) {
         $url = ComTool::url("index");
         ComTool::redirect($url);
     }
     $curTime = time();
     $category['start_time'] = '09:00:00';
     $category['end_time'] = '24:00:00';
     $startTime = strtotime($category['start_time']);
     $endTime = strtotime($category['end_time']);
     $notStart = $curTime < $startTime ? true : false;
     //true为尚未开始
     $isOver = $curTime > $endTime ? true : false;
     //true为已结束
     $isOn = !$notStart && !$isOver;
     //过程中
     $this->assign('notStart', $notStart);
     $this->assign('isOver', $isOver);
     $this->assign('isOn', $isOn);
     $group = GroupData::getById($category['group_id']);
     $store = StoreData::getById($category['store_id']);
     $goods = GoodsData::getsByCid($cid);
     $cart = array();
     $cart = $this->getCart($cid);
     $this->assign('category', $category);
     $this->assign('group', $group);
     $this->assign('store', $store);
     $this->assign('goods', $goods);
     $this->assign('products', $cart['products']);
     $this->assign('totalPrice', $cart['totalPrice']);
     $this->display();
 }
示例#2
0
 /**
  * 购物车
  */
 public function cartAction()
 {
     $gid = intval($this->param('g', 0));
     if (!$gid) {
         exit('empty g');
     }
     $cid = intval($this->param('c', 0));
     if (!$cid) {
         exit('empty c');
     }
     $category = CategoryData::getById($cid);
     if ($category['group_id'] != $gid) {
         exit('该圈子无此分类');
     }
     $cart = array();
     $cart = $this->getCart($cid);
     $group = GroupData::getById($category['group_id']);
     $currUser = $currUserGroup = array();
     $isLogin = $this->isLogin();
     if ($isLogin) {
         $currUser = $this->getCurrentUser();
         $userGroups = UserGroupData::getGroupsByUid($currUser['id']);
         foreach ($userGroups as $userGroup) {
             if ($group['id'] == $userGroup['group_id']) {
                 $currUserGroup = $userGroup;
                 break;
             }
         }
     }
     $store = StoreData::getById($category['store_id']);
     $this->assign('group', $group);
     $this->assign('store', $store);
     $this->assign('currUser', $currUser);
     $this->assign('currUserGroup', $currUserGroup);
     $this->assign('category', $category);
     $this->assign('products', $cart['products']);
     $this->assign('totalPrice', $cart['totalPrice']);
     $this->display();
 }