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
0d68fbfa
Commit
0d68fbfa
authored
Jul 08, 2021
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 优化
parent
b78d5d00
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
131 additions
and
55 deletions
+131
-55
SkuList.vue
src/views/vipLife/components/SkuList.vue
+7
-1
SpuList.vue
src/views/vipLife/components/SpuList.vue
+75
-45
index.less
src/views/vipLife/index.less
+15
-0
index.vue
src/views/vipLife/index.vue
+34
-9
No files found.
src/views/vipLife/components/SkuList.vue
View file @
0d68fbfa
...
@@ -11,7 +11,9 @@
...
@@ -11,7 +11,9 @@
}"
}"
@click="parent.handleSkuSelected(item, index)"
@click="parent.handleSkuSelected(item, index)"
>
>
<div
class=
"Vl__sku-name"
>
{{
props
.
threeCol
?
item
.
salePrice
:
item
.
skuName
}}
元
</div>
<div
class=
"Vl__sku-name"
>
{{
props
.
threeCol
?
item
.
salePrice
:
item
.
skuName
}}{{
showUnit
?
'
元
'
:
''
}}
</div>
<div
class=
"Vl__sku-price"
>
售价
{{
props
.
threeCol
?
item
.
price
:
item
.
salePrice
}}
元
</div>
<div
class=
"Vl__sku-price"
>
售价
{{
props
.
threeCol
?
item
.
price
:
item
.
salePrice
}}
元
</div>
<div
class=
"Vl__sku-tag"
>
优惠
</div>
<div
class=
"Vl__sku-tag"
>
优惠
</div>
</div>
</div>
...
@@ -30,6 +32,10 @@ export default {
...
@@ -30,6 +32,10 @@ export default {
type
:
Object
,
type
:
Object
,
default
:
()
=>
{}
default
:
()
=>
{}
},
},
showUnit
:
{
type
:
Boolean
,
default
:
true
},
disabled
:
Boolean
disabled
:
Boolean
}
}
};
};
...
...
src/views/vipLife/components/SpuList.vue
View file @
0d68fbfa
<
template
>
<
template
>
<div
class=
"Vl__spu"
>
<div
ref=
"spuList"
class=
"Vl__spu-wrapper"
>
<div
<div
class=
"Vl__spu"
:style=
"
{ width: numAddUnit(contentWidth) }">
v-for=
"(item, index) in list"
<div
:key=
"index"
v-for=
"(item, index) in list"
class=
"Vl__spu-item"
:key=
"index"
:class=
"
{ 'Vl__spu-item_active': info.spuNo === item.spuNo }"
class=
"Vl__spu-item"
@click="$parent.handleSpuSelected(item, index)"
:class=
"
{ 'Vl__spu-item_active': info.spuNo === item.spuNo }"
>
@click="handleSpuClick($event, item, index)"
<cr-image
:src=
"item.icon"
height=
"1.093333rem"
width=
"1.093333rem"
class=
"Vl__spu-icon"
/>
>
<div
class=
"Vl__spu-name"
>
{{
item
.
name
}}
</div>
<cr-image
:src=
"item.icon"
height=
"1.093333rem"
width=
"1.093333rem"
class=
"Vl__spu-icon"
/>
<div
class=
"Vl__spu-name"
>
{{
item
.
name
}}
</div>
</div>
<div
class=
"Vl__spu-placeholder"
:style=
"
{ width: numAddUnit(placeholderWidth) }" />
</div>
</div>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
BScroll
from
'
@better-scroll/core
'
;
const
ITEM_WIDTH
=
108
;
export
default
{
export
default
{
name
:
'
SpuList
'
,
name
:
'
SpuList
'
,
props
:
{
props
:
{
list
:
{
list
:
{
type
:
Array
,
type
:
Array
,
default
:
()
=>
[]
default
:
()
=>
[
{
spuNo
:
''
,
icon
:
''
,
name
:
''
}
]
},
},
info
:
{
info
:
{
type
:
Object
,
type
:
Object
,
default
:
()
=>
{}
default
:
()
=>
{}
}
}
},
},
data
()
{
data
:
function
()
{
return
{
return
{
scrollWidth
:
0
,
listWrapper
:
null
scrollLeft
:
0
,
top
:
0
};
};
},
},
mounted
()
{
computed
:
{
this
.
getScrollInfo
();
contentWidth
()
{
// this.$el.addEventListener('scroll', this.handleScoll);
this
.
$nextTick
(()
=>
{
this
.
listWrapper
&&
this
.
listWrapper
.
refresh
();
});
return
ITEM_WIDTH
*
this
.
list
.
length
+
this
.
placeholderWidth
;
},
placeholderWidth
()
{
return
((
this
.
list
.
length
%
4
)
+
1.335
)
*
ITEM_WIDTH
;
}
},
},
// beforeDestroy() {
// this.$el.removeEventListener('scroll', this.handleScoll);
mounted
()
{
// },
this
.
$nextTick
(()
=>
{
// activated() {
this
.
listWrapper
=
new
BScroll
(
this
.
$refs
.
spuList
,
{
// this.$el.addEventListener('scroll', this.handleScoll);
click
:
true
,
// },
scrollX
:
true
,
// deactivated() {
scrollY
:
false
// this.$el.removeEventListener('scroll', this.handleScoll);
});
// },
});
updated
()
{
console
.
log
(
111
);
},
},
methods
:
{
methods
:
{
getScrollInfo
()
{
numAddUnit
(
num
)
{
this
.
scrollWidth
=
this
.
$el
.
scrollWidth
;
return
num
/
37.5
+
'
rem
'
;
},
handleSpuClick
(
e
,
item
,
index
)
{
this
.
$parent
.
handleSpuSelected
(
item
,
index
);
const
target
=
e
.
path
.
find
(
item
=>
item
.
className
.
indexOf
(
'
Vl__spu-item
'
)
>
-
1
);
console
.
dir
(
target
);
this
.
listWrapper
.
scrollToElement
(
target
,
500
,
-
10
,
0
);
}
}
}
}
};
};
...
@@ -58,22 +78,32 @@ export default {
...
@@ -58,22 +78,32 @@ export default {
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
.Vl {
.Vl {
&__spu {
&__spu {
padding: @padding-sm 0;
&-wrapper {
width: 375px;
height: 121px;
overflow: hidden;
}
&-placeholder {
height: 97px;
width: 95px;
flex-shrink: 0;
margin-right: @padding-sm;
}
padding: @padding-sm 0 @padding-sm @padding-sm;
display: flex;
display: flex;
align-items: center;
align-items: center;
overflow: auto;
position: relative;
position: relative;
&::before,
//
&::before,
&::after {
//
&::after {
content: ' ';
//
content: ' ';
flex-shrink: 0;
//
flex-shrink: 0;
display: block;
//
display: block;
width: @padding-sm;
//
width: @padding-sm;
height: 97px;
//
height: 97px;
}
//
}
&::after {
//
&::after {
width: @padding-unit;
//
width: @padding-unit;
}
//
}
&-item {
&-item {
height: 97px;
height: 97px;
width: 95px;
width: 95px;
...
@@ -84,7 +114,7 @@ export default {
...
@@ -84,7 +114,7 @@ export default {
flex-direction: column;
flex-direction: column;
align-items: center;
align-items: center;
justify-content: center;
justify-content: center;
margin-right: @padding-
xs
;
margin-right: @padding-
sm
;
transition: all 0.2s linear;
transition: all 0.2s linear;
&_active {
&_active {
box-shadow: 0px 2px 12px 0px rgba(100, 101, 102, 0.12);
box-shadow: 0px 2px 12px 0px rgba(100, 101, 102, 0.12);
...
...
src/views/vipLife/index.less
View file @
0d68fbfa
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
border-radius: @border-radius-lx @border-radius-lx 0 0;
border-radius: @border-radius-lx @border-radius-lx 0 0;
padding: @padding-lg @padding-lg @bottom-height;
padding: @padding-lg @padding-lg @bottom-height;
min-height: 340px;
min-height: 340px;
position: relative;
&-placeholder {
&-placeholder {
margin-bottom: -@padding-lg;
margin-bottom: -@padding-lg;
}
}
...
@@ -14,6 +15,20 @@
...
@@ -14,6 +15,20 @@
font-weight: @font-weight-bold - 100;
font-weight: @font-weight-bold - 100;
margin: @padding-lg + @padding-unit 0 @padding-sm;
margin: @padding-lg + @padding-unit 0 @padding-sm;
}
}
&-loading {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2;
background: rgba(255, 255, 255, 0.7);
display: flex;
justify-content: center;
.cr-loading {
margin-top: 200px;
}
}
}
}
&__bottom {
&__bottom {
position: fixed;
position: fixed;
...
...
src/views/vipLife/index.vue
View file @
0d68fbfa
...
@@ -5,16 +5,21 @@
...
@@ -5,16 +5,21 @@
</cr-tabs>
</cr-tabs>
<spu-list
ref=
"spuList"
:list=
"spuList"
:info=
"spuInfo"
/>
<spu-list
ref=
"spuList"
:list=
"spuList"
:info=
"spuInfo"
/>
<div
class=
"Vl__panel"
>
<div
class=
"Vl__panel"
>
<account-input
v-if=
"spuInfo.rechargeAccountType !== 2"
v-model=
"account"
:info=
"spuInfo"
/>
<template>
<div
v-else
class=
"Vl__panel-placeholder"
/>
<account-input
v-if=
"spuInfo.rechargeAccountType !== 2"
v-model=
"account"
:info=
"spuInfo"
/>
<div
v-else
class=
"Vl__panel-placeholder"
/>
</
template
>
<div
class=
"Vl__panel-title"
>
充值类型
</div>
<div
class=
"Vl__panel-title"
>
充值类型
</div>
<sku-list
:list=
"skuList"
:info=
"skuInfo"
/>
<sku-list
:list=
"skuList"
:info=
"skuInfo"
:show-unit=
"false"
/>
<div
v-show=
"showLoading"
class=
"Vl__panel-loading"
>
<cr-loading
color=
"#ec1500"
/>
</div>
<
template
v-if=
"tips"
>
<
template
v-if=
"tips"
>
<div
class=
"Vl__panel-title"
>
温馨提示
</div>
<div
class=
"Vl__panel-title"
>
温馨提示
</div>
<div
class=
"Vl__panel-tips"
v-html=
"tips"
/>
<div
class=
"Vl__panel-tips"
v-html=
"tips"
/>
</
template
>
</
template
>
</div>
</div>
<div
class=
"Vl__bottom"
>
<div
v-if=
"!hideFixedBottom"
class=
"Vl__bottom"
>
<cr-button
type=
"primary"
block
shape=
"circle"
:disabled=
"disabled"
@
click=
"goOrder"
>
<cr-button
type=
"primary"
block
shape=
"circle"
:disabled=
"disabled"
@
click=
"goOrder"
>
立即充值
立即充值
</cr-button>
</cr-button>
...
@@ -22,6 +27,7 @@
...
@@ -22,6 +27,7 @@
</div>
</div>
</template>
</template>
<
script
>
<
script
>
import
{
onKeyboardStateChange
,
clearKeyboard
}
from
'
@/service/utils.service
'
;
import
rechargeApi
from
'
@/api/recharge.api
'
;
import
rechargeApi
from
'
@/api/recharge.api
'
;
import
orderApi
from
'
@/api/order.api
'
;
import
orderApi
from
'
@/api/order.api
'
;
import
tipsData
from
'
@/api/tips
'
;
import
tipsData
from
'
@/api/tips
'
;
...
@@ -42,7 +48,10 @@ export default {
...
@@ -42,7 +48,10 @@ export default {
spuData
:
[],
spuData
:
[],
spuInfo
:
{},
spuInfo
:
{},
skuInfo
:
{},
skuInfo
:
{},
skuList
:
[]
skuList
:
[],
skuTimer
:
null
,
showLoading
:
false
,
hideFixedBottom
:
false
};
};
},
},
computed
:
{
computed
:
{
...
@@ -61,17 +70,25 @@ export default {
...
@@ -61,17 +70,25 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
getList
();
this
.
getList
();
});
});
onKeyboardStateChange
(
val
=>
{
this
.
hideFixedBottom
=
val
;
},
false
);
},
beforeRouteLeave
(
to
,
from
,
next
)
{
// 清除键盘
clearKeyboard
();
next
();
},
},
methods
:
{
methods
:
{
handleTabChange
(
name
)
{
handleTabChange
(
name
)
{
this
.
currentTab
=
name
;
this
.
currentTab
=
name
;
this
.
updateSpuInfo
(
this
.
spuData
[
this
.
currentTab
-
1
].
itemList
[
0
]);
this
.
updateSpuInfo
(
this
.
spuData
[
this
.
currentTab
-
1
].
itemList
[
0
]);
this
.
getSkuList
();
this
.
getSkuList
Debounce
();
},
},
handleSpuSelected
(
item
)
{
handleSpuSelected
(
item
)
{
this
.
spuInfo
=
item
;
this
.
spuInfo
=
item
;
this
.
updateSpuInfo
(
item
);
this
.
updateSpuInfo
(
item
);
this
.
getSkuList
();
this
.
getSkuList
Debounce
();
},
},
handleSkuSelected
(
item
,
index
)
{
handleSkuSelected
(
item
,
index
)
{
this
.
skuInfo
=
item
;
this
.
skuInfo
=
item
;
...
@@ -84,10 +101,17 @@ export default {
...
@@ -84,10 +101,17 @@ export default {
const
[
res
]
=
await
rechargeApi
.
getSpuList
();
const
[
res
]
=
await
rechargeApi
.
getSpuList
();
if
(
res
)
{
if
(
res
)
{
this
.
spuData
=
res
.
vipLife
;
this
.
spuData
=
res
.
vipLife
;
this
.
spuInfo
=
this
.
spuData
[
this
.
currentTab
].
itemList
[
0
]
;
this
.
updateSpuInfo
(
this
.
spuData
[
this
.
currentTab
-
1
].
itemList
[
0
])
;
this
.
getSkuList
();
this
.
getSkuList
Debounce
();
}
}
},
},
getSkuListDebounce
()
{
this
.
showLoading
=
true
;
if
(
this
.
skuTimer
)
clearTimeout
(
this
.
skuTimer
);
this
.
skuTimer
=
setTimeout
(()
=>
{
this
.
getSkuList
();
},
600
);
},
async
getSkuList
()
{
async
getSkuList
()
{
this
.
skuList
=
[];
this
.
skuList
=
[];
const
{
spuNo
:
spuNos
,
type
}
=
this
.
spuInfo
;
const
{
spuNo
:
spuNos
,
type
}
=
this
.
spuInfo
;
...
@@ -96,6 +120,7 @@ export default {
...
@@ -96,6 +120,7 @@ export default {
this
.
skuList
=
res
.
rechargeList
;
this
.
skuList
=
res
.
rechargeList
;
this
.
handleSkuSelected
(
res
.
rechargeList
[
0
],
0
);
this
.
handleSkuSelected
(
res
.
rechargeList
[
0
],
0
);
}
}
this
.
showLoading
=
false
;
},
},
async
goOrder
()
{
async
goOrder
()
{
if
(
!
this
.
account
&&
this
.
spuInfo
.
rechargeAccountType
!==
2
)
if
(
!
this
.
account
&&
this
.
spuInfo
.
rechargeAccountType
!==
2
)
...
...
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