@kengic/uni 0.5.1 → 0.5.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
- package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
- package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
- package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
- package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
- package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
- package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
- package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
- package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
- package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
- package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
- package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
- package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
- package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
- package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
- package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
- package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
- package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
- package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
- package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
- package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
- package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
- package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
- package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
- package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
- package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
- package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
- package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
- package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
- package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
- package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
- package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
- package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
- package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
- package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
- package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
- package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
- package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
- package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
- package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
- package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
- package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
- package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
- package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
- package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
- package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
- package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
- package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
- package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
- package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
- package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
- package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
- package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
- package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
- package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
- package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
- package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
- package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
- package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
- package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
- package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
- package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
- package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
- package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
- package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
- package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
- package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
- package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
- package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
- package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
- package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
- package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
- package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
- package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
- package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
- package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
- package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
- package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
- package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
- package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
- package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
- package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
- package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
- package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
- package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
- package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
- package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
- package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
- package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
- package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
- package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
- package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
- package/dist/uni/uni-ui/uni-scss/package.json +73 -73
- package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
- package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
- package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
- package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
- package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
- package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
- package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
- package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
- package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
- package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
- package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
- package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
- package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
- package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
- package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
- package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
- package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
- package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
- package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
- package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
- package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
- package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
- package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
- package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
- package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
- package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
- package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
- package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
- package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
- package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
- package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
- package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
- package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
- package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
- package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
- package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
- package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
- package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
- package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
- package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
- package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
- package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
- package/package.json +1 -1
|
@@ -1,365 +1,361 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
<view>
|
|
3
|
+
<view ref="uni-rate" class="uni-rate">
|
|
4
|
+
<view
|
|
5
|
+
class="uni-rate__icon"
|
|
6
|
+
:class="{ 'uni-cursor-not-allowed': disabled }"
|
|
7
|
+
:style="{ 'margin-right': marginNumber + 'px' }"
|
|
8
|
+
v-for="(star, index) in stars"
|
|
9
|
+
:key="index"
|
|
10
|
+
@touchstart.stop="touchstart"
|
|
11
|
+
@touchmove.stop="touchmove"
|
|
12
|
+
@mousedown.stop="mousedown"
|
|
13
|
+
@mousemove.stop="mousemove"
|
|
14
|
+
@mouseleave="mouseleave"
|
|
15
|
+
>
|
|
16
|
+
<uni-icons :color="color" :size="size" :type="isFill ? 'star-filled' : 'star'" />
|
|
17
|
+
<!-- #ifdef APP-NVUE -->
|
|
18
|
+
<view :style="{ width: (star.activeWitch.replace('%', '') * size) / 100 + 'px' }" class="uni-rate__icon-on">
|
|
19
|
+
<uni-icons style="text-align: left" :color="disabled ? '#ccc' : activeColor" :size="size" type="star-filled" />
|
|
20
|
+
</view>
|
|
21
|
+
<!-- #endif -->
|
|
22
|
+
<!-- #ifndef APP-NVUE -->
|
|
23
|
+
<view :style="{ width: star.activeWitch }" class="uni-rate__icon-on">
|
|
24
|
+
<uni-icons :color="disabled ? disabledColor : activeColor" :size="size" type="star-filled" />
|
|
25
|
+
</view>
|
|
26
|
+
<!-- #endif -->
|
|
27
|
+
</view>
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
23
30
|
</template>
|
|
24
31
|
|
|
25
32
|
<script>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
// #ifdef APP-NVUE
|
|
34
|
+
const dom = uni.requireNativePlugin('dom');
|
|
35
|
+
// #endif
|
|
36
|
+
/**
|
|
37
|
+
* Rate 评分
|
|
38
|
+
* @description 评分组件
|
|
39
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=33
|
|
40
|
+
* @property {Boolean} isFill = [true|false] 星星的类型,是否为实心类型, 默认为实心
|
|
41
|
+
* @property {String} color 未选中状态的星星颜色,默认为 "#ececec"
|
|
42
|
+
* @property {String} activeColor 选中状态的星星颜色,默认为 "#ffca3e"
|
|
43
|
+
* @property {String} disabledColor 禁用状态的星星颜色,默认为 "#c0c0c0"
|
|
44
|
+
* @property {Number} size 星星的大小
|
|
45
|
+
* @property {Number} value/v-model 当前评分
|
|
46
|
+
* @property {Number} max 最大评分评分数量,目前一分一颗星
|
|
47
|
+
* @property {Number} margin 星星的间距,单位 px
|
|
48
|
+
* @property {Boolean} disabled = [true|false] 是否为禁用状态,默认为 false
|
|
49
|
+
* @property {Boolean} readonly = [true|false] 是否为只读状态,默认为 false
|
|
50
|
+
* @property {Boolean} allowHalf = [true|false] 是否实现半星,默认为 false
|
|
51
|
+
* @property {Boolean} touchable = [true|false] 是否支持滑动手势,默认为 true
|
|
52
|
+
* @event {Function} change uniRate 的 value 改变时触发事件,e={value:Number}
|
|
53
|
+
*/
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
55
|
+
export default {
|
|
56
|
+
name: 'UniRate',
|
|
57
|
+
props: {
|
|
58
|
+
isFill: {
|
|
59
|
+
// 星星的类型,是否镂空
|
|
60
|
+
type: [Boolean, String],
|
|
61
|
+
default: true,
|
|
62
|
+
},
|
|
63
|
+
color: {
|
|
64
|
+
// 星星未选中的颜色
|
|
65
|
+
type: String,
|
|
66
|
+
default: '#ececec',
|
|
67
|
+
},
|
|
68
|
+
activeColor: {
|
|
69
|
+
// 星星选中状态颜色
|
|
70
|
+
type: String,
|
|
71
|
+
default: '#ffca3e',
|
|
72
|
+
},
|
|
73
|
+
disabledColor: {
|
|
74
|
+
// 星星禁用状态颜色
|
|
75
|
+
type: String,
|
|
76
|
+
default: '#c0c0c0',
|
|
77
|
+
},
|
|
78
|
+
size: {
|
|
79
|
+
// 星星的大小
|
|
80
|
+
type: [Number, String],
|
|
81
|
+
default: 24,
|
|
82
|
+
},
|
|
83
|
+
value: {
|
|
84
|
+
// 当前评分
|
|
85
|
+
type: [Number, String],
|
|
86
|
+
default: 0,
|
|
87
|
+
},
|
|
88
|
+
modelValue: {
|
|
89
|
+
// 当前评分
|
|
90
|
+
type: [Number, String],
|
|
91
|
+
default: 0,
|
|
92
|
+
},
|
|
93
|
+
max: {
|
|
94
|
+
// 最大评分
|
|
95
|
+
type: [Number, String],
|
|
96
|
+
default: 5,
|
|
97
|
+
},
|
|
98
|
+
margin: {
|
|
99
|
+
// 星星的间距
|
|
100
|
+
type: [Number, String],
|
|
101
|
+
default: 0,
|
|
102
|
+
},
|
|
103
|
+
disabled: {
|
|
104
|
+
// 是否可点击
|
|
105
|
+
type: [Boolean, String],
|
|
106
|
+
default: false,
|
|
107
|
+
},
|
|
108
|
+
readonly: {
|
|
109
|
+
// 是否只读
|
|
110
|
+
type: [Boolean, String],
|
|
111
|
+
default: false,
|
|
112
|
+
},
|
|
113
|
+
allowHalf: {
|
|
114
|
+
// 是否显示半星
|
|
115
|
+
type: [Boolean, String],
|
|
116
|
+
default: false,
|
|
117
|
+
},
|
|
118
|
+
touchable: {
|
|
119
|
+
// 是否支持滑动手势
|
|
120
|
+
type: [Boolean, String],
|
|
121
|
+
default: true,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
data() {
|
|
125
|
+
return {
|
|
126
|
+
valueSync: '',
|
|
127
|
+
userMouseFristMove: true,
|
|
128
|
+
userRated: false,
|
|
129
|
+
userLastRate: 1,
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
watch: {
|
|
133
|
+
value(newVal) {
|
|
134
|
+
this.valueSync = Number(newVal);
|
|
135
|
+
},
|
|
136
|
+
modelValue(newVal) {
|
|
137
|
+
this.valueSync = Number(newVal);
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
computed: {
|
|
141
|
+
stars() {
|
|
142
|
+
const value = this.valueSync ? this.valueSync : 0;
|
|
143
|
+
const starList = [];
|
|
144
|
+
const floorValue = Math.floor(value);
|
|
145
|
+
const ceilValue = Math.ceil(value);
|
|
146
|
+
for (let i = 0; i < this.max; i++) {
|
|
147
|
+
if (floorValue > i) {
|
|
148
|
+
starList.push({
|
|
149
|
+
activeWitch: '100%',
|
|
150
|
+
});
|
|
151
|
+
} else if (ceilValue - 1 === i) {
|
|
152
|
+
starList.push({
|
|
153
|
+
activeWitch: (value - floorValue) * 100 + '%',
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
starList.push({
|
|
157
|
+
activeWitch: '0',
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return starList;
|
|
162
|
+
},
|
|
156
163
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const {
|
|
193
|
-
clientX,
|
|
194
|
-
screenX
|
|
195
|
-
} = e.changedTouches[0]
|
|
196
|
-
this._getRateCount(clientX || screenX)
|
|
197
|
-
},
|
|
164
|
+
marginNumber() {
|
|
165
|
+
return Number(this.margin);
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
created() {
|
|
169
|
+
this.valueSync = Number(this.value || this.modelValue);
|
|
170
|
+
this._rateBoxLeft = 0;
|
|
171
|
+
this._oldValue = null;
|
|
172
|
+
},
|
|
173
|
+
mounted() {
|
|
174
|
+
setTimeout(() => {
|
|
175
|
+
this._getSize();
|
|
176
|
+
}, 100);
|
|
177
|
+
// #ifdef H5
|
|
178
|
+
this.PC = this.IsPC();
|
|
179
|
+
// #endif
|
|
180
|
+
},
|
|
181
|
+
methods: {
|
|
182
|
+
touchstart(e) {
|
|
183
|
+
// #ifdef H5
|
|
184
|
+
if (this.IsPC()) return;
|
|
185
|
+
// #endif
|
|
186
|
+
if (this.readonly || this.disabled) return;
|
|
187
|
+
const { clientX, screenX } = e.changedTouches[0];
|
|
188
|
+
// TODO 做一下兼容,只有 Nvue 下才有 screenX,其他平台式 clientX
|
|
189
|
+
this._getRateCount(clientX || screenX);
|
|
190
|
+
},
|
|
191
|
+
touchmove(e) {
|
|
192
|
+
// #ifdef H5
|
|
193
|
+
if (this.IsPC()) return;
|
|
194
|
+
// #endif
|
|
195
|
+
if (this.readonly || this.disabled || !this.touchable) return;
|
|
196
|
+
const { clientX, screenX } = e.changedTouches[0];
|
|
197
|
+
this._getRateCount(clientX || screenX);
|
|
198
|
+
},
|
|
198
199
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
/**
|
|
201
|
+
* 兼容 PC @tian
|
|
202
|
+
*/
|
|
202
203
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
return flag;
|
|
254
|
-
},
|
|
255
|
-
// #endif
|
|
204
|
+
mousedown(e) {
|
|
205
|
+
// #ifdef H5
|
|
206
|
+
if (!this.IsPC()) return;
|
|
207
|
+
if (this.readonly || this.disabled) return;
|
|
208
|
+
const { clientX } = e;
|
|
209
|
+
this.userLastRate = this.valueSync;
|
|
210
|
+
this._getRateCount(clientX);
|
|
211
|
+
this.userRated = true;
|
|
212
|
+
// #endif
|
|
213
|
+
},
|
|
214
|
+
mousemove(e) {
|
|
215
|
+
// #ifdef H5
|
|
216
|
+
if (!this.IsPC()) return;
|
|
217
|
+
if (this.userRated) return;
|
|
218
|
+
if (this.userMouseFristMove) {
|
|
219
|
+
console.log('---mousemove----', this.valueSync);
|
|
220
|
+
this.userLastRate = this.valueSync;
|
|
221
|
+
this.userMouseFristMove = false;
|
|
222
|
+
}
|
|
223
|
+
if (this.readonly || this.disabled || !this.touchable) return;
|
|
224
|
+
const { clientX } = e;
|
|
225
|
+
this._getRateCount(clientX);
|
|
226
|
+
// #endif
|
|
227
|
+
},
|
|
228
|
+
mouseleave(e) {
|
|
229
|
+
// #ifdef H5
|
|
230
|
+
if (!this.IsPC()) return;
|
|
231
|
+
if (this.readonly || this.disabled || !this.touchable) return;
|
|
232
|
+
if (this.userRated) {
|
|
233
|
+
this.userRated = false;
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
this.valueSync = this.userLastRate;
|
|
237
|
+
// #endif
|
|
238
|
+
},
|
|
239
|
+
// #ifdef H5
|
|
240
|
+
IsPC() {
|
|
241
|
+
var userAgentInfo = navigator.userAgent;
|
|
242
|
+
var Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
|
|
243
|
+
var flag = true;
|
|
244
|
+
for (let v = 0; v < Agents.length - 1; v++) {
|
|
245
|
+
if (userAgentInfo.indexOf(Agents[v]) > 0) {
|
|
246
|
+
flag = false;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return flag;
|
|
251
|
+
},
|
|
252
|
+
// #endif
|
|
256
253
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
value = Math.max(0.5, Math.min(value, _this.max))
|
|
286
|
-
_this.valueSync = value
|
|
287
|
-
_this._onChange()
|
|
288
|
-
})
|
|
289
|
-
},
|
|
254
|
+
/**
|
|
255
|
+
* 获取星星个数
|
|
256
|
+
*/
|
|
257
|
+
_getRateCount(clientX) {
|
|
258
|
+
const _this = this;
|
|
259
|
+
this._getSize(function () {
|
|
260
|
+
const size = Number(_this.size);
|
|
261
|
+
if (isNaN(size)) {
|
|
262
|
+
return new Error('size 属性只能设置为数字');
|
|
263
|
+
}
|
|
264
|
+
const rateMoveRange = clientX - _this._rateBoxLeft;
|
|
265
|
+
let index = parseInt(rateMoveRange / (size + _this.marginNumber));
|
|
266
|
+
index = index < 0 ? 0 : index;
|
|
267
|
+
index = index > _this.max ? _this.max : index;
|
|
268
|
+
const range = parseInt(rateMoveRange - (size + _this.marginNumber) * index);
|
|
269
|
+
let value = 0;
|
|
270
|
+
if (_this._oldValue === index && !_this.PC) return;
|
|
271
|
+
_this._oldValue = index;
|
|
272
|
+
if (_this.allowHalf) {
|
|
273
|
+
if (range > size / 2) {
|
|
274
|
+
value = index + 1;
|
|
275
|
+
} else {
|
|
276
|
+
value = index + 0.5;
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
value = index + 1;
|
|
280
|
+
}
|
|
290
281
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
282
|
+
value = Math.max(0.5, Math.min(value, _this.max));
|
|
283
|
+
_this.valueSync = value;
|
|
284
|
+
_this._onChange();
|
|
285
|
+
});
|
|
286
|
+
},
|
|
295
287
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
288
|
+
/**
|
|
289
|
+
* 触发动态修改
|
|
290
|
+
*/
|
|
291
|
+
_onChange() {
|
|
292
|
+
this.$emit('input', this.valueSync);
|
|
293
|
+
this.$emit('update:modelValue', this.valueSync);
|
|
294
|
+
this.$emit('change', {
|
|
295
|
+
value: this.valueSync,
|
|
296
|
+
});
|
|
297
|
+
},
|
|
298
|
+
/**
|
|
299
|
+
* 获取星星距离屏幕左侧距离
|
|
300
|
+
*/
|
|
301
|
+
_getSize(fn) {
|
|
302
|
+
// #ifndef APP-NVUE
|
|
303
|
+
uni.createSelectorQuery()
|
|
304
|
+
.in(this)
|
|
305
|
+
.select('.uni-rate')
|
|
306
|
+
.boundingClientRect()
|
|
307
|
+
.exec((ret) => {
|
|
308
|
+
if (ret) {
|
|
309
|
+
this._rateBoxLeft = ret[0].left;
|
|
310
|
+
fn && fn();
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
// #endif
|
|
314
|
+
// #ifdef APP-NVUE
|
|
315
|
+
dom.getComponentRect(this.$refs['uni-rate'], (ret) => {
|
|
316
|
+
const size = ret.size;
|
|
317
|
+
if (size) {
|
|
318
|
+
this._rateBoxLeft = size.left;
|
|
319
|
+
fn && fn();
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
// #endif
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
};
|
|
330
326
|
</script>
|
|
331
327
|
|
|
332
328
|
<style lang="scss">
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
329
|
+
.uni-rate {
|
|
330
|
+
/* #ifndef APP-NVUE */
|
|
331
|
+
display: flex;
|
|
332
|
+
/* #endif */
|
|
333
|
+
line-height: 1;
|
|
334
|
+
font-size: 0;
|
|
335
|
+
flex-direction: row;
|
|
336
|
+
/* #ifdef H5 */
|
|
337
|
+
cursor: pointer;
|
|
338
|
+
/* #endif */
|
|
339
|
+
}
|
|
344
340
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
341
|
+
.uni-rate__icon {
|
|
342
|
+
position: relative;
|
|
343
|
+
line-height: 1;
|
|
344
|
+
font-size: 0;
|
|
345
|
+
}
|
|
350
346
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
347
|
+
.uni-rate__icon-on {
|
|
348
|
+
overflow: hidden;
|
|
349
|
+
position: absolute;
|
|
350
|
+
top: 0;
|
|
351
|
+
left: 0;
|
|
352
|
+
line-height: 1;
|
|
353
|
+
text-align: left;
|
|
354
|
+
}
|
|
359
355
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
356
|
+
.uni-cursor-not-allowed {
|
|
357
|
+
/* #ifdef H5 */
|
|
358
|
+
cursor: not-allowed !important;
|
|
359
|
+
/* #endif */
|
|
360
|
+
}
|
|
365
361
|
</style>
|