uview-plus 3.3.61 → 3.3.62

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/changelog.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 3.3.62(2025-01-10)
2
+ feat: sleder滑动选择器双滑块增加外层触发值的变动功能
3
+
4
+ fix: picker支持hasInput优化
5
+
1
6
  ## 3.3.61(2024-12-31)
2
7
  fix: 修复微信getSystemInfoSync接口废弃警告
3
8
 
@@ -38,6 +38,7 @@
38
38
  </template>
39
39
  <script>
40
40
  export default {
41
+ name: 'up-cate-tab',
41
42
  props: {
42
43
  tabList: {
43
44
  type: Array,
@@ -262,6 +263,7 @@
262
263
  }
263
264
 
264
265
  .u-cate-tab__right-box {
266
+ flex: 1;
265
267
  background-color: rgb(250, 250, 250);
266
268
  }
267
269
 
@@ -81,6 +81,16 @@
81
81
  */
82
82
  export default {
83
83
  name: 'u-icon',
84
+ beforeCreate() {
85
+ // #ifdef APP-NVUE
86
+ if (this.customFontFamily) {
87
+ domModule.addRule('fontFace', {
88
+ 'fontFamily': `${this.customPrefix}-${this.customFontFamily}`,
89
+ 'src': `url('${this.customFontUrl}')`
90
+ })
91
+ }
92
+ // #endif
93
+ },
84
94
  data() {
85
95
  return {
86
96
 
@@ -136,7 +146,9 @@
136
146
  // 通过图标名,查找对应的图标
137
147
  icon() {
138
148
  // 使用自定义图标的时候页面上会把name属性也展示出来,所以在这里处理一下
139
- if (this.customPrefix !== "uicon") return "";
149
+ if (this.customPrefix !== "uicon") {
150
+ return this.customIcons[this.customPrefix + '-' + this.name] || this.name;
151
+ }
140
152
  // 如果内置的图标中找不到对应的图标,就直接返回name值,因为用户可能传入的是unicode代码
141
153
  return icons['uicon-' + this.name] || this.name
142
154
  }
@@ -1,12 +1,11 @@
1
1
  <template>
2
2
  <view class="u-picker-warrper">
3
- <view v-if="hasInput" class="u-picker-input cursor-pointer" @click="showByClickInput = !showByClickInput">
4
- <slot>
5
- <view>
6
- {{ inputLabel && inputLabel.length ? inputLabel.join('/') : placeholder }}
7
- </view>
8
- </slot>
9
- </view>
3
+ <view v-if="hasInput" class="u-picker-input cursor-pointer" @click="showByClickInput = !showByClickInput">
4
+ <slot>
5
+ <up-input :placeholder="placeholder" :readonly="true" border="surround" v-model="inputLabel"></up-input>
6
+ <div class="input-cover"></div>
7
+ </slot>
8
+ </view>
10
9
  <u-popup
11
10
  :show="show || (hasInput && showByClickInput)"
12
11
  :mode="popupMode"
@@ -114,6 +113,7 @@ export default {
114
113
  // 上一次的变化列索引
115
114
  columnIndex: 0,
116
115
  showByClickInput: false,
116
+ currentActiveValue: [] //当前用户选中,但是还没确认的值,用户没做change操作时候,点击确认可以默认选中第一个
117
117
  }
118
118
  },
119
119
  watch: {
@@ -121,8 +121,13 @@ export default {
121
121
  defaultIndex: {
122
122
  immediate: true,
123
123
  deep:true,
124
- handler(n) {
125
- this.setIndexs(n, true)
124
+ handler(n,o) {
125
+ // 修复uniapp调用子组件直接:defaultIndex="[0]"这样写
126
+ // v-model的值变化时候导致defaultIndexwatch也会执行的问题
127
+ //单纯vue不会出现
128
+ if (!o || n.join("/") != o.join("/")) {
129
+ this.setIndexs(n, true)
130
+ }
126
131
  }
127
132
  },
128
133
  // 监听columns参数的变化
@@ -136,22 +141,38 @@ export default {
136
141
  },
137
142
  emits: ['close', 'cancel', 'confirm', 'change', 'update:modelValue', 'update:show'],
138
143
  computed: {
139
- inputLabel() {
140
- let items = this.innerColumns.map((item, index) => item[this.innerIndex[index]])
141
- let res = []
142
- items.forEach(element => {
143
- res.push(element[this.keyName])
144
- });
145
- return res
146
- },
147
- inputValue() {
148
- let items = this.innerColumns.map((item, index) => item[this.innerIndex[index]])
149
- let res = []
150
- items.forEach(element => {
151
- res.push(element['id'])
152
- });
153
- return res
154
- }
144
+ //已选&&已确认的值显示在input上面的文案
145
+ inputLabel() {
146
+ let firstItem = this.innerColumns[0] && this.innerColumns[0][0];
147
+ // //区分是不是对象数组
148
+ if (firstItem && Object.prototype.toString.call(firstItem) === '[object Object]') {
149
+ let res = this.innerColumns[0].filter(item => this.modelValue.includes(item['id']))
150
+ res = res.map(item => item[this.keyName]);
151
+ return res.join("/");
152
+
153
+ } else {
154
+ //用户确定的值,才显示到输入框
155
+ return this.modelValue.join("/");
156
+ }
157
+ },
158
+ //已选,待确认的值
159
+ inputValue() {
160
+ let items = this.innerColumns.map((item, index) => item[this.innerIndex[index]])
161
+ let res = []
162
+ //区分是不是对象数组
163
+ if (items[0] && Object.prototype.toString.call(items[0]) === '[object Object]') {
164
+ //对象数组返回id集合
165
+ items.forEach(element => {
166
+ res.push(element && element['id'])
167
+ });
168
+ } else {
169
+ //非对象数组返回元素集合
170
+ items.forEach((element, index) => {
171
+ res.push(element)
172
+ });
173
+ }
174
+ return res
175
+ }
155
176
  },
156
177
  methods: {
157
178
  addUnit,
@@ -184,6 +205,19 @@ export default {
184
205
  },
185
206
  // 点击工具栏的确定按钮
186
207
  confirm() {
208
+ //如果用户有没有触发过change
209
+ if (!this.currentActiveValue.length) {
210
+ let arr = [0]
211
+ //如果有默认值&&默认值的数组长度是正确的,就用默认值
212
+ if (Array.isArray(this.defaultIndex) && this.defaultIndex.length == this.innerColumns.length) {
213
+ arr = [...this.defaultIndex];
214
+ } else {
215
+ //否则默认都选中第一个
216
+ arr = Array(this.innerColumns.length).fill(0);
217
+ }
218
+ this.setLastIndex(arr)
219
+ this.setIndexs(arr)
220
+ }
187
221
  this.$emit('update:modelValue', this.inputValue)
188
222
  if (this.hasInput) {
189
223
  this.showByClickInput = false
@@ -202,6 +236,8 @@ export default {
202
236
  } = e.detail
203
237
  let index = 0,
204
238
  columnIndex = 0
239
+ //记录用户选中但是还没确认的值
240
+ this.currentActiveValue = value;
205
241
  // 通过对比前后两次的列索引,得出当前变化的是哪一列
206
242
  for (let i = 0; i < value.length; i++) {
207
243
  let item = value[i]
@@ -218,9 +254,11 @@ export default {
218
254
  // 将当前的各项变化索引,设置为"上一次"的索引变化值
219
255
  this.setLastIndex(value)
220
256
  this.setIndexs(value)
221
-
222
- this.$emit('update:modelValue', this.inputValue)
223
-
257
+ //如果是非自带输入框才会在change时候触发v-model绑值的变化
258
+ //否则会非常的奇怪,用户未确认,值就变了
259
+ if (!this.hasInput) {
260
+ this.$emit('update:modelValue', this.inputValue)
261
+ }
224
262
  this.$emit('change', {
225
263
  // #ifndef MP-WEIXIN || MP-LARK
226
264
  // 微信小程序不能传递this,会因为循环引用而报错
@@ -303,7 +341,18 @@ export default {
303
341
 
304
342
  .u-picker {
305
343
  position: relative;
306
-
344
+ &-input {
345
+ position: relative;
346
+ .input-cover {
347
+ opacity: 0;
348
+ position: absolute;
349
+ top: 0;
350
+ bottom: 0;
351
+ left: 0;
352
+ right: 0;
353
+ z-index:1;
354
+ }
355
+ }
307
356
  &__view {
308
357
 
309
358
  &__column {
@@ -45,6 +45,7 @@
45
45
  class="u-search__content__input"
46
46
  type="text"
47
47
  :style="[{
48
+ pointerEvents: disabled ? 'none' : 'auto',
48
49
  textAlign: inputAlign,
49
50
  color: color,
50
51
  backgroundColor: bgColor,
@@ -155,8 +155,17 @@
155
155
  value(n) {
156
156
  // 只有在非滑动状态时,才可以通过value更新滑块值,这里监听,是为了让用户触发
157
157
  if(this.status == 'end') this.updateValue(this.value, false);
158
- }
158
+ },
159
159
  // #endif
160
+ rangeValue:{
161
+ handler(n){
162
+ if(this.status == 'end'){
163
+ this.updateValue(this.rangeValue[0], false, 0);
164
+ this.updateValue(this.rangeValue[1], false, 1);
165
+ }
166
+ },
167
+ deep:true
168
+ }
160
169
  },
161
170
  created() {
162
171
  },
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙移动组件库。",
5
- "version": "3.3.61",
5
+ "version": "3.3.62",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
7
7
  "keywords": [
8
8
  "uview",