uview-plus 3.7.32 → 3.8.18
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/README.md +0 -1
- package/changelog.md +1993 -1808
- package/components/u-action-sheet/u-action-sheet.vue +54 -16
- package/components/u-agreement/u-agreement.vue +2 -1
- package/components/u-alert/u-alert.vue +8 -10
- package/components/u-button/u-button.vue +35 -5
- package/components/u-calendar/calendar.js +1 -0
- package/components/u-calendar/header.vue +98 -9
- package/components/u-calendar/month.vue +10 -7
- package/components/u-calendar/props.js +5 -0
- package/components/u-calendar/u-calendar.vue +109 -2
- package/components/u-car-keyboard/u-car-keyboard.vue +7 -7
- package/components/u-card/u-card.vue +6 -6
- package/components/u-cascader/u-cascader.vue +32 -12
- package/components/u-cate-tab/u-cate-tab.vue +49 -48
- package/components/u-cell/u-cell.vue +24 -4
- package/components/u-cell-group/u-cell-group.vue +10 -3
- package/components/u-checkbox/u-checkbox.vue +6 -6
- package/components/u-choose/u-choose.vue +9 -4
- package/components/u-city-locate/u-city-locate.vue +28 -22
- package/components/u-color-picker/u-color-picker.vue +15 -15
- package/components/u-datetime-picker/u-datetime-picker.vue +79 -10
- package/components/u-dragsort/u-dragsort.vue +3 -0
- package/components/u-dropdown/u-dropdown.vue +15 -2
- package/components/u-dropdown-item/u-dropdown-item.vue +3 -3
- package/components/u-form-item/u-form-item.vue +6 -1
- package/components/u-gap/u-gap.vue +5 -1
- package/components/u-goods-sku/u-goods-sku.vue +16 -15
- package/components/u-index-anchor/u-index-anchor.vue +13 -2
- package/components/u-index-list/u-index-list.vue +18 -5
- package/components/u-input/input.js +3 -3
- package/components/u-input/u-input.vue +27 -5
- package/components/u-keyboard/u-keyboard.vue +11 -6
- package/components/u-loading-page/loadingPage.js +1 -1
- package/components/u-loading-page/u-loading-page.vue +18 -12
- package/components/u-navbar/navbar.js +2 -3
- package/components/u-navbar/theme-vars.scss +21 -0
- package/components/u-navbar/u-navbar.vue +30 -6
- package/components/u-notice-bar/theme-vars.scss +25 -0
- package/components/u-notice-bar/u-notice-bar.vue +24 -5
- package/components/u-number-box/numberBox.js +4 -4
- package/components/u-number-box/u-number-box.vue +27 -13
- package/components/u-number-keyboard/u-number-keyboard.vue +6 -6
- package/components/u-picker/picker.js +43 -43
- package/components/u-picker/u-picker.vue +14 -2
- package/components/u-popup/popup.js +1 -1
- package/components/u-popup/u-popup.vue +14 -6
- package/components/u-pull-refresh/u-pull-refresh.vue +6 -6
- package/components/u-radio/u-radio.vue +6 -6
- package/components/u-rate/rate.js +2 -2
- package/components/u-rate/u-rate.vue +98 -21
- package/components/u-search/search.js +3 -3
- package/components/u-search/u-search.vue +29 -6
- package/components/u-select/u-select.vue +141 -73
- package/components/u-signature/u-signature.vue +35 -16
- package/components/u-skeleton/u-skeleton.vue +7 -2
- package/components/u-slider/u-slider.vue +30 -31
- package/components/u-steps-item/u-steps-item.vue +20 -17
- package/components/u-subsection/theme-vars.scss +41 -0
- package/components/u-subsection/u-subsection.vue +69 -16
- package/components/u-swipe-action-item/u-swipe-action-item.vue +11 -5
- package/components/u-switch/theme-vars.scss +41 -0
- package/components/u-switch/u-switch.vue +44 -15
- package/components/u-tabbar/u-tabbar.vue +5 -5
- package/components/u-tabbar-item/u-tabbar-item.vue +16 -5
- package/components/u-table/u-table.vue +18 -3
- package/components/u-table2/tableRow.vue +43 -41
- package/components/u-table2/u-table2.vue +56 -50
- package/components/u-tabs/u-tabs.vue +14 -1
- package/components/u-tag/theme-vars.scss +21 -0
- package/components/u-tag/u-tag.vue +17 -7
- package/components/u-td/u-td.vue +5 -3
- package/components/u-text/text.js +1 -1
- package/components/u-text/u-text.vue +15 -13
- package/components/u-textarea/props.js +2 -2
- package/components/u-textarea/textarea.js +1 -1
- package/components/u-textarea/u-textarea.vue +115 -61
- package/components/u-th/u-th.vue +5 -4
- package/components/u-title/u-title.vue +1 -0
- package/components/u-toast/u-toast.vue +8 -8
- package/components/u-tree/u-tree.vue +491 -51
- package/components/u-upload/u-upload.vue +34 -6
- package/index.js +178 -27
- package/index.scss +5 -1
- package/libs/config/color.js +1 -2
- package/libs/config/props.js +1 -1
- package/libs/css/theme-vars-core.scss +197 -0
- package/libs/css/theme-vars.scss +1 -0
- package/libs/function/index.js +8 -8
- package/libs/mixin/mixin.js +117 -5
- package/libs/root/index.js +175 -0
- package/libs/root/nvue-root.vue +72 -0
- package/libs/root/page.js +269 -0
- package/libs/root/root-toast-host.vue +31 -0
- package/libs/root/root.js +40 -0
- package/libs/root/runtime.js +11 -0
- package/libs/root/utils.js +115 -0
- package/libs/theme/runtime.js +391 -0
- package/libs/theme/theme.js +684 -0
- package/libs/util/gcanvas/bridge/bridge-weex.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStylePattern.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/ActiveInfo.js +0 -0
- package/libs/util/gcanvas/context-webgl/Buffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/Framebuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLenum.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLmethod.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLtype.js +0 -0
- package/libs/util/gcanvas/context-webgl/Program.js +0 -0
- package/libs/util/gcanvas/context-webgl/Renderbuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/Shader.js +0 -0
- package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +0 -0
- package/libs/util/gcanvas/context-webgl/Texture.js +0 -0
- package/libs/util/gcanvas/context-webgl/UniformLocation.js +0 -0
- package/libs/util/gcanvas/context-webgl/classUtils.js +0 -0
- package/libs/util/gcanvas/env/canvas.js +0 -0
- package/libs/util/gcanvas/env/image.js +0 -0
- package/libs/util/gcanvas/env/tool.js +0 -0
- package/libs/util/gcanvas/index.js +0 -0
- package/package.json +1 -1
- package/theme.scss +113 -32
- package/types/comps/stepsItem.d.ts +8 -4
- package/types/index.d.ts +41 -2
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
@touchcancel="onTouchEnd"
|
|
46
46
|
>
|
|
47
47
|
<!-- iOS风格的横条指示器 -->
|
|
48
|
-
<view class="u-popup__content__indicator"></view>
|
|
48
|
+
<view class="u-popup__content__indicator" :style="indicatorStyle"></view>
|
|
49
49
|
</view>
|
|
50
50
|
<slot></slot>
|
|
51
51
|
<view
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
>
|
|
59
59
|
<up-icon
|
|
60
60
|
name="close"
|
|
61
|
-
color="
|
|
61
|
+
:color="closeIconColor"
|
|
62
62
|
size="18"
|
|
63
63
|
bold
|
|
64
64
|
></up-icon>
|
|
@@ -195,8 +195,8 @@
|
|
|
195
195
|
if (this.mode !== 'center') {
|
|
196
196
|
style.flex = 1
|
|
197
197
|
}
|
|
198
|
-
//
|
|
199
|
-
style.backgroundColor = this.bgColor
|
|
198
|
+
// 背景色,留空时跟随主题卡片背景
|
|
199
|
+
style.backgroundColor = this.bgColor || this.upThemeVar('--up-card-bg-color', this.upThemeIsDark ? '#1c1c1e' : '#ffffff')
|
|
200
200
|
if(this.round) {
|
|
201
201
|
const value = addUnit(this.round)
|
|
202
202
|
if(this.mode === 'top') {
|
|
@@ -212,6 +212,14 @@
|
|
|
212
212
|
|
|
213
213
|
return deepMerge(style, addStyle(this.customStyle))
|
|
214
214
|
},
|
|
215
|
+
closeIconColor() {
|
|
216
|
+
return this.upThemeVar('--up-content-color', '#606266')
|
|
217
|
+
},
|
|
218
|
+
indicatorStyle() {
|
|
219
|
+
return {
|
|
220
|
+
backgroundColor: this.upThemeVar('--up-light-color', '#c0c4cc')
|
|
221
|
+
}
|
|
222
|
+
},
|
|
215
223
|
position() {
|
|
216
224
|
if (this.mode === 'center') {
|
|
217
225
|
return this.zoom ? 'fade-zoom' : 'fade'
|
|
@@ -413,7 +421,7 @@
|
|
|
413
421
|
width: 100px;
|
|
414
422
|
height: 5px;
|
|
415
423
|
border-radius: 100px;
|
|
416
|
-
background-color: #c0c4cc;
|
|
424
|
+
background-color: var(--up-light-color, #c0c4cc);
|
|
417
425
|
}
|
|
418
426
|
|
|
419
427
|
&__close {
|
|
@@ -445,4 +453,4 @@
|
|
|
445
453
|
}
|
|
446
454
|
}
|
|
447
455
|
}
|
|
448
|
-
</style>
|
|
456
|
+
</style>
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<!-- 默认下拉状态 -->
|
|
23
23
|
<view class="refresh-content">
|
|
24
24
|
<view class="refresh-indicator">
|
|
25
|
-
<up-icon name="arrow-downward" size="26px"></up-icon>
|
|
25
|
+
<up-icon name="arrow-downward" size="26px" color="var(--up-content-color, #606266)"></up-icon>
|
|
26
26
|
</view>
|
|
27
27
|
<text class="refresh-text">{{ t("up.pullRefresh.pull") }}</text>
|
|
28
28
|
</view>
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<!-- 默认释放状态 -->
|
|
38
38
|
<view class="refresh-content">
|
|
39
39
|
<view class="refresh-indicator">
|
|
40
|
-
<up-icon name="arrow-upward" size="26px"></up-icon>
|
|
40
|
+
<up-icon name="arrow-upward" size="26px" color="var(--up-content-color, #606266)"></up-icon>
|
|
41
41
|
</view>
|
|
42
42
|
<text class="refresh-text">{{ t("up.pullRefresh.release") }}</text>
|
|
43
43
|
</view>
|
|
@@ -316,8 +316,8 @@ export default {
|
|
|
316
316
|
.spinner {
|
|
317
317
|
width: 16px;
|
|
318
318
|
height: 16px;
|
|
319
|
-
border: 2px solid #f3f3f3;
|
|
320
|
-
border-top: 2px solid #666;
|
|
319
|
+
border: 2px solid var(--up-border-color, #f3f3f3);
|
|
320
|
+
border-top: 2px solid var(--up-content-color, #666);
|
|
321
321
|
border-radius: 50%;
|
|
322
322
|
animation: spin 1s linear infinite;
|
|
323
323
|
}
|
|
@@ -329,6 +329,6 @@ export default {
|
|
|
329
329
|
|
|
330
330
|
.refresh-text {
|
|
331
331
|
font-size: 14px;
|
|
332
|
-
color: #
|
|
332
|
+
color: var(--up-main-color, #303133);
|
|
333
333
|
}
|
|
334
|
-
</style>
|
|
334
|
+
</style>
|
|
@@ -107,16 +107,16 @@
|
|
|
107
107
|
},
|
|
108
108
|
// 组件选中激活时的颜色
|
|
109
109
|
elActiveColor() {
|
|
110
|
-
return this.activeColor ? this.activeColor : (this.parentData.activeColor ? this.parentData.activeColor : '#2979ff');
|
|
110
|
+
return this.activeColor ? this.activeColor : (this.parentData.activeColor ? this.parentData.activeColor : this.upThemeVar('--up-primary', '#2979ff'));
|
|
111
111
|
},
|
|
112
112
|
// 组件选未中激活时的颜色
|
|
113
113
|
elInactiveColor() {
|
|
114
114
|
return this.inactiveColor ? this.inactiveColor : (this.parentData.inactiveColor ? this.parentData.inactiveColor :
|
|
115
|
-
'#c8c9cc');
|
|
115
|
+
this.upThemeVar('--up-border-color', '#c8c9cc'));
|
|
116
116
|
},
|
|
117
117
|
// label的颜色
|
|
118
118
|
elLabelColor() {
|
|
119
|
-
return this.labelColor ? this.labelColor : (this.parentData.labelColor ? this.parentData.labelColor : '#606266')
|
|
119
|
+
return this.labelColor ? this.labelColor : (this.parentData.labelColor ? this.parentData.labelColor : this.upThemeVar('--up-content-color', '#606266'))
|
|
120
120
|
},
|
|
121
121
|
// 组件的形状
|
|
122
122
|
elShape() {
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
},
|
|
130
130
|
elIconColor() {
|
|
131
131
|
const iconColor = this.iconColor ? this.iconColor : (this.parentData.iconColor ? this.parentData.iconColor :
|
|
132
|
-
'#ffffff');
|
|
132
|
+
this.upThemeVar('--up-card-bg-color', '#ffffff'));
|
|
133
133
|
// 图标的颜色
|
|
134
134
|
if (this.elDisabled) {
|
|
135
135
|
// disabled状态下,已勾选的radio图标改为elInactiveColor
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
iconWrapStyle() {
|
|
158
158
|
// radio的整体样式
|
|
159
159
|
const style = {}
|
|
160
|
-
style.backgroundColor = this.checked && !this.elDisabled ? this.elActiveColor : '#ffffff'
|
|
160
|
+
style.backgroundColor = this.checked && !this.elDisabled ? this.elActiveColor : this.upThemeVar('--up-card-bg-color', '#ffffff')
|
|
161
161
|
style.borderColor = this.checked && !this.elDisabled ? this.elActiveColor : this.elInactiveColor
|
|
162
162
|
style.width = addUnit(this.elSize)
|
|
163
163
|
style.height = addUnit(this.elSize)
|
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
$u-radio-checked-color:#fff !default;
|
|
257
257
|
$u-radio-checked-background-color:red !default;
|
|
258
258
|
$u-radio-checked-border-color: #2979ff !default;
|
|
259
|
-
$u-radio-disabled-background-color
|
|
259
|
+
$u-radio-disabled-background-color:var(--up-bg-color, #ebedf0) !default;
|
|
260
260
|
$u-radio-disabled--checked-color:#c8c9cc !default;
|
|
261
261
|
$u-radio-label-margin-left: 5px !default;
|
|
262
262
|
$u-radio-label-margin-right:12px !default;
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"
|
|
30
30
|
:color="
|
|
31
31
|
disabled
|
|
32
|
-
?
|
|
32
|
+
? disabledColorInner
|
|
33
33
|
: Math.floor(activeIndex) > index
|
|
34
|
-
?
|
|
35
|
-
:
|
|
34
|
+
? activeColorInner
|
|
35
|
+
: inactiveColorInner
|
|
36
36
|
"
|
|
37
37
|
:custom-style="{
|
|
38
38
|
padding: `0 ${addUnit(gutter / 2)}`,
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"
|
|
58
58
|
:color="
|
|
59
59
|
disabled
|
|
60
|
-
?
|
|
60
|
+
? disabledColorInner
|
|
61
61
|
: Math.ceil(activeIndex) > index
|
|
62
|
-
?
|
|
63
|
-
:
|
|
62
|
+
? activeColorInner
|
|
63
|
+
: inactiveColorInner
|
|
64
64
|
"
|
|
65
65
|
:custom-style="{
|
|
66
66
|
padding: `0 ${addUnit(gutter / 2)}`
|
|
@@ -106,16 +106,20 @@
|
|
|
106
106
|
name: "u-rate",
|
|
107
107
|
mixins: [mpMixin, mixin, props],
|
|
108
108
|
data() {
|
|
109
|
+
const modelVal = Number(this.modelValue)
|
|
110
|
+
const valueVal = Number(this.value)
|
|
111
|
+
const minCount = Number(this.minCount)
|
|
112
|
+
const defaultActive = Number.isFinite(minCount) ? minCount : 0
|
|
109
113
|
return {
|
|
110
114
|
// 生成一个唯一id,否则一个页面多个评分组件,会造成冲突
|
|
111
115
|
elId: guid(),
|
|
112
116
|
elClass: guid(),
|
|
113
117
|
rateBoxLeft: 0, // 评分盒子左边到屏幕左边的距离,用于滑动选择时计算距离
|
|
114
118
|
// #ifdef VUE3
|
|
115
|
-
activeIndex:
|
|
119
|
+
activeIndex: Number.isFinite(modelVal) ? modelVal : defaultActive,
|
|
116
120
|
// #endif
|
|
117
121
|
// #ifdef VUE2
|
|
118
|
-
activeIndex:
|
|
122
|
+
activeIndex: Number.isFinite(valueVal) ? valueVal : defaultActive,
|
|
119
123
|
// #endif
|
|
120
124
|
rateWidth: 0, // 每个星星的宽度
|
|
121
125
|
// 标识是否正在滑动,由于iOS事件上touch比click先触发,导致快速滑动结束后,接着触发click,导致事件混乱而出错
|
|
@@ -125,22 +129,67 @@
|
|
|
125
129
|
watch: {
|
|
126
130
|
// #ifdef VUE3
|
|
127
131
|
modelValue(val) {
|
|
128
|
-
this.activeIndex = val;
|
|
132
|
+
this.activeIndex = this.normalizeActiveIndex(val);
|
|
129
133
|
},
|
|
130
134
|
// #endif
|
|
131
135
|
// #ifdef VUE2
|
|
132
136
|
value(val) {
|
|
133
|
-
this.activeIndex = val;
|
|
137
|
+
this.activeIndex = this.normalizeActiveIndex(val);
|
|
134
138
|
},
|
|
135
139
|
// #endif
|
|
136
140
|
activeIndex: 'emitEvent'
|
|
137
141
|
},
|
|
142
|
+
computed: {
|
|
143
|
+
disabledColorInner() {
|
|
144
|
+
return this.upThemeVar('--up-disabled-color', '#c8c9cc')
|
|
145
|
+
},
|
|
146
|
+
activeColorInner() {
|
|
147
|
+
return this.activeColor || this.upThemeVar('--up-primary', '#FA3534')
|
|
148
|
+
},
|
|
149
|
+
inactiveColorInner() {
|
|
150
|
+
return this.inactiveColor || this.upThemeVar('--up-tips-color', '#b2b2b2')
|
|
151
|
+
}
|
|
152
|
+
},
|
|
138
153
|
// #ifdef VUE3
|
|
139
154
|
emits: ['update:modelValue', 'change'],
|
|
140
155
|
// #endif
|
|
141
156
|
methods: {
|
|
142
157
|
addStyle,
|
|
143
158
|
addUnit,
|
|
159
|
+
toNumber(value, fallback = 0) {
|
|
160
|
+
const num = Number(value)
|
|
161
|
+
return Number.isFinite(num) ? num : fallback
|
|
162
|
+
},
|
|
163
|
+
getMinCountValue() {
|
|
164
|
+
return this.toNumber(this.minCount, 0)
|
|
165
|
+
},
|
|
166
|
+
getCountValue() {
|
|
167
|
+
return this.toNumber(this.count, 0)
|
|
168
|
+
},
|
|
169
|
+
normalizeActiveIndex(value) {
|
|
170
|
+
let normalized = this.toNumber(value, this.getMinCountValue())
|
|
171
|
+
const minCount = this.getMinCountValue()
|
|
172
|
+
const count = this.getCountValue()
|
|
173
|
+
if (normalized < minCount) normalized = minCount
|
|
174
|
+
if (count > 0 && normalized > count) normalized = count
|
|
175
|
+
return normalized
|
|
176
|
+
},
|
|
177
|
+
getFallbackRateWidth() {
|
|
178
|
+
const size = parseFloat(this.size) || 18
|
|
179
|
+
const gutter = parseFloat(this.gutter) || 0
|
|
180
|
+
const width = size + gutter
|
|
181
|
+
return width > 0 ? width : 18
|
|
182
|
+
},
|
|
183
|
+
ensureRateMetrics() {
|
|
184
|
+
if (!Number.isFinite(this.rateBoxLeft)) {
|
|
185
|
+
this.rateBoxLeft = 0
|
|
186
|
+
}
|
|
187
|
+
if (!Number.isFinite(this.rateWidth) || this.rateWidth <= 0) {
|
|
188
|
+
this.rateWidth = this.getFallbackRateWidth()
|
|
189
|
+
this.getRateIconWrapRect()
|
|
190
|
+
}
|
|
191
|
+
return Number.isFinite(this.rateWidth) && this.rateWidth > 0
|
|
192
|
+
},
|
|
144
193
|
init() {
|
|
145
194
|
sleep().then(() => {
|
|
146
195
|
this.getRateItemRect();
|
|
@@ -153,12 +202,17 @@
|
|
|
153
202
|
// uView封装的获取节点的方法,详见文档
|
|
154
203
|
// #ifndef APP-NVUE
|
|
155
204
|
this.$uGetRect("#" + this.elId).then((res) => {
|
|
156
|
-
|
|
205
|
+
if (res && Number.isFinite(res.left)) {
|
|
206
|
+
this.rateBoxLeft = res.left;
|
|
207
|
+
}
|
|
157
208
|
});
|
|
158
209
|
// #endif
|
|
159
210
|
// #ifdef APP-NVUE
|
|
160
211
|
dom.getComponentRect(this.$refs["u-rate"], (res) => {
|
|
161
|
-
|
|
212
|
+
const left = res && res.size ? res.size.left : NaN
|
|
213
|
+
if (Number.isFinite(left)) {
|
|
214
|
+
this.rateBoxLeft = left;
|
|
215
|
+
}
|
|
162
216
|
});
|
|
163
217
|
// #endif
|
|
164
218
|
},
|
|
@@ -167,14 +221,19 @@
|
|
|
167
221
|
// uView封装的获取节点的方法,详见文档
|
|
168
222
|
// #ifndef APP-NVUE
|
|
169
223
|
this.$uGetRect("." + this.elClass).then((res) => {
|
|
170
|
-
|
|
224
|
+
if (res && Number.isFinite(res.width) && res.width > 0) {
|
|
225
|
+
this.rateWidth = res.width;
|
|
226
|
+
}
|
|
171
227
|
});
|
|
172
228
|
// #endif
|
|
173
229
|
// #ifdef APP-NVUE
|
|
174
230
|
dom.getComponentRect(
|
|
175
231
|
this.$refs["u-rate__content__item__icon-wrap"][0],
|
|
176
232
|
(res) => {
|
|
177
|
-
|
|
233
|
+
const width = res && res.size ? res.size.width : NaN
|
|
234
|
+
if (Number.isFinite(width) && width > 0) {
|
|
235
|
+
this.rateWidth = width;
|
|
236
|
+
}
|
|
178
237
|
}
|
|
179
238
|
);
|
|
180
239
|
// #endif
|
|
@@ -186,6 +245,7 @@
|
|
|
186
245
|
return;
|
|
187
246
|
}
|
|
188
247
|
this.preventEvent(e);
|
|
248
|
+
this.ensureRateMetrics();
|
|
189
249
|
const x = e.changedTouches[0].pageX;
|
|
190
250
|
this.getActiveIndex(x);
|
|
191
251
|
},
|
|
@@ -196,6 +256,7 @@
|
|
|
196
256
|
return;
|
|
197
257
|
}
|
|
198
258
|
this.preventEvent(e);
|
|
259
|
+
this.ensureRateMetrics();
|
|
199
260
|
const x = e.changedTouches[0].pageX;
|
|
200
261
|
this.getActiveIndex(x);
|
|
201
262
|
},
|
|
@@ -206,6 +267,7 @@
|
|
|
206
267
|
return;
|
|
207
268
|
}
|
|
208
269
|
this.preventEvent(e);
|
|
270
|
+
this.ensureRateMetrics();
|
|
209
271
|
let x = 0;
|
|
210
272
|
// 点击时,在nvue上,无法获得点击的坐标,所以无法实现点击半星选择
|
|
211
273
|
// #ifndef APP-NVUE
|
|
@@ -219,14 +281,19 @@
|
|
|
219
281
|
},
|
|
220
282
|
// 发出事件
|
|
221
283
|
emitEvent() {
|
|
284
|
+
const normalizedValue = this.normalizeActiveIndex(this.activeIndex)
|
|
285
|
+
if (!Number.isFinite(this.activeIndex) || normalizedValue !== this.activeIndex) {
|
|
286
|
+
this.activeIndex = normalizedValue
|
|
287
|
+
return
|
|
288
|
+
}
|
|
222
289
|
// 发出change事件
|
|
223
|
-
this.$emit("change",
|
|
290
|
+
this.$emit("change", normalizedValue);
|
|
224
291
|
// 同时修改双向绑定的值
|
|
225
292
|
// #ifdef VUE3
|
|
226
|
-
this.$emit("update:modelValue",
|
|
293
|
+
this.$emit("update:modelValue", normalizedValue);
|
|
227
294
|
// #endif
|
|
228
295
|
// #ifdef VUE2
|
|
229
|
-
this.$emit("input",
|
|
296
|
+
this.$emit("input", normalizedValue);
|
|
230
297
|
// #endif
|
|
231
298
|
},
|
|
232
299
|
// 获取当前激活的评分图标
|
|
@@ -234,8 +301,18 @@
|
|
|
234
301
|
if (this.disabled || this.readonly) {
|
|
235
302
|
return;
|
|
236
303
|
}
|
|
304
|
+
if (!this.ensureRateMetrics()) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const count = this.getCountValue()
|
|
308
|
+
if (count <= 0) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (!Number.isFinite(x)) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
237
314
|
// 判断当前操作的点的x坐标值,是否在允许的边界范围内
|
|
238
|
-
const allRateWidth = this.rateWidth *
|
|
315
|
+
const allRateWidth = this.rateWidth * count + this.rateBoxLeft;
|
|
239
316
|
// 如果小于第一个图标的左边界,设置为最小值,如果大于所有图标的宽度,则设置为最大值
|
|
240
317
|
x = range(this.rateBoxLeft, allRateWidth, x) - this.rateBoxLeft
|
|
241
318
|
// 滑动点相对于评分盒子左边的距离
|
|
@@ -264,10 +341,10 @@
|
|
|
264
341
|
}
|
|
265
342
|
|
|
266
343
|
}
|
|
267
|
-
this.activeIndex = Math.min(index,
|
|
344
|
+
this.activeIndex = this.normalizeActiveIndex(Math.min(index, count));
|
|
268
345
|
// 对最少颗星星的限制
|
|
269
|
-
if (this.activeIndex < this.
|
|
270
|
-
this.activeIndex = this.
|
|
346
|
+
if (this.activeIndex < this.getMinCountValue()) {
|
|
347
|
+
this.activeIndex = this.getMinCountValue();
|
|
271
348
|
}
|
|
272
349
|
|
|
273
350
|
// 设置延时为了让click事件在touchmove之前触发
|
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
// search
|
|
13
13
|
search: {
|
|
14
14
|
shape: 'round',
|
|
15
|
-
bgColor: '
|
|
15
|
+
bgColor: '',
|
|
16
16
|
placeholder: t("up.search.placeholder"),
|
|
17
17
|
clearabled: true,
|
|
18
18
|
focus: false,
|
|
@@ -25,8 +25,8 @@ export default {
|
|
|
25
25
|
borderColor: 'transparent',
|
|
26
26
|
searchIconColor: '#909399',
|
|
27
27
|
searchIconSize: 22,
|
|
28
|
-
color: '
|
|
29
|
-
placeholderColor: '
|
|
28
|
+
color: '',
|
|
29
|
+
placeholderColor: '',
|
|
30
30
|
searchIcon: 'search',
|
|
31
31
|
iconPosition: 'left',
|
|
32
32
|
margin: '0',
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
<view
|
|
11
11
|
class="u-search__content"
|
|
12
12
|
:style="{
|
|
13
|
-
backgroundColor:
|
|
13
|
+
backgroundColor: resolvedBgColor,
|
|
14
14
|
borderRadius: shape == 'round' ? '100px' : '4px',
|
|
15
|
-
borderColor:
|
|
15
|
+
borderColor: resolvedBorderColor,
|
|
16
16
|
}"
|
|
17
17
|
>
|
|
18
18
|
<template v-if="$slots.label || label !== null">
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
@tap="clickIcon"
|
|
26
26
|
:size="searchIconSize"
|
|
27
27
|
:name="searchIcon"
|
|
28
|
-
:color="searchIconColor ? searchIconColor :
|
|
28
|
+
:color="searchIconColor ? searchIconColor : resolvedColor"
|
|
29
29
|
></up-icon>
|
|
30
30
|
</view>
|
|
31
31
|
<input
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
:auto-blur="autoBlur"
|
|
43
43
|
placeholder-class="u-search__content__input--placeholder"
|
|
44
44
|
:placeholder="placeholder"
|
|
45
|
-
:placeholder-style="`color: ${
|
|
45
|
+
:placeholder-style="`color: ${resolvedPlaceholderColor}`"
|
|
46
46
|
class="u-search__content__input"
|
|
47
47
|
type="text"
|
|
48
48
|
:style="[{
|
|
49
49
|
pointerEvents: disabled ? 'none' : 'auto',
|
|
50
50
|
textAlign: inputAlign,
|
|
51
|
-
color:
|
|
52
|
-
backgroundColor:
|
|
51
|
+
color: resolvedColor,
|
|
52
|
+
backgroundColor: resolvedBgColor,
|
|
53
53
|
height: addUnit(height)
|
|
54
54
|
}, inputStyle]"
|
|
55
55
|
/>
|
|
@@ -163,6 +163,29 @@
|
|
|
163
163
|
// #endif
|
|
164
164
|
},
|
|
165
165
|
computed: {
|
|
166
|
+
resolvedBgColor() {
|
|
167
|
+
if (this.bgColor) {
|
|
168
|
+
return this.bgColor
|
|
169
|
+
}
|
|
170
|
+
return this.upThemeVar('--up-card-bg-color', this.$u?.color?.bgColor || '#f2f2f2')
|
|
171
|
+
},
|
|
172
|
+
resolvedBorderColor() {
|
|
173
|
+
// 外部显式传参时保持原行为
|
|
174
|
+
if (this.upHasProp('borderColor') || (this.borderColor && this.borderColor !== 'transparent')) {
|
|
175
|
+
return this.borderColor
|
|
176
|
+
}
|
|
177
|
+
// 暗黑模式默认给弱边框,避免背景同色时轮廓不明显
|
|
178
|
+
if (this.upThemeIsDark) {
|
|
179
|
+
return this.upThemeVar('--up-border-color', 'rgba(255, 255, 255, 0.12)')
|
|
180
|
+
}
|
|
181
|
+
return 'transparent'
|
|
182
|
+
},
|
|
183
|
+
resolvedColor() {
|
|
184
|
+
return this.color || this.upThemeVar('--up-content-color', this.$u?.color?.contentColor || '#606266')
|
|
185
|
+
},
|
|
186
|
+
resolvedPlaceholderColor() {
|
|
187
|
+
return this.placeholderColor || this.upThemeVar('--up-tips-color', this.$u?.color?.tipsColor || '#909399')
|
|
188
|
+
},
|
|
166
189
|
showActionBtn() {
|
|
167
190
|
return !this.animation && this.showAction
|
|
168
191
|
},
|