Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7-Eleven
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高淑倩
7-Eleven
Commits
b4c673c0
Commit
b4c673c0
authored
Aug 19, 2019
by
高淑倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: 购物车_商品总价
parent
a289cf01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
54 deletions
+42
-54
cart.js
src/pages/cart/cart.js
+41
-53
cart.wxml
src/pages/cart/cart.wxml
+1
-1
No files found.
src/pages/cart/cart.js
View file @
b4c673c0
...
...
@@ -16,7 +16,8 @@ wxService.page({
cartList
:
[],
outGoods
:
[],
checkAll
:
false
,
checkedColor
:
'rgb(203, 60, 60)'
checkedColor
:
'rgb(203, 60, 60)'
,
shopCartTotalFee
:
0
,
// 商品总价
},
/**
...
...
@@ -144,23 +145,22 @@ wxService.page({
},
blurNum
:
function
(
e
)
{
var
newNum
=
e
.
detail
.
value
console
.
log
(
'blurNum'
,
newNum
)
var
cartList
=
this
.
data
.
cartList
if
(
newNum
===
''
)
{
newNum
=
1
}
// cartList[e.currentTarget.dataset.index].quantity = newNum
// this.setData({
// cartList: cartList
// }, function () {
// this.setTotalFee()
// this.editOk(cartList[e.currentTarget.dataset.index]) //调用完成
// })
cartList
[
e
.
currentTarget
.
dataset
.
index
].
count
=
newNum
this
.
setData
({
cartList
:
cartList
},
function
()
{
this
.
setTotalFee
()
this
.
editOk
(
cartList
[
e
.
currentTarget
.
dataset
.
index
])
//调用完成
})
},
inputNum
:
function
(
e
)
{
// 输入数量
var
newNum
=
e
.
detail
.
value
console
.
log
(
'newNum'
,
newNum
)
if
(
newNum
)
{
const
{
cartList
}
=
this
.
data
if
(
newNum
===
'0'
)
{
...
...
@@ -168,41 +168,31 @@ wxService.page({
}
else
{
newNum
=
parseInt
(
newNum
)
}
cartList
[
e
.
currentTarget
.
dataset
.
index
].
count
=
newNum
this
.
setData
({
cartList
:
cartList
},
function
()
{
this
.
setTotalFee
()
this
.
editOk
(
cartList
[
e
.
currentTarget
.
dataset
.
index
])
//调用完成
})
}
},
setTotalFee
(
skipRedemption
)
{
var
cartList
=
this
.
data
.
cartList
var
checkProsId
=
[]
// 选中的商品id
var
totalFee
=
0
// 购物车总金额
for
(
let
i
=
0
;
i
<
cartList
.
length
;
i
++
)
{
if
(
cartList
[
i
].
checked
)
{
totalFee
+=
cartList
[
i
].
price
*
(
cartList
[
i
].
count
?
cartList
[
i
].
count
:
1
)
checkProsId
.
push
(
cartList
[
i
].
skuId
)
}
}
// if(newNum) {
// var cartList = this.data.cartList
// var choosePro = cartList[e.currentTarget.dataset.index]
// if (newNum === '0') {
// newNum = 1
// } else {
// newNum = parseInt(newNum)
// if (choosePro.quantityAverage == '0') {
// if (newNum > choosePro.selectSku.inventory_num) {
// newNum = choosePro.selectSku.inventory_num
// wx.showToast({
// title: '不能超过库存',
// icon: 'none'
// })
// }
// } else {
// if (newNum > choosePro.quantityAverage) {
// newNum = choosePro.quantityAverage
// wx.showToast({
// title: '每人限购' + choosePro.quantityAverage + '件',
// icon: 'none'
// })
// }
// }
// }
// cartList[e.currentTarget.dataset.index].quantity = newNum
// this.setData({
// cartList: cartList
// }, function () {
// this.setTotalFee()
// this.editOk(cartList[e.currentTarget.dataset.index]) //调用完成
// })
// }
this
.
setData
({
shopCartTotalFee
:
totalFee
.
toFixed
(
2
)
})
},
goBuy
()
{
...
...
@@ -263,19 +253,17 @@ wxService.page({
})
},
// 调整商品 /trolley/add
editOk
()
{
editOk
(
cartPro
)
{
console
.
log
(
'cartPro'
,
cartPro
)
// count skuId
wx
.
showLoading
({
title
:
'加载中'
})
wxService
.
post
(
'/sale/trolley/add'
).
then
(
res
=>
{
console
.
log
(
'query'
,
res
)
wxService
.
post
(
`/sale/trolley/add?count=
${
cartPro
.
count
}
&skuId=
${
cartPro
.
skuId
}
`
).
then
(
res
=>
{
if
(
res
)
{
const
{
result
,
data
}
=
res
.
data
const
{
result
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
this
.
setData
({
// cartList
})
}
else
{
wx
.
showToast
({
title
:
res
.
data
.
message
,
...
...
@@ -308,7 +296,7 @@ wxService.page({
cartList
:
cartList
,
checkAll
:
checkAll
},
function
()
{
//
this.setTotalFee()
this
.
setTotalFee
()
})
},
...
...
@@ -324,7 +312,7 @@ wxService.page({
}),
checkAll
:
false
},
function
()
{
//
this.setTotalFee()
this
.
setTotalFee
()
})
}
else
{
this
.
setData
({
...
...
@@ -335,7 +323,7 @@ wxService.page({
}),
checkAll
:
true
},
function
()
{
//
this.setTotalFee()
this
.
setTotalFee
()
})
}
},
...
...
src/pages/cart/cart.wxml
View file @
b4c673c0
...
...
@@ -68,7 +68,7 @@
</view>
<view class="total-amount">
<text class="total-label">合计:</text>
<text class="total-price">¥
306
</text>
<text class="total-price">¥
{{shopCartTotalFee}}
</text>
</view>
</view>
<view class="theme-color buy-btn" bindtap="goBuy">立即购买</view>
...
...
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