private function cart() { $product = new productModel(); if (Tools::isSession("oneUser")) { Tools::Redirect("只有注册会员才可以购买", "?", 2, 1); return false; } if (isset($_POST['send'])) { $product->id = $_POST["id"]; $oneProduct = $product->getOneProduct(); $oneProduct->num = 1; if (isset($_SESSION['cart'][$oneProduct->id])) { //id号是cart下的一件商品; $_SESSION['cart'][$oneProduct->id]->num++; } else { //以商品的id为键名保存的对象 $_SESSION['cart'][$oneProduct->id] = $oneProduct; } } $cart = $_SESSION['cart']; $this->smarty->assign("cart", $cart); $sum = 0; foreach ($cart as $k => $v) { $sum += $v->price * $v->num; } $this->smarty->assign("sum", $sum); $_SESSION['sum'] = $sum; //Tools::dump($_POST); //Tools::dump($_SESSION); }
private function show() { $user = new userModel(); $upload = new UploadFile("pic", "public/uploads/member"); if (isset($_POST['send'])) { $user->id = $_POST['id']; $user->email = $_POST['email']; if ($_POST['pwd'] == $_POST['newpwd']) { $user->pwd = $_POST['newpwd']; } else { $user->pwd = md5($_POST['newpwd']); } if (is_uploaded_file($_FILES['pic']['tmp_name'])) { if ($upload->upload("pic")) { $user->icon = $upload->getNewName(); } } else { $user->icon = $_POST['newpic']; //echo "没有上传".$_POST['newpic']; } //Tools::dump($_POST); if ($user->updateUser()) { //echo "ok"; Tools::Redirect("会员资料修改成功", $_SERVER['HTTP_REFERER']); } else { if ($user->updateUser() == 0) { Tools::Redirect("会员资料没有修改", $_SERVER['HTTP_REFERER']); //echo "not changed"; } else { Tools::Redirect("会员资料修改失败", $_SERVER['HTTP_REFERER'], 2); } } } $comment = new commentModel(); $article = new articleModel(); $product = new productModel(); $ask = new askModel(); $quiz = new quizModel(); if ($_GET['id']) { $user->id = $_GET['id']; $oneUser = $user->getOneUserByID(); $this->smarty->assign("oneUser", $oneUser); ///////////////////////////////// $comment->uid = $_GET['id']; $allComments = $comment->getAllCommentsByUID(); foreach ($allComments as $key => $value) { $article->id = $value->aid; $oneArticle = $article->getOneArticle(); $value->title = $oneArticle->title; } $product->uid = $_GET['id']; $allOrders = $product->getAllOrdersByUID(); foreach ($allOrders as $value) { $pids = explode(",", $value->pid); $str = null; foreach ($pids as $v) { $product->id = $v; //Tools::dump($v); $oneProduct = $product->getOneProduct(); //Tools::dump($oneProduct); $str .= $oneProduct->name . ","; } $str = rtrim($str, ","); //Tools::dump($str); $value->pid = $str; switch ($value->payed) { case 0: $value->payed = "<span style='color:red;'>[未付]</span>"; break; case 1: $value->payed = "<span style='color:green;'>[已付]</span>"; } switch ($value->sent) { case 0: $value->sent = "<span style='color:red;'>[未发货]</span>"; break; case 1: $value->sent = "<span style='color:green;'>[已发货]</span>"; } } $ask->aid = $_GET['id']; $allAsks = $ask->getAllAskByAID(); $this->smarty->assign("allAsks", $allAsks); $this->smarty->assign("allOrders", $allOrders); $this->smarty->assign("allComments", $allComments); $quiz->uid = $_GET["id"]; $allScores = $quiz->getAllScoresByUID(); $course = new courseModel(); foreach ($allScores as $key => $value) { $course->id = $value->cid; $oneCourse = $course->getOneCourse(); $value->cid = $oneCourse->name; } $this->smarty->assign("allScores", $allScores); } $this->smarty->assign("show", true); }
private function show() { parent::page($this->model->getAllOrdersTotal(), 5); $allOrders = $this->model->getAllOrders(); $product = new productModel(); foreach ($allOrders as $value) { $pids = explode(",", $value->pid); $str = null; foreach ($pids as $v) { $product->id = $v; //Tools::dump($v); $oneProduct = $product->getOneProduct(); //Tools::dump($oneProduct); $str .= $oneProduct->name . ","; } $str = rtrim($str, ","); //Tools::dump($str); $value->pid = $str; switch ($value->payed) { case 0: $value->payed = "<span style='color:red;'>[未付]</span>\r\n\t\t\t\t\t\t\t<a href='?a=order&action=state&flag=show&id=" . $value->id . "'>已付</a>"; break; case 1: $value->payed = "<span style='color:green;'>[已付]</span>\r\n\t\t\t\t\t\t\t<a href='?a=order&action=state&flag=hide&id=" . $value->id . "'>未付</a>"; } switch ($value->sent) { case 0: $value->sent = "<span style='color:red;'>[未发货]</span>\r\n\t\t\t\t\t\t\t<a href='?a=order&action=sent&flag=show&id=" . $value->id . "'>已发货</a>"; break; case 1: $value->sent = "<span style='color:green;'>[已发货]</span>\r\n\t\t\t\t\t\t\t<a href='?a=order&action=sent&flag=hide&id=" . $value->id . "'>未发货</a>"; } } $this->smarty->assign("data", $allOrders); $this->smarty->assign("show", true); }