Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
56e90409
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
18
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
56e90409
编写于
7月 14, 2017
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
产品详细页面,显示产品组属性。
上级
62f1737a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
11 deletion
+67
-11
app/appfront/modules/Catalog/block/product/Index.php
app/appfront/modules/Catalog/block/product/Index.php
+17
-1
app/appfront/theme/base/front/catalog/product/index.php
app/appfront/theme/base/front/catalog/product/index.php
+11
-7
services/Product.php
services/Product.php
+39
-3
未找到文件。
app/appfront/modules/Catalog/block/product/Index.php
浏览文件 @
56e90409
...
...
@@ -42,7 +42,10 @@ class Index
$ReviewAndStarCount
=
ReviewHelper
::
getReviewAndStarCount
(
$this
->
_product
);
list
(
$review_count
,
$reviw_rate_star_average
)
=
$ReviewAndStarCount
;
$this
->
filterProductImg
(
$this
->
_product
[
'image'
]);
$groupAttr
=
Yii
::
$service
->
product
->
getGroupAttr
(
$this
->
_product
[
'attr_group'
]);
$groupAttrArr
=
$this
->
getGroupAttrArr
(
$groupAttr
);
return
[
'groupAttrArr'
=>
$groupAttrArr
,
'name'
=>
Yii
::
$service
->
store
->
getStoreAttrVal
(
$this
->
_product
[
'name'
],
'name'
),
'image_thumbnails'
=>
$this
->
_image_thumbnails
,
'image_detail'
=>
$this
->
_image_detail
,
...
...
@@ -66,6 +69,18 @@ class Index
'buy_also_buy'
=>
$this
->
getProductBySkus
(
$skus
),
];
}
public
function
getGroupAttrArr
(
$groupAttr
){
$gArr
=
[];
if
(
is_array
(
$groupAttr
)){
foreach
(
$groupAttr
as
$attr
){
if
(
isset
(
$this
->
_product
[
$attr
])
&&
$this
->
_product
[
$attr
]){
$gArr
[
$attr
]
=
$this
->
_product
[
$attr
];
}
}
}
//var_dump($gArr);
return
$gArr
;
}
/**
* @property $product_images | Array ,产品的图片属性
* 根据图片数组,得到橱窗图,和描述图
...
...
@@ -190,9 +205,10 @@ class Index
*/
protected
function
getSameSpuInfo
()
{
$groupAttr
=
Yii
::
$service
->
product
->
getGroupAttr
(
$this
->
_product
[
'attr_group'
]);
// 当前的产品对应的spu属性组的属性,譬如 ['color','size','myyy']
$this
->
_productSpuAttrArr
=
Yii
::
$service
->
product
->
getSpuAttr
(
$this
->
_product
[
'attr_group'
]);
//var_dump($this->_productSpuAttrArr);exit;
$this
->
_spuAttrShowAsImg
=
Yii
::
$service
->
product
->
getSpuImgAttr
(
$this
->
_product
[
'attr_group'
]);
if
(
!
is_array
(
$this
->
_productSpuAttrArr
)
||
empty
(
$this
->
_productSpuAttrArr
))
{
return
;
...
...
app/appfront/theme/base/front/catalog/product/index.php
浏览文件 @
56e90409
...
...
@@ -138,15 +138,10 @@
];
?>
<?=
Yii
::
$service
->
page
->
widget
->
render
(
$buyAlsoBuyView
,
$buyAlsoBuyParam
);
?>
</div>
<div
class=
"clear"
></div>
<div
class=
"product_description_info"
>
<div
class=
"nav"
id=
"nav-container"
>
<ul
id=
"nav-box"
>
<li
class=
"nav_tab cur"
rel=
"description"
>
<?=
Yii
::
$service
->
page
->
translate
->
__
(
'Description'
);
?>
</li>
...
...
@@ -157,6 +152,15 @@
</div>
<div
id=
"text"
>
<div
class=
"text-description"
style=
""
>
<?php
if
(
is_array
(
$groupAttrArr
))
:
?>
<table>
<?php
foreach
(
$groupAttrArr
as
$k
=>
$v
)
:
?>
<tr><td>
<?=
$k
?>
</td><td>
<?=
$v
?>
</td></tr>
<?php
endforeach
;
?>
</table>
<br/>
<?php
endif
;
?>
<?=
$description
;
?>
<div
class=
"img-section"
>
...
...
@@ -383,7 +387,7 @@
interval
=
setInterval
(
function
(){
if
(
scroll
.
scrollTop
+
a
<=
textChild
[
self
.
index
].
offsetTop
){
scroll
.
scrollTop
+=
4
0
;
scroll
.
scrollTop
+=
150
0
;
if
(
scroll
.
scrollTop
+
a
>=
textChild
[
self
.
index
].
offsetTop
){
scroll
.
scrollTop
=
textChild
[
self
.
index
].
offsetTop
-
a
;
clearInterval
(
interval
);
...
...
@@ -395,7 +399,7 @@
clearInterval
(
interval
);
}
}
},
4
0
);
},
4
);
};
}
<?php
$this
->
endBlock
();
?>
...
...
services/Product.php
浏览文件 @
56e90409
...
...
@@ -48,7 +48,7 @@ class Product extends Service
/**
* @property $productAttrGroup|string
* 得到这个产品属性组里面的所有的产品属性,
* 得到这个产品属性组里面的所有的产品属性
详细
,
* 注解:不同类型的产品,对应不同的属性组,譬如衣服有颜色尺码,电脑类型的有不同cpu型号等
* 属性组,以及属性组对应的属性,是在Product Service config中配置的。
*/
...
...
@@ -70,10 +70,46 @@ class Product extends Service
)
{
$arr
=
array_merge
(
$arr
,
$this
->
customAttrGroup
[
$productAttrGroup
][
'spu_attr'
]);
}
//var_dump($arr);
return
$arr
;
}
/**
* @property $productAttrGroup|string
* 得到这个产品属性组里面的所有的产品属性,
* 注解:不同类型的产品,对应不同的属性组,譬如衣服有颜色尺码,电脑类型的有不同cpu型号等
* 属性组,以及属性组对应的属性,是在Product Service config中配置的。
*/
protected
function
actionGetGroupAttr
(
$productAttrGroup
)
{
$arr
=
[];
// 得到普通属性
if
(
isset
(
$this
->
customAttrGroup
[
$productAttrGroup
][
'general_attr'
])
&&
is_array
(
$this
->
customAttrGroup
[
$productAttrGroup
][
'general_attr'
])
)
{
$general_attr
=
$this
->
customAttrGroup
[
$productAttrGroup
][
'general_attr'
];
if
(
is_array
(
$general_attr
)){
foreach
(
$general_attr
as
$attr
=>
$info
){
$arr
[]
=
$attr
;
}
}
}
// 得到用于spu,细分sku的属性,譬如颜色尺码之类。
if
(
isset
(
$this
->
customAttrGroup
[
$productAttrGroup
][
'spu_attr'
])
&&
is_array
(
$this
->
customAttrGroup
[
$productAttrGroup
][
'spu_attr'
])
)
{
$spu_attr
=
$this
->
customAttrGroup
[
$productAttrGroup
][
'spu_attr'
];
if
(
is_array
(
$spu_attr
)){
foreach
(
$spu_attr
as
$attr
=>
$info
){
$arr
[]
=
$attr
;
}
}
}
//var_dump($arr);
return
$arr
;
}
/**
* @property $productAttrGroup|string
* @return 一维数组
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录