コード例 #1
0
 public function secgoods()
 {
     $id = $_REQUEST["id"];
     if (!$id) {
         $this->error("没有商品id");
     }
     //商品的信息
     $SecGoodModel = new \Home\Model\SeckillGoodModel();
     $goods = $SecGoodModel->get_good_info($id);
     if ($goods[0]["start"] > time()) {
         $this->redirect("seckill");
     }
     if (!$goods) {
         $this->error("出现了一些错误。");
     }
     //print_r($goods);
     $this->assign("result", $goods);
     //商品的type类型
     $SecTypeModel = new \Home\Model\SecTypeModel();
     //echo $goods->type_id;
     $type_info = $SecTypeModel->search_name_by_id($goods[0]["type_id"]);
     $this->assign("type_name", $type_info[0]["typename"]);
     //商品的图片
     $SecPicModel = new \Home\Model\SecGoodPicModel();
     //print_r($SecPicModel->get_pic($id));
     $this->assign("photo", $SecPicModel->get_pic($id));
     $this->display("Good/secgoods");
 }
コード例 #2
0
 public function collect()
 {
     //根据商品的类型来渲染
     $type = $_REQUEST["type"];
     if (!isset($type)) {
         $type = 40;
     }
     $CollectModel = new \Home\Model\CollectionModel();
     //查找各种商品类型的个数
     list($all, $common, $seckill, $teambuy, $trial, $book) = $CollectModel->get_num($this->id);
     $this->assign("all", $all);
     $this->assign("common", $common);
     $this->assign("seckill", $seckill);
     $this->assign("teambuy", $teambuy);
     $this->assign("trial", $trial);
     $this->assign("book", $book);
     //首先查找所有满足条件的藏品
     //然后根据藏品id找到现在的藏品的信息
     $goods = $CollectModel->get_collect($type, $this->id);
     $GoodModel = new \Home\Model\GoodModel();
     $SeckillGoodModel = new \Home\Model\SeckillGoodModel();
     $TeamGoodModel = new \Home\Model\TeamGoodsModel();
     $TrialGoodModel = new \Home\Model\TrialGoodsModel();
     $BookGoodModel = new \Home\Model\BookGoodsModel();
     $result_array = array();
     foreach ($goods as $piece) {
         $good_id = $piece["collect_id"];
         switch ($piece["collect_type"]) {
             case "1":
                 $good_info = $GoodModel->get_info($good_id);
                 break;
             case "3":
                 $good_info = $SeckillGoodModel->get_info($good_id);
                 break;
             case "4":
                 $good_info = $TeamGoodModel->get_info($good_id);
                 break;
             case "5":
                 $good_info = $TrialGoodModel->get_info($good_id);
                 break;
             case "6":
                 $good_info = $BookGoodModel->get_info($good_id);
                 break;
             default:
                 return false;
         }
         array_push($result_array, array("collect_info" => $piece, "good_info" => $good_info));
     }
     $this->assign("result", $result_array);
     $this->display();
 }