Esempio n. 1
0
<?php

$myCartObj = new Cart();
$myCartInfo = $myCartObj->getMyCart();
$siteConfig = new Config("site_config");
$callback = IReq::get('callback') ? urlencode(IFilter::act(IReq::get('callback'), 'url')) : '';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php 
echo $siteConfig->name;
?>
</title>
	<link type="image/x-icon" href="favicon.ico" rel="icon">
	<link rel="stylesheet" href="<?php 
echo IUrl::creatUrl("") . "views/" . $this->theme . "/skin/" . $this->skin . "/css/index.css";
?>
" />
	<script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/jquery/jquery-1.11.3.min.js"></script><script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/jquery/jquery-migrate-1.2.1.min.js"></script>
	<script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
Esempio n. 2
0
 public function cart_count()
 {
     //获取购物车中的商品和货品信息
     $cartObj = new Cart();
     $myCartInfo = $cartObj->getMyCart();
     return $this->goodsCount($myCartInfo);
 }
Esempio n. 3
0
 public function cart_count($id = '', $type = '', $buy_num = 1, $promo = '', $active_id = '')
 {
     //单品购买
     if ($id && $type) {
         $buyInfo = array($type => array('id' => array($id), 'data' => array($id => array('count' => $buy_num)), 'count' => $buy_num));
     } else {
         //获取购物车中的商品和货品信息
         $cartObj = new Cart();
         $buyInfo = $cartObj->getMyCart();
     }
     return $this->goodsCount($buyInfo, $promo, $active_id);
 }
Esempio n. 4
0
 function deposit_cart_set()
 {
     $is_ajax = IReq::get('is_ajax');
     //必须为登录用户
     if ($this->user['user_id'] == null) {
         $callback = "/simple/cart";
         $this->redirect('/simple/login?callback={$callback}');
     }
     //获取购物车中的信息
     $cartObj = new Cart();
     $myCartInfo = $cartObj->getMyCart();
     /*寄存的数据
     		格式:goods => array (id => count);
     		*/
     $depositArray = array();
     if (isset($myCartInfo['goods']['id']) && !empty($myCartInfo['goods']['id'])) {
         foreach ($myCartInfo['goods']['id'] as $id) {
             $depositArray['goods'][$id] = $myCartInfo['goods']['data'][$id]['count'];
         }
     }
     if (isset($myCartInfo['product']['id']) && !empty($myCartInfo['product']['id'])) {
         foreach ($myCartInfo['product']['id'] as $id) {
             $depositArray['product'][$id] = $myCartInfo['product']['data'][$id]['count'];
         }
     }
     if (empty($depositArray)) {
         $isError = true;
         $message = '您的购物车中没有商品';
     } else {
         $isError = false;
         $dataArray = array('user_id' => $this->user['user_id'], 'content' => serialize($depositArray), 'create_time' => ITime::getDateTime());
         $goodsCarObj = new IModel('goods_car');
         $goodsCarRow = $goodsCarObj->getObj('user_id = ' . $this->user['user_id']);
         $goodsCarObj->setData($dataArray);
         if (empty($goodsCarRow)) {
             $goodsCarObj->add();
         } else {
             $goodsCarObj->update('user_id = ' . $this->user['user_id']);
         }
         $message = '寄存成功';
     }
     //ajax方式
     if ($is_ajax == 1) {
         $result = array('isError' => $isError, 'message' => $message);
         echo JSON::encode($result);
     } else {
         //页面跳转
         $this->cart();
         if (isset($message)) {
             Util::showMessage($message);
         }
     }
 }
Esempio n. 5
0
 function deposit_cart_get()
 {
     //必须为登录用户
     if ($this->user['user_id'] == null) {
         $this->redirect('/simple/login?callback=/simple/cart');
     }
     $goodsCatObj = new IModel('goods_car');
     $goodsCarRow = $goodsCatObj->getObj('user_id = ' . $this->user['user_id']);
     if (isset($goodsCarRow['content'])) {
         $depositContent = unserialize($goodsCarRow['content']);
         //获取购物车中的信息
         $cartObj = new Cart();
         $myCartInfo = $cartObj->getMyCart();
         if (isset($depositContent['goods'])) {
             foreach ($depositContent['goods'] as $id => $count) {
                 if (!in_array($id, $myCartInfo['goods']['id']) && ($depositGoods = $cartObj->getUpdateCartData($myCartInfo, $id, $count, 'goods'))) {
                     $myCartInfo = $depositGoods;
                 }
             }
         }
         if (isset($depositContent['product'])) {
             foreach ($depositContent['product'] as $id => $count) {
                 if (!in_array($id, $myCartInfo['product']['id']) && ($depositProducts = $cartObj->getUpdateCartData($myCartInfo, $id, $count, 'product'))) {
                     $myCartInfo = $depositProducts;
                 }
             }
         }
     } else {
         $message = '您没有寄存任何商品';
     }
     //页面跳转
     if (isset($message)) {
         $this->cart(false);
         Util::showMessage($message);
     } else {
         $cartObj->setMyCart($myCartInfo);
         $this->cart(true);
     }
 }