Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
self-support
Project
Project
Details
Activity
Releases
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
李俊赕
self-support
Commits
addd27d9
Commit
addd27d9
authored
Jun 26, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 配件更新购物车
parent
cf9e94e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
addParts.vue
src/pages/parts/addParts.vue
+16
-7
No files found.
src/pages/parts/addParts.vue
View file @
addd27d9
...
...
@@ -53,8 +53,8 @@
:key=
"index"
:info=
"item"
:show-checked=
"false"
@
numChange=
"numChange($event, index)"
@
apply=
"apply(index)"
@
numChange=
"numChange($event, i
tem, i
ndex)"
@
apply=
"apply(i
tem, i
ndex)"
></select-parts>
<view
class=
"load-more"
>
<u-loadmore
:status=
"loadStatus"
@
loadmore=
"loadMore"
/>
...
...
@@ -98,6 +98,7 @@ export default {
scrollId
:
''
,
loadStatus
:
"loadmore"
,
lists
:
[],
submitList
:
[],
pageSize
:
20
,
pageNumber
:
1
};
...
...
@@ -110,11 +111,11 @@ export default {
},
// 配件数
partNum
()
{
return
this
.
lists
.
reduce
((
counter
,
item
)
=>
!
item
.
disabled
&&
item
.
quantity
>
0
?
counter
+=
1
:
counter
,
0
)
return
this
.
submitList
.
reduce
((
counter
,
item
)
=>
!
item
.
disabled
&&
item
.
quantity
>
0
?
counter
+=
1
:
counter
,
0
)
},
// 总数
num
()
{
return
this
.
lists
.
reduce
((
counter
,
{
disabled
,
quantity
})
=>
!
disabled
?
counter
+=
quantity
:
counter
,
0
)
return
this
.
submitList
.
reduce
((
counter
,
{
disabled
,
quantity
})
=>
!
disabled
?
counter
+=
quantity
:
counter
,
0
)
}
},
created
()
{
...
...
@@ -219,16 +220,24 @@ export default {
}
},
// 加入申请
apply
(
index
)
{
apply
(
i
tem
,
i
ndex
)
{
this
.
$set
(
this
.
lists
[
index
],
'disabled'
,
false
)
// 如果购物车没有该记录,则添加
const
findIndex
=
this
.
submitList
.
findIndex
(
v
=>
v
.
id
===
item
.
id
)
if
(
findIndex
===
-
1
)
this
.
submitList
.
push
(
item
)
},
// 改变数量
numChange
(
val
,
index
)
{
numChange
(
val
,
i
tem
,
i
ndex
)
{
this
.
$set
(
this
.
lists
[
index
],
'quantity'
,
val
)
// 如果购物车有该记录,则更新
const
findIndex
=
this
.
submitList
.
findIndex
(
v
=>
v
.
id
===
item
.
id
)
this
.
$set
(
this
.
submitList
[
findIndex
],
'quantity'
,
val
)
},
// 提交
submit
()
{
const
lists
=
this
.
lists
.
filter
(
v
=>
!
v
.
disabled
).
map
(
v
=>
{
const
lists
=
this
.
submitList
.
filter
(
v
=>
!
v
.
disabled
&&
v
.
quantity
>
0
).
map
(
v
=>
{
return
{
part_id
:
v
.
skuId
,
name
:
v
.
name
,
...
...
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