Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
570399b8
ShopXO
项目概览
starsw001
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
570399b8
编写于
12月 27, 2018
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
小程序-商品详情规格
上级
1947136d
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
204 addition
and
33 deletion
+204
-33
application/api/controller/Goods.php
application/api/controller/Goods.php
+32
-0
application/service/GoodsService.php
application/service/GoodsService.php
+6
-5
public/appmini/old/alipay/pages/goods-detail/goods-detail.acss
...c/appmini/old/alipay/pages/goods-detail/goods-detail.acss
+24
-2
public/appmini/old/alipay/pages/goods-detail/goods-detail.axml
...c/appmini/old/alipay/pages/goods-detail/goods-detail.axml
+1
-5
public/appmini/old/alipay/pages/goods-detail/goods-detail.js
public/appmini/old/alipay/pages/goods-detail/goods-detail.js
+141
-21
未找到文件。
application/api/controller/Goods.php
浏览文件 @
570399b8
...
...
@@ -96,5 +96,37 @@ class Goods extends Common
$ret
=
GoodsService
::
GoodsFavor
(
$params
);
return
json
(
$ret
);
}
/**
* 商品规格类型
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-14
* @desc description
*/
public
function
SpecType
()
{
// 开始处理
$params
=
$this
->
data_post
;
$ret
=
GoodsService
::
GoodsSpecType
(
$params
);
return
json
(
$ret
);
}
/**
* 商品规格信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-14
* @desc description
*/
public
function
SpecDetail
()
{
// 开始处理
$params
=
$this
->
data_post
;
$ret
=
GoodsService
::
GoodsSpecDetail
(
$params
);
return
json
(
$ret
);
}
}
?>
\ No newline at end of file
application/service/GoodsService.php
浏览文件 @
570399b8
...
...
@@ -1748,11 +1748,6 @@ class GoodsService
'key_name'
=>
'spec'
,
'error_msg'
=>
'请选择规格'
,
],
[
'checked_type'
=>
'is_array'
,
'key_name'
=>
'spec'
,
'error_msg'
=>
'规格有误'
,
],
];
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
!==
true
)
...
...
@@ -1766,6 +1761,12 @@ class GoodsService
'goods_id'
=>
intval
(
$params
[
'id'
]),
];
$value
=
[];
// 规格不为数组则为json字符串
if
(
!
is_array
(
$params
[
'spec'
]))
{
$params
[
'spec'
]
=
json_decode
(
$params
[
'spec'
],
true
);
}
foreach
(
$params
[
'spec'
]
as
$v
)
{
$value
[]
=
$v
[
'value'
];
...
...
public/appmini/old/alipay/pages/goods-detail/goods-detail.acss
浏览文件 @
570399b8
...
...
@@ -31,10 +31,11 @@
margin-top: 20rpx;
margin-right: 25rpx;
padding: 0 30rpx;
background
: #eee
;
background
-color: #f5f5f5
;
color: #666;
line-height: 27px;
height: 27px;
border: 1px solid #d5d5d5;
}
.goods-attr-choose .item .attribute button image {
width: 20px;
...
...
@@ -42,17 +43,38 @@
vertical-align: middle;
margin-right: 10rpx;
}
.spec-active {
background: #d2364c !important;
color: #fff !important;
border: 1px solid #b91d33 !important;
}
.spec-dont-choose {
color: #b4b3b3 !important;
background-color: #ffffff !important;
border: 1px solid #ebeaea !important;
}
.spec-dont-choose image {
opacity: 0.5;
}
.spec-items-disabled {
color: #d2cfcf !important;
background-color: #ffffff !important;
border: 1px dashed #d5d5d5 !important;
}
.spec-items-disabled image {
opacity: 0.3;
}
.goods-attr-choose .item .attribute button,
.goods-popup-submit
{
border-radius: 50rpx;
border: 0;
}
.goods-popup-submit {
height: 85rpx;
line-height: 85rpx;
font-size: 36rpx;
margin-top: 20rpx;
border: 0;
}
.goods-popup .goods-buy-number {
margin-bottom: 20rpx;
...
...
public/appmini/old/alipay/pages/goods-detail/goods-detail.axml
浏览文件 @
570399b8
...
...
@@ -91,11 +91,7 @@
<view class="title">{{item.name}}</view>
<view a:if="{{item.value.length > 0}}" class="attribute">
<block a:for="{{item.value}}" a:for-index="keys" a:for-item="items">
<button a:if="{{temp_attribute_active[key] == keys}}" catchTap="goods_attribute_event" data-key="{{key}}" data-keys="{{keys}}" class="bg-active-main" type="default" size="mini" hover-class="none">
<image a:if="{{(items.images || null) != null}}" src="{{items.images}}" mode="scaleToFill" />
{{items.name}}
</button>
<button a:else catchTap="goods_attribute_event" data-key="{{key}}" data-keys="{{keys}}" type="default" size="mini" hover-class="none">
<button catchTap="goods_specifications_event" data-key="{{key}}" data-keys="{{keys}}" type="default" size="mini" hover-class="none" class="{{items.is_active}} {{items.is_dont}} {{items.is_disabled}}">
<image a:if="{{(items.images || null) != null}}" src="{{items.images}}" mode="scaleToFill" />
{{items.name}}
</button>
...
...
public/appmini/old/alipay/pages/goods-detail/goods-detail.js
浏览文件 @
570399b8
...
...
@@ -19,7 +19,6 @@ Page({
popup_status
:
false
,
goods_favor_text
:
'
收藏
'
,
goods_favor_icon
:
'
/images/goods-detail-favor-icon-0.png
'
,
temp_attribute_active
:
{},
temp_buy_number
:
1
,
buy_event_type
:
'
buy
'
,
nav_submit_text
:
'
立即购买
'
,
...
...
@@ -76,6 +75,7 @@ Page({
indicator_dots
:
(
data
.
goods
.
photo
.
length
>
1
),
autoplay
:
(
data
.
goods
.
photo
.
length
>
1
),
goods_photo
:
data
.
goods
.
photo
,
goods_specifications_choose
:
data
.
goods
.
specifications
.
choose
||
[],
goods_content_app
:
data
.
goods
.
content_app
,
temp_buy_number
:
(
data
.
goods
.
buy_min_number
)
||
1
,
goods_favor_text
:
(
data
.
goods
.
is_favor
==
1
)
?
'
已收藏
'
:
'
收藏
'
,
...
...
@@ -86,8 +86,8 @@ Page({
nav_submit_is_disabled
:
(
data
.
goods
.
is_shelves
==
1
&&
data
.
goods
.
inventory
>
0
)
?
false
:
true
,
});
// 规格处理
this
.
goods_specifications_choose_handle_dont
(
data
.
goods
.
specifications
.
choose
,
0
);
//
不能选择
规格处理
this
.
goods_specifications_choose_handle_dont
(
0
);
if
(
data
.
goods
.
is_shelves
!=
1
)
{
this
.
setData
({
...
...
@@ -128,24 +128,28 @@ Page({
}
},
// 规格处理
goods_specifications_choose_handle_dont
(
data
,
key
)
{
if
((
data
||
null
)
==
null
)
// 不能选择规格处理
goods_specifications_choose_handle_dont
(
key
)
{
var
temp_data
=
this
.
data
.
goods_specifications_choose
||
[];
if
(
temp_data
.
length
<=
0
)
{
this
.
setData
({
goods_specifications_choose
:
[]});
return
false
;
}
// 是否不能选择
for
(
var
i
in
data
)
for
(
var
i
in
temp_
data
)
{
for
(
var
k
in
data
[
i
][
'
value
'
])
for
(
var
k
in
temp_
data
[
i
][
'
value
'
])
{
data
[
i
][
'
value
'
][
k
][
'
is_dont
'
]
=
(
key
>
0
)
?
'
spec-dont
'
:
''
,
data
[
i
][
'
value
'
][
k
][
'
is_disabled
'
]
=
''
;
if
(
i
>
key
)
{
temp_data
[
i
][
'
value
'
][
k
][
'
is_dont
'
]
=
'
spec-dont-choose
'
,
temp_data
[
i
][
'
value
'
][
k
][
'
is_disabled
'
]
=
''
;
temp_data
[
i
][
'
value
'
][
k
][
'
is_active
'
]
=
''
;
}
}
}
this
.
setData
({
goods_specifications_choose
:
data
});
this
.
setData
({
goods_specifications_choose
:
temp_
data
});
},
// 下拉刷新
...
...
@@ -291,20 +295,136 @@ Page({
}
},
//
属性
事件
goods_
attribute
_event
(
e
)
{
//
规格
事件
goods_
specifications
_event
(
e
)
{
var
key
=
e
.
currentTarget
.
dataset
.
key
||
0
;
var
keys
=
e
.
currentTarget
.
dataset
.
keys
||
0
;
var
temp_data
=
this
.
data
.
temp_attribute_activ
e
;
var
temp_data
=
this
.
data
.
goods_specifications_choos
e
;
// 相同则移除
if
(
temp_data
[
key
]
==
keys
)
// 不能选择和禁止选择跳过
if
((
temp_data
[
key
][
'
value
'
][
keys
][
'
is_dont
'
]
||
null
)
==
null
&&
(
temp_data
[
key
][
'
value
'
][
keys
][
'
is_disabled
'
]
||
null
)
==
null
)
{
// 规格选择
for
(
var
i
in
temp_data
)
{
for
(
var
k
in
temp_data
[
i
][
'
value
'
])
{
if
((
temp_data
[
i
][
'
value
'
][
k
][
'
is_dont
'
]
||
null
)
==
null
&&
(
temp_data
[
i
][
'
value
'
][
k
][
'
is_disabled
'
]
||
null
)
==
null
)
{
delete
temp_data
[
key
];
if
(
key
==
i
)
{
if
(
keys
==
k
&&
(
temp_data
[
i
][
'
value
'
][
k
][
'
is_active
'
]
||
null
)
==
null
)
{
temp_data
[
i
][
'
value
'
][
k
][
'
is_active
'
]
=
'
spec-active
'
;
}
else
{
temp_data
[
key
]
=
keys
;
temp_data
[
i
][
'
value
'
][
k
][
'
is_active
'
]
=
''
;
}
}
}
}
}
this
.
setData
({
goods_specifications_choose
:
temp_data
});
// 不能选择规格处理
this
.
goods_specifications_choose_handle_dont
(
key
);
// 获取下一个规格类型
this
.
get_goods_specifications_type
(
key
);
// 获取规格详情
this
.
get_goods_specifications_detail
();
}
},
// 获取下一个规格类型
get_goods_specifications_type
(
key
)
{
var
temp_data
=
this
.
data
.
goods_specifications_choose
;
var
active_index
=
key
+
1
;
var
sku_count
=
temp_data
.
length
;
if
(
active_index
<=
0
||
active_index
>=
sku_count
)
{
return
false
;
}
// 获取规格值
var
spec
=
[];
for
(
var
i
in
temp_data
)
{
for
(
var
k
in
temp_data
[
i
][
'
value
'
])
{
if
((
temp_data
[
i
][
'
value
'
][
k
][
'
is_active
'
]
||
null
)
!=
null
)
{
spec
.
push
({
"
type
"
:
temp_data
[
i
][
'
name
'
],
"
value
"
:
temp_data
[
i
][
'
value
'
][
k
][
'
name
'
]});
break
;
}
this
.
setData
({
temp_attribute_active
:
temp_data
});
}
}
if
(
spec
.
length
<=
0
)
{
return
false
;
}
// 获取数据
my
.
httpRequest
({
url
:
app
.
get_request_url
(
'
spectype
'
,
'
goods
'
),
method
:
'
POST
'
,
data
:
{
"
id
"
:
this
.
data
.
goods
.
id
,
"
spec
"
:
JSON
.
stringify
(
spec
)
},
dataType
:
'
json
'
,
success
:
(
res
)
=>
{
if
(
res
.
data
.
code
==
0
)
{
var
spec_count
=
spec
.
length
;
var
index
=
(
spec_count
>
0
)
?
spec_count
:
0
;
if
(
index
<
sku_count
)
{
for
(
var
i
in
temp_data
)
{
for
(
var
k
in
temp_data
[
i
][
'
value
'
])
{
if
(
index
==
i
)
{
temp_data
[
i
][
'
value
'
][
k
][
'
is_dont
'
]
=
''
;
var
temp_value
=
temp_data
[
i
][
'
value
'
][
k
][
'
name
'
];
var
temp_status
=
false
;
for
(
var
t
in
res
.
data
.
data
)
{
if
(
res
.
data
.
data
[
t
]
==
temp_value
)
{
temp_status
=
true
;
break
;
}
}
console
.
log
(
temp_value
,
temp_status
,
res
.
data
)
if
(
temp_status
==
true
)
{
temp_data
[
i
][
'
value
'
][
k
][
'
is_disabled
'
]
=
''
;
}
else
{
temp_data
[
i
][
'
value
'
][
k
][
'
is_disabled
'
]
=
'
spec-items-disabled
'
;
}
}
}
}
this
.
setData
({
goods_specifications_choose
:
temp_data
});
}
}
else
{
my
.
showToast
({
type
:
'
fail
'
,
content
:
res
.
data
.
msg
});
}
},
fail
:
()
=>
{
my
.
showToast
({
type
:
'
fail
'
,
content
:
'
服务器请求出错
'
});
}
});
},
// 获取规格详情
get_goods_specifications_detail
()
{
},
// 数量输入事件
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录