Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
08b4d1c1
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,发现更多精彩内容 >>
提交
08b4d1c1
编写于
10月 22, 2016
作者:
R
root
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
product custom options
上级
cccf1c80
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
178 addition
and
64 deletion
+178
-64
app/appfront/modules/Catalog/block/product/Index.php
app/appfront/modules/Catalog/block/product/Index.php
+8
-45
app/appfront/theme/base/front/assets/css/style.css
app/appfront/theme/base/front/assets/css/style.css
+58
-0
app/appfront/theme/base/front/catalog/product/index.php
app/appfront/theme/base/front/catalog/product/index.php
+30
-19
app/appfront/theme/base/front/catalog/product/index/custom_option.php
.../theme/base/front/catalog/product/index/custom_option.php
+24
-0
app/appfront/theme/base/front/catalog/product/index/options.php
...pfront/theme/base/front/catalog/product/index/options.php
+58
-0
未找到文件。
app/appfront/modules/Catalog/block/product/Index.php
浏览文件 @
08b4d1c1
...
...
@@ -28,22 +28,23 @@ class Index {
$this
->
initProduct
();
return
[
'name'
=>
Yii
::
$service
->
store
->
getStoreAttrVal
(
$this
->
_product
[
'name'
],
'name'
),
'image'
=>
$this
->
_product
[
'image'
],
'sku'
=>
$this
->
_product
[
'sku'
],
'price_info'
=>
$this
->
getProductPriceInfo
(),
'tier_price'
=>
$this
->
_product
[
'tier_price'
],
'media_size'
=>
[
'small_img_width'
=>
$productImgSize
[
'small_img_width'
],
'small_img_height'
=>
$productImgSize
[
'small_img_height'
],
'middle_img_width'
=>
$productImgSize
[
'middle_img_width'
],
'small_img_width'
=>
$productImgSize
[
'small_img_width'
],
'small_img_height'
=>
$productImgSize
[
'small_img_height'
],
'middle_img_width'
=>
$productImgSize
[
'middle_img_width'
],
],
'productImgMagnifier'
=>
$productImgMagnifier
,
'productImgMagnifier'
=>
$productImgMagnifier
,
'options'
=>
$this
->
getSameSpuInfo
(),
'custom_option'
=>
$this
->
_product
[
'custom_option'
],
];
}
protected
function
getSpuData
(){
$spu
=
$this
->
_product
[
'spu'
];
$filter
=
[
...
...
@@ -127,46 +128,8 @@ class Index {
}
$data
=
$this
->
getSpuData
();
list
(
$all_color
,
$all_size
,
$color_2_size
,
$size_2_color
)
=
$this
->
getColorAndSizeInfo
(
$data
,
$current_size
,
$current_color
);
$str
=
''
;
$all_size
=
$this
->
sortSizeArr
(
$all_size
);
if
(
is_array
(
$all_color
)
&&
!
empty
(
$all_color
)){
$str
.
=
'<div class="chose_color">'
;
foreach
(
$all_color
as
$color
=>
$info
){
$main_img
=
isset
(
$info
[
'image'
][
'main'
][
'image'
])
?
$info
[
'image'
][
'main'
][
'image'
]
:
''
;
$url
=
''
;
$active
=
'class="active"'
;
if
(
isset
(
$color_2_size
[
$color
])){
$url
=
Yii
::
$service
->
url
->
getUrl
(
$color_2_size
[
$color
][
'url_key'
]);
}
else
{
$url
=
Yii
::
$service
->
url
->
getUrl
(
$info
[
'url_key'
]);
}
if
(
$color
==
$current_color
){
$active
=
'class="current"'
;
}
$str
.
=
'<a '
.
$active
.
' href="javascript:void(0)" rel="'
.
$url
.
'"><img src="'
.
Yii
::
$service
->
product
->
image
->
getResize
(
$main_img
,[
50
,
55
],
false
)
.
'"/></a>'
;
}
$str
.
=
'<div class="clear"></div>'
;
$str
.
=
'</div>'
;
}
if
(
is_array
(
$all_size
)
&&
!
empty
(
$all_size
)){
$str
.
=
'<div class="chose_size">'
;
foreach
(
$all_size
as
$size
=>
$info
){
$url
=
''
;
$active
=
'class="noactive"'
;
if
(
isset
(
$size_2_color
[
$size
])){
$url
=
Yii
::
$service
->
url
->
getUrl
(
$size_2_color
[
$size
][
'url_key'
]);
$active
=
'class="active"'
;
}
if
(
$size
==
$current_size
){
$active
=
'class="current"'
;
}
$str
.
=
'<a '
.
$active
.
' href="javascript:void(0)" rel="'
.
$url
.
'"><span>'
.
$size
.
'</span></a>'
;
}
$str
.
=
'<div class="clear"></div>'
;
$str
.
=
'</div>'
;
}
//echo $str;exit;
return
$str
;
$all_size
=
$this
->
sortSizeArr
(
$all_size
);
return
[
$current_color
,
$current_size
,
$all_color
,
$all_size
,
$color_2_size
,
$size_2_color
];
}
/**
* @property $data | Array 各个尺码对应的产品数组
...
...
app/appfront/theme/base/front/assets/css/style.css
浏览文件 @
08b4d1c1
...
...
@@ -1812,3 +1812,61 @@ padding: 0 0 0 20px;
.product_options
a
.active
{
border
:
1px
solid
#ccc
;
}
.product_custom_options
.one_option
{
margin
:
10px
0
;
}
.product_custom_options
.custom_option
{
float
:
left
;
display
:
block
;
width
:
100px
;
margin
:
4px
0
0
;
}
.product_custom_options
.one_option_title
{
float
:
left
;
display
:
block
;
width
:
80px
;
}
app/appfront/theme/base/front/catalog/product/index.php
浏览文件 @
08b4d1c1
...
...
@@ -33,27 +33,38 @@
</div>
<div
style=
"height:300px;"
>
<div
class=
"product_options"
>
<?=
$options
;
?>
<?php
# options部分
$optionsView
=
[
'view'
=>
'catalog/product/index/options.php'
];
$optionsParam
=
[
'options'
=>
$options
,
];
?>
<?=
Yii
::
$service
->
page
->
widget
->
render
(
$optionsView
,
$optionsParam
);
?>
</div>
<div
class=
"product_custom_options"
>
<?php
# options部分
$optionsView
=
[
'view'
=>
'catalog/product/index/custom_option.php'
];
$optionsParam
=
[
'custom_option'
=>
$custom_option
,
];
?>
<?=
Yii
::
$service
->
page
->
widget
->
render
(
$optionsView
,
$optionsParam
);
?>
</div>
<div
class=
"product_qty"
>
<div>
Qty:
</div>
<div>
<input
type=
"text"
name=
"qty"
class=
"qty"
value=
"1"
/>
</div>
<div
class=
"clear"
></div>
</div>
<script>
<?php
$this
->
beginBlock
(
'product_options'
)
?>
$
(
document
).
ready
(
function
(){
$
(
"
.product_options a
"
).
click
(
function
(){
$url
=
$
(
this
).
attr
(
"
rel
"
);
if
(
$url
){
window
.
location
.
href
=
$url
;
}
else
{
}
});
});
<?php
$this
->
endBlock
();
?>
</script>
<?php
$this
->
registerJs
(
$this
->
blocks
[
'product_options'
],
\
yii\web\View
::
POS_END
);
//将编写的js代码注册到页面底部 ?>
</div>
<div
class=
"tier_price_info"
>
...
...
app/appfront/theme/base/front/catalog/product/index/custom_option.php
0 → 100644
浏览文件 @
08b4d1c1
<?php
$custom_option
=
$parentThis
[
'custom_option'
];
?>
<?php
if
(
is_array
(
$custom_option
)
&&
!
empty
(
$custom_option
)){
?>
<?php
$custom_option
=
\
fec\helpers\CFunc
::
array_sort
(
$custom_option
,
'sort_order'
,
'asc'
);
?>
<?php
foreach
(
$custom_option
as
$one
){
?>
<?php
$option_title
=
$one
[
'title'
];
?>
<?php
$is_require
=
$one
[
'is_require'
];
?>
<?php
$data
=
$one
[
'data'
];
?>
<?php
if
(
is_array
(
$data
)
&&
!
empty
(
$data
)){
?>
<div
class=
"one_option"
>
<div
class=
"one_option_title"
>
<?=
$option_title
?>
:
</div>
<select
class=
"custom_option
<?=
$title
?>
<?=
$is_require
?
'required'
:
''
?>
"
name=
"custom_option[
<?=
$title
?>
]"
>
<?php
$data
=
\
fec\helpers\CFunc
::
array_sort
(
$data
,
'sort_order'
,
'asc'
);
?>
<?php
foreach
(
$data
as
$one
){
?>
<?php
$title
=
$one
[
'title'
];
?>
<?php
$price
=
$one
[
'price'
];
?>
<?php
$val
=
Yii
::
$service
->
store
->
getStoreAttrVal
(
$title
,
'title'
);
?>
<option
value=
"
<?=
$val
?>
"
>
<?=
$val
?>
</option>
<?php
}
?>
</select>
<div
class=
"clear"
></div>
</div>
<?php
}
?>
<?php
}
?>
<?php
}
?>
\ No newline at end of file
app/appfront/theme/base/front/catalog/product/index/options.php
0 → 100644
浏览文件 @
08b4d1c1
<?php
list
(
$current_color
,
$current_size
,
$all_color
,
$all_size
,
$color_2_size
,
$size_2_color
)
=
$parentThis
[
'options'
];
?>
<?php
?>
<?php
if
(
is_array
(
$all_color
)
&&
!
empty
(
$all_color
)){
?>
<div
class=
"chose_color"
>
<?php
foreach
(
$all_color
as
$color
=>
$info
){
?>
<?php
$main_img
=
isset
(
$info
[
'image'
][
'main'
][
'image'
])
?
$info
[
'image'
][
'main'
][
'image'
]
:
''
;
?>
<?php
$url
=
''
;
?>
<?php
$active
=
'class="active"'
;
?>
<?php
if
(
isset
(
$color_2_size
[
$color
])){
?>
<?php
$url
=
Yii
::
$service
->
url
->
getUrl
(
$color_2_size
[
$color
][
'url_key'
]);
?>
<?php
}
else
{
?>
<?php
$url
=
Yii
::
$service
->
url
->
getUrl
(
$info
[
'url_key'
]);
?>
<?php
}
?>
<?php
if
(
$color
==
$current_color
){
?>
<?php
$active
=
'class="current"'
;
?>
<?php
}
?>
<a
<?=
$active
?>
href=
"javascript:void(0)"
rel=
"
<?=
$url
?>
"
><img
src=
"
<?=
Yii
::
$service
->
product
->
image
->
getResize
(
$main_img
,[
50
,
55
],
false
)
?>
"
/></a>
<?php
}
?>
<div
class=
"clear"
></div>
</div>
<?php
}
?>
<?php
if
(
is_array
(
$all_size
)
&&
!
empty
(
$all_size
)){
?>
<div
class=
"chose_size"
>
<?php
foreach
(
$all_size
as
$size
=>
$info
){
?>
<?php
$url
=
''
;
?>
<?php
$active
=
'class="noactive"'
;
?>
<?php
if
(
isset
(
$size_2_color
[
$size
])){
?>
<?php
$url
=
Yii
::
$service
->
url
->
getUrl
(
$size_2_color
[
$size
][
'url_key'
]);
?>
<?php
$active
=
'class="active"'
;
?>
<?php
}
?>
<?php
if
(
$size
==
$current_size
){
?>
<?php
$active
=
'class="current"'
;
?>
<?php
}
?>
<a
<?=
$active
?>
href=
"javascript:void(0)"
rel=
"
<?=
$url
?>
"
><span>
<?=
$size
?>
</span></a>
<?php
}
?>
<div
class=
"clear"
></div>
</div>
<?php
}
?>
<script>
<?php
$this
->
beginBlock
(
'product_options'
)
?>
$
(
document
).
ready
(
function
(){
$
(
"
.product_options a
"
).
click
(
function
(){
$url
=
$
(
this
).
attr
(
"
rel
"
);
if
(
$url
){
window
.
location
.
href
=
$url
;
}
});
});
<?php
$this
->
endBlock
();
?>
</script>
<?php
$this
->
registerJs
(
$this
->
blocks
[
'product_options'
],
\
yii\web\View
::
POS_END
);
//将编写的js代码注册到页面底部 ?>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录