uview-plus 3.7.36 → 3.8.32
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 +2047 -1782
- 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-cropper/u-cropper.vue +409 -387
- 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-poster/u-poster.vue +12 -10
- package/components/u-pull-refresh/u-pull-refresh.vue +6 -6
- package/components/u-qrcode/qrcode.js +35 -29
- package/components/u-qrcode/u-qrcode.vue +17 -12
- 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 +13 -9
- package/components/u-tooltip/u-tooltip.vue +1 -0
- 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/config.js +2 -0
- package/libs/config/props.js +1 -1
- package/libs/css/theme-vars-core.scss +201 -0
- package/libs/css/theme-vars.scss +1 -0
- package/libs/function/index.js +7 -7
- package/libs/mixin/mixin.js +111 -4
- package/libs/root/index.js +151 -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 +44 -0
- package/libs/root/runtime.js +11 -0
- package/libs/root/utils.js +115 -0
- package/libs/theme/runtime.js +392 -0
- package/libs/theme/theme.js +682 -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 +3 -2
- package/theme.scss +113 -32
- package/types/comps/qrcode.d.ts +6 -0
- package/types/index.d.ts +47 -2
|
@@ -1023,11 +1023,12 @@ let QRCode = {};
|
|
|
1023
1023
|
QRCode = function (opt) {
|
|
1024
1024
|
//设置默认参数
|
|
1025
1025
|
this.options = {
|
|
1026
|
-
text: '',
|
|
1027
|
-
size: 256,
|
|
1028
|
-
correctLevel: 3,
|
|
1029
|
-
|
|
1030
|
-
|
|
1026
|
+
text: '',
|
|
1027
|
+
size: 256,
|
|
1028
|
+
correctLevel: 3,
|
|
1029
|
+
quietZone: 0,
|
|
1030
|
+
background: '#ffffff',
|
|
1031
|
+
foreground: '#000000',
|
|
1031
1032
|
pdground: '#000000',
|
|
1032
1033
|
image: '',
|
|
1033
1034
|
imageSize: 30,
|
|
@@ -1103,30 +1104,35 @@ let QRCode = {};
|
|
|
1103
1104
|
var ctx = '';
|
|
1104
1105
|
ctx = options.ctx;
|
|
1105
1106
|
|
|
1106
|
-
var count = qrCodeAlg.getModuleCount();
|
|
1107
|
-
var
|
|
1108
|
-
var
|
|
1109
|
-
|
|
1110
|
-
var
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
var
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1107
|
+
var count = qrCodeAlg.getModuleCount();
|
|
1108
|
+
var quietZone = Math.max(0, Math.floor(options.quietZone || 0));
|
|
1109
|
+
var renderCount = count + quietZone * 2;
|
|
1110
|
+
var ratioSize = options.size;
|
|
1111
|
+
var ratioImgSize = options.imageSize;
|
|
1112
|
+
//计算每个点的长宽
|
|
1113
|
+
var tileW = (ratioSize / renderCount).toPrecision(4);
|
|
1114
|
+
var tileH = (ratioSize / renderCount).toPrecision(4);
|
|
1115
|
+
//绘制
|
|
1116
|
+
for (var row = 0; row < renderCount; row++) {
|
|
1117
|
+
for (var col = 0; col < renderCount; col++) {
|
|
1118
|
+
var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
|
|
1119
|
+
var h = (Math.ceil((row + 1) * tileH) - Math.floor(row * tileH));
|
|
1120
|
+
var qrRow = row - quietZone;
|
|
1121
|
+
var qrCol = col - quietZone;
|
|
1122
|
+
var isDark = qrRow >= 0 && qrCol >= 0 && qrRow < count && qrCol < count && qrCodeAlg.modules[qrRow][qrCol];
|
|
1123
|
+
var foreground = getForeGround({
|
|
1124
|
+
row: qrRow,
|
|
1125
|
+
col: qrCol,
|
|
1126
|
+
count: count,
|
|
1127
|
+
options: options
|
|
1128
|
+
});
|
|
1129
|
+
if (options.isNvue) {
|
|
1130
|
+
ctx.setFillStyle(isDark ? foreground : options.background);
|
|
1131
|
+
} else {
|
|
1132
|
+
ctx.fillStyle = isDark ? foreground : options.background;
|
|
1133
|
+
}
|
|
1134
|
+
ctx.fillRect(Math.round(col * tileW), Math.round(row * tileH), w, h);
|
|
1135
|
+
}
|
|
1130
1136
|
}
|
|
1131
1137
|
if (options.image) {
|
|
1132
1138
|
var x = Number(((ratioSize - ratioImgSize) / 2).toFixed(2));
|
|
@@ -101,13 +101,17 @@ export default {
|
|
|
101
101
|
type: Number,
|
|
102
102
|
default: 40
|
|
103
103
|
},
|
|
104
|
-
lv: {
|
|
105
|
-
type: Number,
|
|
106
|
-
default: 3
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
type:
|
|
110
|
-
default:
|
|
104
|
+
lv: {
|
|
105
|
+
type: Number,
|
|
106
|
+
default: 3
|
|
107
|
+
},
|
|
108
|
+
quietZone: {
|
|
109
|
+
type: Number,
|
|
110
|
+
default: 0
|
|
111
|
+
},
|
|
112
|
+
onval: {
|
|
113
|
+
type: Boolean,
|
|
114
|
+
default: true
|
|
111
115
|
},
|
|
112
116
|
loadMake: {
|
|
113
117
|
type: Boolean,
|
|
@@ -218,11 +222,12 @@ export default {
|
|
|
218
222
|
loadingText: that.loadingText, // loading文字
|
|
219
223
|
text: that.val, // 生成内容
|
|
220
224
|
size: that.sizeLocal, // 二维码大小
|
|
221
|
-
background: that.background, // 背景色
|
|
222
|
-
foreground: that.foreground, // 前景色
|
|
223
|
-
pdground: that.pdground, // 定位角点颜色
|
|
224
|
-
|
|
225
|
-
|
|
225
|
+
background: that.background, // 背景色
|
|
226
|
+
foreground: that.foreground, // 前景色
|
|
227
|
+
pdground: that.pdground, // 定位角点颜色
|
|
228
|
+
quietZone: that.quietZone, // 静区宽度
|
|
229
|
+
correctLevel: that.lv, // 容错级别
|
|
230
|
+
image: that.icon, // 二维码图标
|
|
226
231
|
imageSize: that.iconSize,// 二维码图标大小
|
|
227
232
|
cbResult: function (res) { // 生成二维码的回调
|
|
228
233
|
that._result(res)
|
|
@@ -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
|
},
|