@vtj/materials 0.10.6 → 0.10.8

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 (77) hide show
  1. package/dist/assets/antdv/index.umd.js +2 -2
  2. package/dist/assets/charts/index.umd.js +2 -2
  3. package/dist/assets/element/index.umd.js +2 -2
  4. package/dist/assets/ui/index.umd.js +2 -2
  5. package/dist/assets/uni-h5/index.umd.js +3 -3
  6. package/dist/assets/uni-ui/index.umd.js +3 -3
  7. package/dist/assets/vant/index.umd.js +2 -2
  8. package/dist/deps/@vtj/charts/index.umd.js +2 -2
  9. package/dist/deps/@vtj/icons/index.umd.js +2 -2
  10. package/dist/deps/@vtj/ui/index.umd.js +3 -3
  11. package/dist/deps/@vtj/utils/index.umd.js +20 -20
  12. package/dist/deps/@vueuse/core/index.iife.min.js +1 -1
  13. package/dist/deps/uni-ui/index.umd.js +1 -1
  14. package/dist/deps/uni-ui/style.css +1 -1
  15. package/package.json +7 -7
  16. package/src/uni-h5/components/input.ts +2 -2
  17. package/src/uni-h5/components/scrollView.ts +3 -3
  18. package/src/uni-h5/components/video.ts +1 -1
  19. package/src/uni-ui/components/badge.ts +1 -5
  20. package/src/uni-ui/components/breadcrumb.ts +1 -20
  21. package/src/uni-ui/components/collapse.ts +22 -23
  22. package/src/uni-ui/components/grid.ts +0 -9
  23. package/src/uni-ui/components/group.ts +1 -10
  24. package/src/uni-ui/components/index.ts +4 -4
  25. package/src/uni-ui/components/popup.ts +10 -2
  26. package/src/uni-ui/components/swiperDot.ts +21 -7
  27. package/src/uni-ui/components/table.ts +9 -3
  28. package/src/uni-ui/components/transition.ts +10 -1
  29. package/src/uni-ui/index.ts +19 -44
  30. package/src/uni-ui/lib/uni-collapse/uni-collapse.vue +153 -0
  31. package/src/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +425 -0
  32. package/src/uni-ui/lib/uni-data-picker/keypress.js +45 -0
  33. package/src/uni-ui/lib/uni-data-picker/uni-data-picker.vue +604 -0
  34. package/src/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +622 -0
  35. package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.css +76 -0
  36. package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +335 -0
  37. package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +181 -170
  38. package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +977 -939
  39. package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +1024 -932
  40. package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +15 -17
  41. package/src/uni-ui/lib/uni-datetime-picker/util.js +419 -392
  42. package/src/uni-ui/lib/uni-fav/i18n/en.json +4 -0
  43. package/src/uni-ui/lib/uni-fav/i18n/index.js +8 -0
  44. package/src/uni-ui/lib/uni-fav/i18n/zh-Hans.json +4 -0
  45. package/src/uni-ui/lib/uni-fav/i18n/zh-Hant.json +4 -0
  46. package/src/uni-ui/lib/uni-fav/uni-fav.vue +170 -0
  47. package/src/uni-ui/lib/uni-file-picker/choose-and-upload-file.js +280 -0
  48. package/src/uni-ui/lib/uni-file-picker/uni-file-picker.vue +668 -0
  49. package/src/uni-ui/lib/uni-file-picker/upload-file.vue +325 -0
  50. package/src/uni-ui/lib/uni-file-picker/upload-image.vue +292 -0
  51. package/src/uni-ui/lib/uni-file-picker/utils.js +110 -0
  52. package/src/uni-ui/lib/uni-grid/uni-grid.vue +148 -0
  53. package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +152 -128
  54. package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +50 -50
  55. package/src/uni-ui/lib/uni-load-more/i18n/en.json +5 -0
  56. package/src/uni-ui/lib/uni-load-more/i18n/index.js +8 -0
  57. package/src/uni-ui/lib/uni-load-more/i18n/zh-Hans.json +5 -0
  58. package/src/uni-ui/lib/uni-load-more/i18n/zh-Hant.json +5 -0
  59. package/src/uni-ui/lib/uni-load-more/uni-load-more.vue +456 -0
  60. package/src/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +484 -0
  61. package/src/uni-ui/lib/uni-popup/uni-popup.vue +4 -4
  62. package/src/uni-ui/lib/uni-popup-message/uni-popup-message.vue +149 -0
  63. package/src/uni-ui/lib/uni-rate/uni-rate.vue +362 -343
  64. package/src/uni-ui/lib/uni-row/uni-row.vue +193 -0
  65. package/src/uni-ui/lib/uni-search-bar/i18n/en.json +4 -0
  66. package/src/uni-ui/lib/uni-search-bar/i18n/index.js +8 -0
  67. package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hans.json +4 -0
  68. package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hant.json +4 -0
  69. package/src/uni-ui/lib/uni-search-bar/uni-search-bar.vue +339 -0
  70. package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +294 -285
  71. package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +8 -9
  72. package/src/uni-ui/lib/uni-th/filter-dropdown.vue +551 -503
  73. package/src/uni-ui/lib/uni-tr/table-checkbox.vue +165 -163
  74. package/src/uni-ui/lib/uni-tr/uni-tr.vue +6 -6
  75. package/src/uni-ui/lib/uni-transition/createAnimation.js +131 -0
  76. package/src/uni-ui/lib/uni-transition/uni-transition.vue +310 -0
  77. package/src/version.ts +2 -2
@@ -1,361 +1,380 @@
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
+ <uni-icons
16
+ :color="color"
17
+ :size="size"
18
+ :type="isFill ? 'star-filled' : 'star'" />
19
+ <!-- #ifdef APP-NVUE -->
20
+ <!-- <view
21
+ :style="{
22
+ width: (star.activeWitch.replace('%', '') * size) / 100 + 'px'
23
+ }"
24
+ class="uni-rate__icon-on">
25
+ <uni-icons
26
+ style="text-align: left"
27
+ :color="disabled ? '#ccc' : activeColor"
28
+ :size="size"
29
+ type="star-filled" />
30
+ </view> -->
31
+ <!-- #endif -->
32
+ <!-- #ifndef APP-NVUE -->
33
+ <view :style="{ width: star.activeWitch }" class="uni-rate__icon-on">
34
+ <uni-icons
35
+ :color="disabled ? disabledColor : activeColor"
36
+ :size="size"
37
+ type="star-filled" />
38
+ </view>
39
+ <!-- #endif -->
40
+ </view>
41
+ </view>
42
+ </view>
23
43
  </template>
24
44
 
25
45
  <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
- */
46
+ // #ifdef APP-NVUE
47
+ // const dom = uni.requireNativePlugin('dom');
48
+ // #endif
49
+ /**
50
+ * Rate 评分
51
+ * @description 评分组件
52
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=33
53
+ * @property {Boolean} isFill = [true|false] 星星的类型,是否为实心类型, 默认为实心
54
+ * @property {String} color 未选中状态的星星颜色,默认为 "#ececec"
55
+ * @property {String} activeColor 选中状态的星星颜色,默认为 "#ffca3e"
56
+ * @property {String} disabledColor 禁用状态的星星颜色,默认为 "#c0c0c0"
57
+ * @property {Number} size 星星的大小
58
+ * @property {Number} value/v-model 当前评分
59
+ * @property {Number} max 最大评分评分数量,目前一分一颗星
60
+ * @property {Number} margin 星星的间距,单位 px
61
+ * @property {Boolean} disabled = [true|false] 是否为禁用状态,默认为 false
62
+ * @property {Boolean} readonly = [true|false] 是否为只读状态,默认为 false
63
+ * @property {Boolean} allowHalf = [true|false] 是否实现半星,默认为 false
64
+ * @property {Boolean} touchable = [true|false] 是否支持滑动手势,默认为 true
65
+ * @event {Function} change uniRate 的 value 改变时触发事件,e={value:Number}
66
+ */
47
67
 
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
- },
68
+ export default {
69
+ name: 'UniRate',
70
+ props: {
71
+ isFill: {
72
+ // 星星的类型,是否镂空
73
+ type: [Boolean, String],
74
+ default: true
75
+ },
76
+ color: {
77
+ // 星星未选中的颜色
78
+ type: String,
79
+ default: '#ececec'
80
+ },
81
+ activeColor: {
82
+ // 星星选中状态颜色
83
+ type: String,
84
+ default: '#ffca3e'
85
+ },
86
+ disabledColor: {
87
+ // 星星禁用状态颜色
88
+ type: String,
89
+ default: '#c0c0c0'
90
+ },
91
+ size: {
92
+ // 星星的大小
93
+ type: [Number, String],
94
+ default: 24
95
+ },
96
+ value: {
97
+ // 当前评分
98
+ type: [Number, String],
99
+ default: 0
100
+ },
101
+ modelValue: {
102
+ // 当前评分
103
+ type: [Number, String],
104
+ default: 0
105
+ },
106
+ max: {
107
+ // 最大评分
108
+ type: [Number, String],
109
+ default: 5
110
+ },
111
+ margin: {
112
+ // 星星的间距
113
+ type: [Number, String],
114
+ default: 0
115
+ },
116
+ disabled: {
117
+ // 是否可点击
118
+ type: [Boolean, String],
119
+ default: false
120
+ },
121
+ readonly: {
122
+ // 是否只读
123
+ type: [Boolean, String],
124
+ default: false
125
+ },
126
+ allowHalf: {
127
+ // 是否显示半星
128
+ type: [Boolean, String],
129
+ default: false
130
+ },
131
+ touchable: {
132
+ // 是否支持滑动手势
133
+ type: [Boolean, String],
134
+ default: true
135
+ }
136
+ },
137
+ data() {
138
+ return {
139
+ valueSync: '',
140
+ userMouseFristMove: true,
141
+ userRated: false,
142
+ userLastRate: 1
143
+ };
144
+ },
145
+ watch: {
146
+ // value(newVal) {
147
+ // this.valueSync = Number(newVal);
148
+ // },
149
+ modelValue(newVal) {
150
+ this.valueSync = Number(newVal);
151
+ }
152
+ },
153
+ computed: {
154
+ stars() {
155
+ const value = this.valueSync ? this.valueSync : 0;
156
+ const starList = [];
157
+ const floorValue = Math.floor(value);
158
+ const ceilValue = Math.ceil(value);
159
+ for (let i = 0; i < this.max; i++) {
160
+ if (floorValue > i) {
161
+ starList.push({
162
+ activeWitch: '100%'
163
+ });
164
+ } else if (ceilValue - 1 === i) {
165
+ starList.push({
166
+ activeWitch: (value - floorValue) * 100 + '%'
167
+ });
168
+ } else {
169
+ starList.push({
170
+ activeWitch: '0'
171
+ });
172
+ }
173
+ }
174
+ return starList;
175
+ },
156
176
 
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
- },
177
+ marginNumber() {
178
+ return Number(this.margin);
179
+ }
180
+ },
181
+ created() {
182
+ this.valueSync = Number(this.value || this.modelValue);
183
+ this._rateBoxLeft = 0;
184
+ this._oldValue = null;
185
+ },
186
+ mounted() {
187
+ setTimeout(() => {
188
+ this._getSize();
189
+ }, 100);
190
+ // #ifdef H5
191
+ this.PC = this.IsPC();
192
+ // #endif
193
+ },
194
+ methods: {
195
+ touchstart(e) {
196
+ // #ifdef H5
197
+ if (this.IsPC()) return;
198
+ // #endif
199
+ if (this.readonly || this.disabled) return;
200
+ const { clientX, screenX } = e.changedTouches[0];
201
+ // TODO 做一下兼容,只有 Nvue 下才有 screenX,其他平台式 clientX
202
+ this._getRateCount(clientX || screenX);
203
+ },
204
+ touchmove(e) {
205
+ // #ifdef H5
206
+ if (this.IsPC()) return;
207
+ // #endif
208
+ if (this.readonly || this.disabled || !this.touchable) return;
209
+ const { clientX, screenX } = e.changedTouches[0];
210
+ this._getRateCount(clientX || screenX);
211
+ },
198
212
 
199
- /**
200
- * 兼容 PC @tian
201
- */
213
+ /**
214
+ * 兼容 PC @tian
215
+ */
202
216
 
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
217
+ mousedown(e) {
218
+ // #ifdef H5
219
+ if (!this.IsPC()) return;
220
+ if (this.readonly || this.disabled) return;
221
+ const { clientX } = e;
222
+ this.userLastRate = this.valueSync;
223
+ this._getRateCount(clientX);
224
+ this.userRated = true;
225
+ // #endif
226
+ },
227
+ mousemove(e) {
228
+ // #ifdef H5
229
+ if (!this.IsPC()) return;
230
+ if (this.userRated) return;
231
+ if (this.userMouseFristMove) {
232
+ // console.log('---mousemove----', this.valueSync);
233
+ this.userLastRate = this.valueSync;
234
+ this.userMouseFristMove = false;
235
+ }
236
+ if (this.readonly || this.disabled || !this.touchable) return;
237
+ const { clientX } = e;
238
+ this._getRateCount(clientX);
239
+ // #endif
240
+ },
241
+ mouseleave(e) {
242
+ // #ifdef H5
243
+ if (!this.IsPC()) return;
244
+ if (this.readonly || this.disabled || !this.touchable) return;
245
+ if (this.userRated) {
246
+ this.userRated = false;
247
+ return;
248
+ }
249
+ this.valueSync = this.userLastRate;
250
+ // #endif
251
+ },
252
+ // #ifdef H5
253
+ IsPC() {
254
+ var userAgentInfo = navigator.userAgent;
255
+ var Agents = [
256
+ 'Android',
257
+ 'iPhone',
258
+ 'SymbianOS',
259
+ 'Windows Phone',
260
+ 'iPad',
261
+ 'iPod'
262
+ ];
263
+ var flag = true;
264
+ for (let v = 0; v < Agents.length - 1; v++) {
265
+ if (userAgentInfo.indexOf(Agents[v]) > 0) {
266
+ flag = false;
267
+ break;
268
+ }
269
+ }
270
+ return flag;
271
+ },
272
+ // #endif
256
273
 
257
- /**
258
- * 获取星星个数
259
- */
260
- _getRateCount(clientX) {
261
- this._getSize()
262
- const size = Number(this.size)
263
- if (isNaN(size)) {
264
- return new Error('size 属性只能设置为数字')
265
- }
266
- const rateMoveRange = clientX - this._rateBoxLeft
267
- let index = parseInt(rateMoveRange / (size + this.marginNumber))
268
- index = index < 0 ? 0 : index;
269
- index = index > this.max ? this.max : index;
270
- const range = parseInt(rateMoveRange - (size + this.marginNumber) * index);
271
- let value = 0;
272
- if (this._oldValue === index && !this.PC) return;
273
- this._oldValue = index;
274
- if (this.allowHalf) {
275
- if (range > (size / 2)) {
276
- value = index + 1
277
- } else {
278
- value = index + 0.5
279
- }
280
- } else {
281
- value = index + 1
282
- }
274
+ /**
275
+ * 获取星星个数
276
+ */
277
+ _getRateCount(clientX) {
278
+ this._getSize();
279
+ const size = Number(this.size);
280
+ if (isNaN(size)) {
281
+ return new Error('size 属性只能设置为数字');
282
+ }
283
+ const rateMoveRange = clientX - this._rateBoxLeft;
284
+ let index = parseInt(rateMoveRange / (size + this.marginNumber));
285
+ index = index < 0 ? 0 : index;
286
+ index = index > this.max ? this.max : index;
287
+ const range = parseInt(
288
+ rateMoveRange - (size + this.marginNumber) * index
289
+ );
290
+ let value = 0;
291
+ if (this._oldValue === index && !this.PC) return;
292
+ this._oldValue = index;
293
+ if (this.allowHalf) {
294
+ if (range > size / 2) {
295
+ value = index + 1;
296
+ } else {
297
+ value = index + 0.5;
298
+ }
299
+ } else {
300
+ value = index + 1;
301
+ }
283
302
 
284
- value = Math.max(0.5, Math.min(value, this.max))
285
- this.valueSync = value
286
- this._onChange()
287
- },
303
+ value = Math.max(0.5, Math.min(value, this.max));
304
+ this.valueSync = value;
305
+ this._onChange();
306
+ },
288
307
 
289
- /**
290
- * 触发动态修改
291
- */
292
- _onChange() {
293
-
294
- this.$emit("input", this.valueSync);
295
- this.$emit("update:modelValue", this.valueSync);
296
- this.$emit("change", {
297
- value: this.valueSync
298
- });
299
- },
300
- /**
301
- * 获取星星距离屏幕左侧距离
302
- */
303
- _getSize() {
304
- // #ifndef APP-NVUE
305
- uni.createSelectorQuery()
306
- .in(this)
307
- .select('.uni-rate')
308
- .boundingClientRect()
309
- .exec(ret => {
310
- if (ret) {
311
- this._rateBoxLeft = ret[0].left
312
- }
313
- })
314
- // #endif
315
- // #ifdef APP-NVUE
316
- dom.getComponentRect(this.$refs['uni-rate'], (ret) => {
317
- const size = ret.size
318
- if (size) {
319
- this._rateBoxLeft = size.left
320
- }
321
- })
322
- // #endif
323
- }
324
- }
325
- };
308
+ /**
309
+ * 触发动态修改
310
+ */
311
+ _onChange() {
312
+ this.$emit('input', this.valueSync);
313
+ this.$emit('update:modelValue', this.valueSync);
314
+ this.$emit('change', {
315
+ value: this.valueSync
316
+ });
317
+ },
318
+ /**
319
+ * 获取星星距离屏幕左侧距离
320
+ */
321
+ _getSize() {
322
+ // #ifndef APP-NVUE
323
+ uni
324
+ .createSelectorQuery()
325
+ .in(this)
326
+ .select('.uni-rate')
327
+ .boundingClientRect()
328
+ .exec((ret) => {
329
+ if (ret) {
330
+ this._rateBoxLeft = ret[0].left;
331
+ }
332
+ });
333
+ // #endif
334
+ // #ifdef APP-NVUE
335
+ // dom.getComponentRect(this.$refs['uni-rate'], (ret) => {
336
+ // const size = ret.size;
337
+ // if (size) {
338
+ // this._rateBoxLeft = size.left;
339
+ // }
340
+ // });
341
+ // #endif
342
+ }
343
+ }
344
+ };
326
345
  </script>
327
346
 
328
347
  <style lang="scss">
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
- }
348
+ .uni-rate {
349
+ /* #ifndef APP-NVUE */
350
+ display: flex;
351
+ /* #endif */
352
+ line-height: 1;
353
+ font-size: 0;
354
+ flex-direction: row;
355
+ /* #ifdef H5 */
356
+ cursor: pointer;
357
+ /* #endif */
358
+ }
340
359
 
341
- .uni-rate__icon {
342
- position: relative;
343
- line-height: 1;
344
- font-size: 0;
345
- }
360
+ .uni-rate__icon {
361
+ position: relative;
362
+ line-height: 1;
363
+ font-size: 0;
364
+ }
346
365
 
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
- }
366
+ .uni-rate__icon-on {
367
+ overflow: hidden;
368
+ position: absolute;
369
+ top: 0;
370
+ left: 0;
371
+ line-height: 1;
372
+ text-align: left;
373
+ }
355
374
 
356
- .uni-cursor-not-allowed {
357
- /* #ifdef H5 */
358
- cursor: not-allowed !important;
359
- /* #endif */
360
- }
375
+ .uni-cursor-not-allowed {
376
+ /* #ifdef H5 */
377
+ cursor: not-allowed !important;
378
+ /* #endif */
379
+ }
361
380
  </style>