Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cauchy-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
cauchy-ui
Commits
734125c5
Commit
734125c5
authored
Jul 16, 2021
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 数据模拟
parent
262baa76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
21 deletions
+31
-21
SpuList.vue
src/views/vipLife/components/SpuList.vue
+23
-17
index.vue
src/views/vipLife/index.vue
+8
-4
No files found.
src/views/vipLife/components/SpuList.vue
View file @
734125c5
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
BScroll
from
'
@better-scroll/core
'
;
import
BScroll
from
'
@better-scroll/core
'
;
const
ITEM_WIDTH
=
108
;
const
SCROLL_
ITEM_WIDTH
=
108
;
export
default
{
export
default
{
name
:
'
SpuList
'
,
name
:
'
SpuList
'
,
props
:
{
props
:
{
...
@@ -54,18 +54,18 @@ export default {
...
@@ -54,18 +54,18 @@ export default {
this
.
listWrapper
.
scrollTo
(
0
,
0
);
this
.
listWrapper
.
scrollTo
(
0
,
0
);
this
.
listWrapper
.
refresh
();
this
.
listWrapper
.
refresh
();
});
});
return
ITEM_WIDTH
*
(
this
.
list
.
length
+
2.28
);
return
SCROLL_
ITEM_WIDTH
*
(
this
.
list
.
length
+
2.28
);
}
}
},
},
watch
:
{
watch
:
{
info
:
{
info
:
{
deep
:
true
,
deep
:
true
,
handler
(
val
)
{
handler
(
val
)
{
if
(
Object
.
hasOwnProperty
.
call
(
val
,
'
i
ndex
'
))
{
if
(
Object
.
hasOwnProperty
.
call
(
val
,
'
parentI
ndex
'
))
{
const
itemIndex
=
this
.
list
.
findIndex
(
item
=>
item
.
index
===
val
.
i
ndex
);
const
itemIndex
=
this
.
list
.
findIndex
(
item
=>
item
.
parentIndex
===
val
.
parentI
ndex
);
if
(
itemIndex
===
-
1
)
return
;
if
(
itemIndex
===
-
1
)
return
;
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
handleSpuClick
(
this
.
$refs
.
spuItem
[
itemIndex
],
val
,
itemIndex
);
this
.
handleSpuClick
(
this
.
$refs
.
spuItem
[
itemIndex
],
val
);
});
});
}
}
}
}
...
@@ -76,28 +76,34 @@ export default {
...
@@ -76,28 +76,34 @@ export default {
this
.
createScroller
();
this
.
createScroller
();
},
},
beforeDestroy
()
{
beforeDestroy
()
{
this
.
listWrapper
.
off
(
'
scroll
'
,
this
.
handleScroll
);
this
.
listWrapper
.
destroy
();
this
.
listWrapper
.
destroy
();
},
},
methods
:
{
methods
:
{
createScroller
()
{
createScroller
()
{
this
.
$nextTick
(()
=>
{
if
(
this
.
listWrapper
)
{
if
(
this
.
listWrapper
)
{
this
.
listWrapper
.
destroy
();
this
.
listWrapper
.
destroy
();
}
}
this
.
listWrapper
=
new
BScroll
(
this
.
$refs
.
spuList
,
{
this
.
listWrapper
=
new
BScroll
(
this
.
$refs
.
spuList
,
{
click
:
true
,
click
:
true
,
scrollX
:
true
,
scrollX
:
true
,
scrollY
:
false
,
scrollY
:
false
probeType
:
1
});
});
});
this
.
listWrapper
.
on
(
'
scroll
'
,
this
.
handleScroll
);
},
handleScroll
(
e
)
{
console
.
log
(
e
);
},
},
numAddUnit
(
num
)
{
numAddUnit
(
num
)
{
return
num
/
37.5
+
'
rem
'
;
return
num
/
37.5
+
'
rem
'
;
},
},
handleSpuClick
(
e
,
item
,
index
)
{
handleSpuClick
(
e
,
item
)
{
this
.
$parent
.
handleSpuSelected
(
item
,
index
);
this
.
$parent
.
handleSpuSelected
(
item
);
const
target
=
e
.
path
?
e
.
path
.
find
(
item
=>
item
.
className
.
indexOf
(
'
Vl__spu-item
'
)
>
-
1
)
:
e
;
const
target
=
e
.
path
?
e
.
path
.
find
(
item
=>
item
.
className
.
indexOf
(
'
Vl__spu-item
'
)
>
-
1
)
:
e
;
this
.
listWrapper
.
scrollToElement
(
target
,
500
,
-
10
,
0
);
this
.
$nextTick
(()
=>
{
this
.
listWrapper
.
scrollToElement
(
target
,
500
,
-
10
,
0
);
});
}
}
}
}
};
};
...
...
src/views/vipLife/index.vue
View file @
734125c5
...
@@ -67,8 +67,10 @@ export default {
...
@@ -67,8 +67,10 @@ export default {
spuList
()
{
spuList
()
{
let
spuList
=
[];
let
spuList
=
[];
this
.
spuData
.
forEach
((
item
,
index
)
=>
{
this
.
spuData
.
forEach
((
item
,
index
)
=>
{
item
.
itemList
[
0
].
index
=
index
;
item
.
itemList
.
forEach
(
it
=>
{
spuList
=
[...
spuList
,
...
item
.
itemList
];
it
.
parentIndex
=
index
;
spuList
.
push
(
it
);
});
});
});
return
spuList
;
return
spuList
;
},
},
...
@@ -130,8 +132,10 @@ export default {
...
@@ -130,8 +132,10 @@ export default {
const
[
res
]
=
await
rechargeApi
.
getSkuList
(
spuNos
,
type
);
const
[
res
]
=
await
rechargeApi
.
getSkuList
(
spuNos
,
type
);
if
(
res
)
{
if
(
res
)
{
this
.
skuList
=
res
.
rechargeList
;
this
.
skuList
=
res
.
rechargeList
;
const
defaultItem
=
res
.
rechargeList
.
find
(
item
=>
item
.
hasStock
);
// const defaultItem = res.rechargeList.find(item => item.hasStock);
const
defaultIndex
=
res
.
rechargeList
.
findIndex
(
item
=>
item
.
hasStock
);
// const defaultIndex = res.rechargeList.findIndex(item => item.hasStock);
const
defaultItem
=
res
.
rechargeList
[
0
];
const
defaultIndex
=
0
;
defaultItem
&&
this
.
handleSkuSelected
(
defaultItem
,
defaultIndex
);
defaultItem
&&
this
.
handleSkuSelected
(
defaultItem
,
defaultIndex
);
}
}
this
.
showLoading
=
false
;
this
.
showLoading
=
false
;
...
...
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