Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
uview-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
李晖
uview-ui
Commits
df1303d6
Commit
df1303d6
authored
Sep 20, 2020
by
TtTao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增:评分分级分层、评分半星显示
parent
cc56616c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
index.vue
pages/componentsB/rate/index.vue
+17
-2
u-rate.vue
uview-ui/components/u-rate/u-rate.vue
+4
-6
No files found.
pages/componentsB/rate/index.vue
View file @
df1303d6
...
...
@@ -6,7 +6,7 @@
<u-rate
v-model=
"value"
:count=
"count"
@
change=
"change"
:active-color=
"activeColor"
:inaction-color=
"inactiveColor"
:active-icon=
"activeIcon"
:inactive-icon=
"inactiveIcon"
:disabled=
"disabled"
></u-rate>
:disabled=
"disabled"
:colors=
"colors"
:icons=
"icons"
></u-rate>
</view>
</view>
<view
class=
"u-config-wrap"
>
...
...
@@ -29,6 +29,10 @@
<view
class=
"u-item-title"
>
自定义图标
</view>
<u-subsection
vibrateShort
current=
"1"
:list=
"['是', '否']"
@
change=
"iconChange"
></u-subsection>
</view>
<view
class=
"u-config-item"
>
<view
class=
"u-item-title"
>
是否分层
</view>
<u-subsection
vibrateShort
current=
"1"
:list=
"['是', '否']"
@
change=
"decimalChange"
></u-subsection>
</view>
<view
class=
"u-config-item"
>
<view
class=
"u-item-title"
>
是否禁用
</view>
<u-subsection
vibrateShort
current=
"1"
:list=
"['是', '否']"
@
change=
"disabledChange"
></u-subsection>
...
...
@@ -53,7 +57,9 @@
count
:
5
,
customIcon
:
false
,
plain
:
false
,
value
:
0
value
:
0
,
colors
:
[],
icons
:
[]
}
},
watch
:
{
...
...
@@ -93,6 +99,15 @@
this
.
inactiveColor
=
'
#b2b2b2
'
;
}
},
decimalChange
(
index
)
{
if
(
index
==
0
)
{
this
.
colors
=
[
'
#ffc454
'
,
'
#ffb409
'
,
'
#ff9500
'
];
this
.
icons
=
[
'
thumb-down-fill
'
,
'
thumb-down-fill
'
,
'
thumb-up-fill
'
,
'
thumb-up-fill
'
];
}
else
{
this
.
colors
=
[];
this
.
icons
=
[];
}
},
iconChange
(
index
)
{
this
.
customIcon
=
!
index
;
},
...
...
uview-ui/components/u-rate/u-rate.vue
View file @
df1303d6
...
...
@@ -31,8 +31,6 @@
* @property {String} inactive-icon 未选中时的图标名,只能为uView的内置图标(默认star)
* @property {String} gutter 星星之间的距离(默认10)
* @property {String Number} min-count 最少选中星星的个数(默认0)
* @property {Array} colors 颜色分级显示,可以用不同颜色区分评分层级
* @property {Array} icons 图标分级显示,可以用不同类型的icon区分评分层级
* @property {Boolean} allow-half 是否允许半星选择(默认false)
* @event {Function} change 选中的星星发生变化时触发
* @example <u-rate :count="count" :current="2"></u-rate>
...
...
@@ -108,14 +106,12 @@ export default {
type
:
String
,
default
:
'
uicon
'
},
// 颜色分级显示,可以用不同颜色区分评分层级
colors
:
{
type
:
Array
,
default
()
{
return
[]
}
},
// 图标分级显示,可以用不同类型的icon区分评分层级
icons
:
{
type
:
Array
,
default
()
{
...
...
@@ -153,8 +149,9 @@ export default {
},
elActiveIcon
()
{
const
len
=
this
.
icons
.
length
if
(
len
)
{
if
(
len
&&
len
<=
this
.
count
)
{
const
step
=
Math
.
round
(
this
.
activeIndex
/
Math
.
round
(
this
.
count
/
len
))
if
(
step
<
1
)
return
this
.
icons
[
0
]
if
(
step
>
len
)
return
this
.
icons
[
len
-
1
]
return
this
.
icons
[
step
-
1
]
}
...
...
@@ -162,8 +159,9 @@ export default {
},
elActiveColor
()
{
const
len
=
this
.
colors
.
length
if
(
len
)
{
if
(
len
&&
len
<=
this
.
count
)
{
const
step
=
Math
.
round
(
this
.
activeIndex
/
Math
.
round
(
this
.
count
/
len
))
if
(
step
<
1
)
return
this
.
colors
[
0
]
if
(
step
>
len
)
return
this
.
colors
[
len
-
1
]
return
this
.
colors
[
step
-
1
]
}
...
...
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