提交 d17bfd12 编写于 作者: R root

fecshop category product

上级 a3a9c089
......@@ -139,6 +139,12 @@ function thissubmit(thiss){
cate_id = jQuery(this).find("input").val();
cate_str += cate_id+",";
});
jQuery(".category_tree div.ckbox.indeterminate").each(function(){
cate_id = jQuery(this).find("input").val();
cate_str += cate_id+",";
});
jQuery(".inputcategory").val(cate_str);
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appfront\modules\Catalog;
use Yii;
use fecshop\app\appfront\modules\AppfrontModule;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Module extends AppfrontModule
{
public $blockNamespace;
......
<?php
/*
* 存放 一些基本的非数据库数据 如 html
* 都是数组
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appfront\modules\Catalog\block\category;
use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Index {
protected $_category;
......@@ -25,6 +32,8 @@ class Index {
return [
'title' => $this->_title,
'name' => Yii::$service->store->getStoreAttrVal($this->_category['name'],'name'),
'image' => $this->_category['image'] ? Yii::$service->category->image->getUrl($this->_category['image']) : '',
'description' => Yii::$service->store->getStoreAttrVal($this->_category['description'],'description'),
'products' => $this->getCategoryProductColl(),
//'content' => Yii::$service->store->getStoreAttrVal($this->_category['content'],'content'),
//'created_at' => $this->_category['created_at'],
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appfront\modules\Catalog\block\category;
use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Price {
public $price;
public $special_price;
public function getLastData(){
$price_info = Yii::$service->product->price->formatPrice($this->price);
$return = [
'price' => [
'symbol' => $price_info['symbol'],
'value' => $price_info['value'],
'code' => $price_info['code'],
]
];
if($this->special_price){
$special_price_info = Yii::$service->product->price->formatPrice($this->special_price);
$return['special_price'] = [
'symbol' => $special_price_info['symbol'],
'value' => $special_price_info['value'],
'code' => $special_price_info['code'],
];
}
return $return;
}
}
\ No newline at end of file
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appfront\modules\Catalog\controllers;
use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
use fecshop\app\appfront\modules\AppfrontController;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class CategoryController extends AppfrontController
{
public function init(){
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appfront\modules\Catalog\helpers;
use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
use fecshop\app\appfront\modules\AppfrontController;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Price{
public function getCategoryPrice($price,$special_price){
$price_info = Yii::$service->product->price->format_price($price);
$return = [
'price' => [
'symbol' => $price_info['symbol'],
'value' => $price_info['value'],
]
];
if($special_price){
$special_price_info = Yii::$service->product->price->format_price($special_price);
$return['special_price'] = [
'symbol' => $special_price_info['symbol'],
'value' => $special_price_info['value'],
];
}
return $return;
}
}
\ No newline at end of file
......@@ -612,21 +612,39 @@ input.input-text {
.top_currency .currency_list ul li{cursor:pointer;}
.two-columns-left .col-main{width:980px;float:right}
.two-columns-left .col-left {width:200px;float:left}
.col-main h1{font-size:15px;font-weight:100;}
.category_product{margin:0 0 15px 0;}
.category_product ul{margin:0 0 10px ;}
.category_product ul li {float:left;width:240px;height:350px;}
.category_product ul li a {font-size:0.75em}
.category_product .c_name{min-height:50px;overflow:hidden}
.category_product .c_price .price{
float:left;
font-weight:bold;
font-size:0.9em;
}
.category_product .c_price .special_price{
float:left;
margin: 0 0 0 10px;
font-weight:bold;
font-size:0.9em;
}
.category_product .c_price .price.sp{
text-decoration: line-through;
color:777;
font-weight:100;
}
.menu_category .toolbar{padding:8px 15px;background:#eee;margin:6px 0;height:25px;}
.menu_category .toolbar .tb_le{float:left;}
.menu_category .toolbar .tb_rg{float:right;}
.menu_category .toolbar .tb_le b{font-size:0.8em}
......
......@@ -7,52 +7,83 @@
* @license http://www.fecshop.com/license/
*/
?>
<div class="main container">
<?php //var_dump($products); ?>
<?php $count = 3; $end = $count-1; ?>
<div class="main container two-columns-left">
<?php // echo count($products); ?>
<?php $count = 4; $end = $count-1; ?>
<div class="col-main">
<h1><?= $name ?></h1>
<div class="category_img">
</div>
<div class="panelBar">
</div>
<div class="category_product">
<?php if(is_array($products)){ ?>
<?php $i = 0; foreach($products as $product){ ?>
<?php if($i%$count == 0){ ?>
<ul>
<?php } ?>
<li>
<div class="c_img">
<a href="<?= $product['url'] ?>">
<img src="<?= Yii::$service->product->image->getResize($product['image'],[280,380],false) ?>" />
</a>
</div>
<div class="c_name">
<a href="<?= $product['url'] ?>">
<?= $product['name'] ?>
</a>
</div>
<div class="c_price">
<div class="price">
<?= $product['price'] ?>
<div class="menu_category">
<div class="category_img">
<a href="#"><?= $image ? '<img style="width:980px;" src="'.$image.'"/>' : '';?><a>
</div>
<div class="category_description">
<h1><?= $name ?></h1>
<?= $description ?>
</div>
<div class="panelBar">
<div class="toolbar">
<div class="tb_le">
<b>Sort By:</b>
<select>
<option value="new">New</option>
<option value="name">Name</option>
<option value="price">Price</option>
</select>
<select>
<option value="30">30</option>
<option value="60">60</option>
<option value="90">90</option>
</select>
</div>
<div class="tb_rg">
<a href="#"><</a>
<a href="#">1</a>
<a href="#">2</a>
<a href="#">3</a>
<a href="#">4</a>
<a href="#">5</a>
<a href="#">></a>
</div>
<div class="clear"></div>
</div>
</div>
<div class="category_product">
<?php if(is_array($products)){ ?>
<?php $i = 0; foreach($products as $product){ ?>
<?php if($i%$count == 0){ ?>
<ul>
<?php } ?>
<li>
<div class="c_img">
<a href="<?= $product['url'] ?>">
<img src="<?= Yii::$service->product->image->getResize($product['image'],[230,230],false) ?>" />
</a>
</div>
<div class="special_price">
<?= $product['special_price'] ?>
<div class="c_name">
<a href="<?= $product['url'] ?>">
<?= $product['name'] ?>
</a>
</div>
</div>
</li>
<?php if($i%$count == $end){ ?>
</ul>
<?php } ?>
<?php $i++; ?>
<?php
$config = [
'class' => 'fecshop\app\appfront\modules\Catalog\block\category\Price',
'view' => 'catalog/category/price.php',
'price' => $product['price'],
'special_price' => $product['special_price'],
];
echo Yii::$service->page->widget->renderContent('category_product_price',$config);
?>
</li>
<?php if($i%$count == $end){ ?>
</ul>
<?php } ?>
<?php $i++; ?>
<?php } ?>
<?php if($i%$count != $end){ ?>
</ul>
<?php } ?>
<?php } ?>
<?php if($i%$count != $end){ ?>
</ul>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
......
<div class="c_price">
<?php if(isset($special_price) && !empty($special_price)){ $sp = 'sp'; } ?>
<div class="price <?= $sp ?>">
<?= $price['symbol'].$price['value'] ?>
</div>
<?php if(isset($special_price) && !empty($special_price)){ ?>
<div class="special_price">
<?= $special_price['symbol'].$special_price['value'] ?>
</div>
<div class="clear"></div>
<?php } ?>
</div>
\ No newline at end of file
......@@ -94,7 +94,7 @@ class Widget extends Service
}
protected function renderContent($configKey,$config,$parentThis=''){
protected function actionRenderContent($configKey,$config,$parentThis=''){
if(isset($config['cache']['enable']) && $config['cache']['enable']){
if(!isset($config['class']) || !$config['class']){
throw new InvalidConfigException('in widget ['.$configKey.'],you enable cache ,you must config widget class .');
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\services\product;
use Yii;
use yii\base\InvalidValueException;
use yii\base\InvalidConfigException;
use fecshop\services\Service;
/**
* Product Service is the component that you can get product info from it.
* @property Image|\fecshop\services\Product\Image $image ,This property is read-only.
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Price extends Service
{
protected $_currencyInfo;
protected function actionFormatPrice($price){
$currencyInfo = $this->getCurrentInfo();
$price = $price * $currencyInfo['rate'];
$price = ceil($price*100)/100;
return [
'code' => $currencyInfo['code'],
'symbol' => $currencyInfo['symbol'],
'value' => $price,
];
}
protected function getCurrentInfo(){
if(!$this->_currencyInfo){
$this->_currencyInfo = Yii::$service->page->currency->getCurrencyInfo();
}
return $this->_currencyInfo;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册