Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
严立
/
mini-shimao
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f4f30ae5
authored
Sep 03, 2020
by
wjw
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
wjw-购物车修改
parent
50122315
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
417 additions
and
8 deletions
pages/commodity/shopping-cart/shopping-cart.js
pages/commodity/shopping-cart/shopping-cart.json
pages/commodity/shopping-cart/shopping-cart.wxss
pages/commodity/shopping-cart/shopping-cart.js
View file @
f4f30ae5
// pages/shimao/index.js
Page
({
Page
({
data
:
{
data
:
{
totalNum
:
3
,
totalPrice
:
840.00
,
discount
:
270.00
,
allChecked
:
false
,
isFoodCart
:
true
,
isEnough
:
false
,
cart
:
[
{
goods_id
:
0
,
goods_name
:
'雪碧迷你瓶装300ml'
,
goods_now_price
:
49.00
,
goods_old_price
:
42.00
,
goods_now_text
:
'业主价'
,
goods_num
:
1
,
store_num
:
1
,
checked
:
true
,
img
:
'/assets/logo.png'
},
},
onLoad
:
function
(
options
)
{
{
goods_id
:
1
,
goods_name
:
'可口可乐300ml'
,
goods_now_price
:
52.00
,
goods_old_price
:
49.00
,
goods_now_text
:
'活动价'
,
goods_num
:
1
,
store_num
:
2
,
checked
:
true
,
img
:
'/assets/logo.png'
},
},
})
{
\ No newline at end of file
goods_id
:
2
,
goods_name
:
'葡萄汁饮料238ml'
,
goods_now_price
:
30.00
,
goods_num
:
2
,
checked
:
true
,
img
:
'/assets/logo.png'
},
{
goods_id
:
3
,
goods_name
:
'牛奶苏打碳酸250ml'
,
goods_now_price
:
78
,
goods_num
:
12
,
checked
:
false
,
img
:
'/assets/logo.png'
}
],
notEnough
:
[
{
id
:
0
,
img
:
'../../assets/enough01.png'
,
title
:
'葱爆牛肉佐秘制麻椒汁'
},
{
id
:
1
,
img
:
'../../assets/enough01.png'
,
title
:
'抹茶酸奶芝士'
}
]
},
handleItemNumEdit
(
e
)
{
const
operation
=
e
.
currentTarget
.
dataset
.
operation
const
goods_id
=
e
.
currentTarget
.
dataset
.
id
let
cart
=
this
.
data
.
cart
const
index
=
cart
.
findIndex
(
v
=>
v
.
goods_id
===
goods_id
)
if
((
cart
[
index
].
store_num
===
cart
[
index
].
goods_num
)
&&
operation
===
1
)
{
console
.
log
(
'没有库存'
)
}
else
if
(
cart
[
index
].
goods_num
===
1
&&
operation
===
-
1
)
{
wx
.
lin
.
showDialog
({
type
:
"confirm"
,
title
:
"温馨提示"
,
content
:
"您是否要删除该商品?"
,
confirmColor
:
"#5DB5DD"
,
cancelColor
:
"#656E7B"
,
titleColor
:
"#15191F"
,
success
:
(
res
)
=>
{
if
(
res
.
confirm
)
{
cart
.
splice
(
index
,
1
)
this
.
setCart
(
cart
)
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
)
}
}
})
}
else
{
cart
[
index
].
goods_num
+=
operation
this
.
setCart
(
cart
)
}
},
handleItemCheck
(
e
)
{
const
goods_id
=
e
.
currentTarget
.
dataset
.
id
let
cart
=
this
.
data
.
cart
const
index
=
cart
.
findIndex
(
v
=>
v
.
goods_id
===
goods_id
)
cart
[
index
].
checked
=
!
cart
[
index
].
checked
this
.
setCart
(
cart
)
},
handleItemAllCheck
()
{
let
allChecked
=
!
this
.
data
.
allChecked
let
cart
=
this
.
data
.
cart
cart
.
forEach
(
v
=>
v
.
checked
=
allChecked
)
this
.
setCart
(
cart
)
},
setCart
(
cart
)
{
let
totalPrice
=
0
let
totalNum
=
0
let
allChecked
=
true
cart
.
forEach
(
v
=>
{
if
(
v
.
checked
)
{
totalPrice
+=
v
.
goods_now_price
*
v
.
goods_num
totalNum
+=
1
}
else
{
allChecked
=
false
}
})
allChecked
=
cart
.
length
!=
0
?
allChecked
:
false
this
.
setData
({
cart
,
allChecked
,
totalPrice
,
totalNum
})
},
handleClearCart
()
{
wx
.
lin
.
showDialog
({
type
:
"confirm"
,
title
:
"温馨提示"
,
content
:
"确定要清空购物车?"
,
confirmColor
:
"#5DB5DD"
,
cancelColor
:
"#656E7B"
,
titleColor
:
"#15191F"
,
success
:
(
res
)
=>
{
if
(
res
.
confirm
)
{
let
cart
=
[]
this
.
setCart
(
cart
)
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
)
}
}
})
},
handleOrderPay
()
{
let
isEnough
=
true
this
.
setData
({
isEnough
})
},
handleBackCart
()
{
let
isEnough
=
false
this
.
setData
({
isEnough
})
},
})
\ No newline at end of file
pages/commodity/shopping-cart/shopping-cart.json
View file @
f4f30ae5
{
{
"usingComponents"
:
{}
"usingComponents"
:
{
"Tips"
:
"../../components/Tips/Tips"
,
"Blank"
:
"../../components/Blank/Blank"
},
"navigationBarTitleText"
:
"购物车"
}
}
\ No newline at end of file
pages/commodity/shopping-cart/shopping-cart.wxss
View file @
f4f30ae5
/* pages/home/home/home.wxss */
Page {
\ No newline at end of file
position: relative;
height: 100%;
}
.header {
width: 100%;
height: 116rpx;
padding: 16rpx 40rpx;
font-size: 30rpx;
}
.header_img {
width: 112rpx;
height: 84rpx;
}
.header_img image {
width: 100%;
height: 100%;
}
.header_title {
flex: 1;
color: #C36069;
}
.header_clear {
height: 100%;
color: #656E7B;
}
.l-content {
color: #959DA9 !important;
}
.item_list {
width: 100%;
height: calc(100vh - 390rpx);
margin-top: 10rpx;
}
.item {
width: 100%;
height: 250rpx;
padding: 0 40rpx;
box-sizing: border-box;
}
.item_checked {
width: 40rpx;
height: 40rpx;
margin-top: 54rpx;
}
.item_img {
width: 148rpx;
height: 148rpx;
margin-left: 24rpx;
}
.item_info {
flex: 1;
margin-left: 28rpx;
}
.item_info_title {
font-size: 30rpx;
color: #15191F;
}
.item_info_now_price {
margin-top: 66rpx;
font-size: 30rpx;
color: #15191F;
}
.item_now_price_text {
width: 78rpx;
height: 32rpx;
margin-left: 4px;
font-size: 18rpx;
color: #EF4E4E;
line-height: 32rpx;
text-align: center;
background: rgba(213, 107, 82, .12);
border-radius: 4rpx;
}
.vipPrice {
color: #E8D0AF;
background: linear-gradient(180deg, #3F4357 0%, #252532 100%);
border-radius: 4rpx;
opacity: 1;
}
.goods_num_tool_wrapper {
flex: 1;
position: relative;
}
.goods_num_tool {
width: 168rpx;
height: 48rpx;
padding: 12rpx 0;
box-sizing: border-box;
border: 1px solid #DBDFE5;
border-radius: 4rpx;
}
.l-counter {
border: 1px solid #DBDFE5;
border-radius: 4rpx;
box-sizing: border-box;
}
.l-symbol, .l-disabled, .l-count {
background-color: #fff !important;
}
.l-symbol, .l-count {
color: #15191F !important;
}
.l-count {
border-left: 1px solid #DBDFE5;
border-right: 1px solid #DBDFE5;
min-height: 0rpx !important;
}
.num_edit {
flex: 1;
}
.goods_num {
flex: 1;
border-left: 1px solid #DBDFE5;
border-right: 1px solid #DBDFE5;
}
.disable {
color: #DBDFE5;
}
.lack_wraning {
position: absolute;
top: 56rpx;
right: 84rpx;
transform: translateX(50%);
color: #D92B3A;
font-size: 22rpx;
}
.item_info_old_price {
margin-top: 4rpx;
font-size: 22rpx;
color: #959DA9;
text-decoration:line-through
}
text {
font-size: 22rpx;
}
.tips-wrapper {
position: absolute;
left: 0;
bottom: 196rpx;
width: 100%;
}
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 196rpx;
background-color: #fff;
display: flex;
padding: 0 40rpx 36rpx 36rpx;
box-sizing: border-box;
border-top: 1px solid #E2E7EF;
}
.all_chk_wrap {
flex: 3;
font-size: 26rpx;
color: #15191F;
}
.total_price_wrap {
flex: 5;
text-align: right;
padding-right: 32rpx;
}
.total_price {
color: #86C5E1;
}
.total_price_text {
font-size: 44rpx;
}
.total_discount {
font-size: 22rpx;
}
.order_pay_wrap {
width: 188rpx;
height: 96rpx;
font-size: 30rpx;
color: #fff;
background-color: #86C5E1;
}
.popup_wrap {
width: 606rpx;
height: 690rpx;
padding: 0 40rpx;
background-color: #fff;
border-radius: 4rpx;
}
.popup_title {
padding: 56rpx 0;
font-size: 34rpx;
font-weight: 600;
color: #15191F;
text-align: center;
border-bottom: 1px solid #E2E7EF;
}
.popup_list {
padding: 26rpx 0;
}
.popup_item {
padding: 32rpx 0;
}
.popup_item_img {
width: 96rpx;
height: 96rpx;
}
.popup_item_title {
margin-left: 32rpx;
font-size: 30rpx;
color: #15191F;
}
.popup_back_cart {
width: 526rpx;
height: 80rpx;
margin-top: 32rpx;
font-size: 30rpx;
color: #fff;
background-color: #86C5E1;
}
image {
width: 100%;
height: 100%;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment