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