uview-plus 3.5.28 → 3.5.39

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,38 @@
1
+ ## 3.5.39(2025-09-07)
2
+ fix: 修复cascader多语言问题
3
+
4
+ ## 3.5.38(2025-09-07)
5
+ improvment: 完善演示图标
6
+
7
+ ## 3.5.37(2025-09-05)
8
+ feat: cascader支持多语言
9
+
10
+ ## 3.5.36(2025-09-04)
11
+ improvment: 补充图标
12
+
13
+ ## 3.5.35(2025-09-04)
14
+ feat: cascader级联组件增加垂直头部与单列选项支持
15
+
16
+ ## 3.5.34(2025-09-03)
17
+ improvement: 优化steps-item
18
+
19
+ ## 3.5.33(2025-09-02)
20
+ 升级uni-app至最新版
21
+ ## 3.5.32(2025-09-01)
22
+ feat: cate-tab支持非联动跟随的单一切换模式
23
+
24
+ feat: choose组件示例使用cate-tab的单一切换模式
25
+
26
+
27
+ ## 3.5.31(2025-09-01)
28
+ feat: 新增choose通用选项选择器组件
29
+
30
+ ## 3.5.30(2025-08-31)
31
+ fix: 修复缺失cascader级联选择器
32
+
33
+ ## 3.5.29(2025-08-30)
34
+ feat: 新增cascader级联选择器
35
+
1
36
  ## 3.5.28(2025-08-29)
2
37
  feat: 多语言增加泰语
3
38
 
@@ -0,0 +1,333 @@
1
+ <template>
2
+ <up-popup :show="popupShow" mode="bottom" :popup="false"
3
+ :mask="true" :closeable="true" :safe-area-inset-bottom="true"
4
+ close-icon-color="#ffffff" :z-index="uZIndex"
5
+ :maskCloseAble="maskCloseAble" @close="close">
6
+ <view class="up-p-t-30 up-p-l-20 up-m-b-10" v-if="headerDirection =='column'">
7
+ <up-steps v-if="popupShow" dot direction="column" v-model:current="tabsIndex">
8
+ <up-steps-item v-for="(item, index) in genTabsList"
9
+ @click="tabsIndex = index" :title="item.name"></up-steps-item>
10
+ </up-steps>
11
+ </view>
12
+ <view class="up-p-t-20 up-m-b-10" v-else>
13
+ <up-tabs v-if="popupShow" :list="genTabsList"
14
+ :scrollable="true" v-model:current="tabsIndex" @change="tabsChange" ref="tabs"></up-tabs>
15
+ </view>
16
+ <view class="area-box">
17
+ <view class="u-flex" :class="{ 'change':isChange }"
18
+ :style="{transform: optionsCols == 2 && isChange ? 'translateX(-33.3333333%)' : ''}">
19
+ <template v-for="(levelData, levelIndex) in levelList" :key="levelIndex">
20
+ <view v-if="optionsCols == 2 || levelIndex == tabsIndex" class="area-item"
21
+ :style="{ width: optionsCols == 2 ? '33.33333%' : '750rpx'}">
22
+ <view class="u-padding-10 u-bg-gray" style="height: 100%;">
23
+ <scroll-view :scroll-y="true" style="height: 100%">
24
+ <up-cell-group v-if="levelIndex === 0 || selectedValueIndexs[levelIndex - 1] !== undefined">
25
+ <up-cell v-for="(item,index) in levelData"
26
+ :title="item[labelKey]" :arrow="false"
27
+ :index="index" :key="index"
28
+ @click="levelChange(levelIndex, index)">
29
+ <template v-slot:right-icon>
30
+ <up-icon v-if="selectedValueIndexs[levelIndex] === index"
31
+ size="17" name="checkbox-mark"></up-icon>
32
+ </template>
33
+ </up-cell>
34
+ </up-cell-group>
35
+ </scroll-view>
36
+ </view>
37
+ </view>
38
+ </template>
39
+ </view>
40
+ </view>
41
+ <!-- 添加按钮区域 -->
42
+ <view class="u-cascader-action up-flex up-flex-between">
43
+ <view class="u-padding-20 up-flex-fill">
44
+ <up-button @click="handleCancel" type="default">{{ t("up.common.cancel") }}</up-button>
45
+ </view>
46
+ <view class="u-padding-20 up-flex-fill">
47
+ <up-button @click="handleConfirm" type="primary">{{ t("up.common.confirm") }}</up-button>
48
+ </view>
49
+ </view>
50
+ </up-popup>
51
+ </template>
52
+
53
+ <script>
54
+ /**
55
+ * u-cascader 通用无限级联选择器
56
+ * @property {String Number} z-index 弹出时的z-index值(默认1075)
57
+ * @property {Boolean} mask-close-able 是否允许通过点击遮罩关闭Picker(默认true)
58
+ * @property {Array} data 级联数据
59
+ * @property {Array} default-value 默认选中的值
60
+ * @property {String} valueKey 指定选项的值为选项对象中的哪个属性值
61
+ * @property {String} labelKey 指定选项标签为选项对象中的哪个属性值
62
+ * @property {String} childrenKey 指定选项的子选项为选项对象中的哪个属性值
63
+ * @property {Boolean} autoClose 是否在选择最后一级时自动关闭并触发confirm(默认false)
64
+ */
65
+ import { t } from '../../libs/i18n'
66
+ export default {
67
+ name: 'up-cascader',
68
+ props: {
69
+ // 通过双向绑定控制组件的弹出与收起
70
+ show: {
71
+ type: Boolean,
72
+ default: false
73
+ },
74
+ // 级联数据
75
+ data: {
76
+ type: Array,
77
+ default() {
78
+ return [];
79
+ }
80
+ },
81
+ // 默认选中的值
82
+ modelValue: {
83
+ type: Array,
84
+ default() {
85
+ return [];
86
+ }
87
+ },
88
+ // 指定选项的值为选项对象中的哪个属性值
89
+ valueKey: {
90
+ type: String,
91
+ default: 'value'
92
+ },
93
+ // 指定选项标签为选项对象中的哪个属性值
94
+ labelKey: {
95
+ type: String,
96
+ default: 'label'
97
+ },
98
+ // 指定选项的子选项为选项对象中的哪个属性值
99
+ childrenKey: {
100
+ type: String,
101
+ default: 'children'
102
+ },
103
+ // 是否允许通过点击遮罩关闭Picker
104
+ maskCloseAble: {
105
+ type: Boolean,
106
+ default: true
107
+ },
108
+ // 弹出的z-index值
109
+ zIndex: {
110
+ type: [String, Number],
111
+ default: 0
112
+ },
113
+ // 是否在选择最后一级时自动关闭并触发confirm
114
+ autoClose: {
115
+ type: Boolean,
116
+ default: false
117
+ },
118
+ // 选中项目的展示方向direction垂直方向适合文字长度过长
119
+ headerDirection: {
120
+ type: String,
121
+ default: 'row'
122
+ },
123
+ // 选项区域列数,支持1列和2列,默认为2列
124
+ optionsCols: {
125
+ type: [Number],
126
+ default: 2
127
+ }
128
+ },
129
+ data() {
130
+ return {
131
+ // 存储每一级的数据
132
+ levelList: [],
133
+ // 存储每一级选中的索引
134
+ selectedValueIndexs: [],
135
+ tabsIndex: 0,
136
+ popupShow: false,
137
+ // 新增confirmValues用于存储确认的值
138
+ confirmValues: []
139
+ }
140
+ },
141
+ watch: {
142
+ data: {
143
+ handler() {
144
+ this.initLevelList();
145
+ },
146
+ immediate: true
147
+ },
148
+ show() {
149
+ this.popupShow = this.show;
150
+ },
151
+ modelValue: {
152
+ handler() {
153
+ this.init();
154
+ },
155
+ immediate: true
156
+ }
157
+ },
158
+ computed: {
159
+ t,
160
+ isChange() {
161
+ return this.tabsIndex > 1;
162
+ },
163
+ genTabsList() {
164
+ let tabsList = [{
165
+ name: "请选择"
166
+ }];
167
+
168
+ // 根据选中的值动态生成tabs
169
+ for (let i = 0; i < this.selectedValueIndexs.length; i++) {
170
+ if (this.selectedValueIndexs[i] !== undefined && this.levelList[i]) {
171
+ const selectedItem = this.levelList[i][this.selectedValueIndexs[i]];
172
+ if (selectedItem) {
173
+ tabsList[i] = {
174
+ name: selectedItem[this.labelKey]
175
+ };
176
+ // 如果还有下一级,则添加"请选择"
177
+ if (i === this.selectedValueIndexs.length - 1 &&
178
+ selectedItem[this.childrenKey] &&
179
+ selectedItem[this.childrenKey].length > 0) {
180
+ tabsList.push({
181
+ name: "请选择"
182
+ });
183
+ }
184
+ }
185
+ }
186
+ }
187
+
188
+ return tabsList;
189
+ },
190
+ uZIndex() {
191
+ // 如果用户有传递z-index值,优先使用
192
+ return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
193
+ }
194
+ },
195
+ // 新增confirm事件
196
+ emits: ['update:modelValue', 'change', 'confirm'],
197
+ methods: {
198
+ init() {
199
+ // 初始化选中值
200
+ if (this.modelValue && this.modelValue.length > 0) {
201
+ this.setDefaultValue();
202
+ }
203
+ },
204
+ initLevelList() {
205
+ // 初始化第一级数据
206
+ if (this.data && this.data.length > 0) {
207
+ this.levelList = [this.data];
208
+ this.selectedValueIndexs = [];
209
+ }
210
+ },
211
+ setDefaultValue() {
212
+ // 根据默认值设置选中项
213
+ // 根据modelValue获取indexs给selectedValueIndexs
214
+ this.selectedValueIndexs = [];
215
+ let currentLevelData = this.data;
216
+
217
+ for (let i = 0; i < this.modelValue.length; i++) {
218
+ const value = this.modelValue[i];
219
+ const index = currentLevelData.findIndex(item => item[this.valueKey] === value);
220
+
221
+ if (index !== -1) {
222
+ this.selectedValueIndexs.push(index);
223
+ // 更新下一级的数据
224
+ if (currentLevelData[index][this.childrenKey]) {
225
+ currentLevelData = currentLevelData[index][this.childrenKey];
226
+ } else {
227
+ // 如果没有子级数据,则停止处理
228
+ break;
229
+ }
230
+ } else {
231
+ // 如果找不到匹配项,则停止处理
232
+ break;
233
+ }
234
+ }
235
+ },
236
+ close() {
237
+ this.$emit('update:show', false);
238
+ },
239
+ tabsChange(item) {
240
+ },
241
+ levelChange(levelIndex, index) {
242
+ // 设置当前级的选中值
243
+ this.$set(this.selectedValueIndexs, levelIndex, index);
244
+
245
+ // 清除后续级别的选中值
246
+ for (let i = levelIndex + 1; i < this.selectedValueIndexs.length; i++) {
247
+ this.$set(this.selectedValueIndexs, i, undefined);
248
+ }
249
+
250
+ // 获取当前选中项
251
+ const currentItem = this.levelList[levelIndex][index];
252
+
253
+ // 如果有子级数据,则初始化下一级
254
+ if (currentItem && currentItem[this.childrenKey] && currentItem[this.childrenKey].length > 0) {
255
+ // 确保levelList数组足够长
256
+ if (this.levelList.length <= levelIndex + 1) {
257
+ this.levelList.push(currentItem[this.childrenKey]);
258
+ } else {
259
+ this.$set(this.levelList, levelIndex + 1, currentItem[this.childrenKey]);
260
+ }
261
+ // 切换到下一级tab
262
+ this.tabsIndex = levelIndex + 1;
263
+ } else {
264
+ // 没有子级数据,说明是最后一级
265
+ if (this.autoClose) {
266
+ // 如果启用自动关闭,则触发change事件并关闭
267
+ this.emitChange();
268
+ } else {
269
+ // 否则只触发change事件,不关闭
270
+ this.emitChange(false);
271
+ }
272
+ }
273
+ },
274
+ // 修改emitChange方法,增加closePopup参数
275
+ emitChange(closePopup = true) {
276
+ // 构造选中结果
277
+ const result = [];
278
+ for (let i = 0; i < this.selectedValueIndexs.length; i++) {
279
+ if (this.selectedValueIndexs[i] !== undefined && this.levelList[i]) {
280
+ result.push(this.levelList[i][this.selectedValueIndexs[i]][this.valueKey]);
281
+ }
282
+ }
283
+
284
+ // 更新confirmValues
285
+ this.confirmValues = [...result];
286
+
287
+ // 触发change事件,返回value数组
288
+ this.$emit('change', this.confirmValues);
289
+
290
+ // 根据参数决定是否关闭弹窗
291
+ if (closePopup) {
292
+ this.close();
293
+ }
294
+ },
295
+ handleCancel() {
296
+ this.close();
297
+ },
298
+ handleConfirm() {
299
+ // 确认时触发confirm事件
300
+ this.$emit('update:modelValue', this.confirmValues);
301
+ this.$emit('confirm', this.confirmValues);
302
+ this.close();
303
+ }
304
+ }
305
+ }
306
+ </script>
307
+ <style lang="scss">
308
+ .area-box {
309
+ width: 100%;
310
+ overflow: hidden;
311
+ height: 800rpx;
312
+
313
+ >view {
314
+ width: 150%;
315
+ transition: transform 0.3s ease-in-out 0s;
316
+ transform: translateX(0);
317
+
318
+ &.change {
319
+ // transform: translateX(-33.3333333%);
320
+ }
321
+ }
322
+
323
+ .area-item {
324
+ // width: 750rpx;
325
+ height: 800rpx;
326
+ }
327
+ }
328
+
329
+ // 添加按钮区域样式
330
+ .u-cascader-action {
331
+ border-top: 1px solid #eee;
332
+ }
333
+ </style>
@@ -19,26 +19,28 @@
19
19
  </slot>
20
20
  </view>
21
21
  <view class="u-cate-tab__page-view">
22
- <view class="u-cate-tab__page-item" :id="'item' + index"
23
- v-for="(item , index) in tabList" :key="index">
24
- <slot name="itemList" :item="item">
25
- </slot>
26
- <template v-if="!$slots['itemList']">
27
- <view class="item-title">
28
- <text>{{item[tabKeyName]}}</text>
29
- </view>
30
- <view class="item-container">
31
- <template v-for="(item1, index1) in item.children" :key="index1">
32
- <slot name="pageItem" :pageItem="item1">
33
- <view class="thumb-box" >
34
- <image class="item-menu-image" :src="item1.icon" mode=""></image>
35
- <view class="item-menu-name">{{item1[itemKeyName]}}</view>
36
- </view>
37
- </slot>
38
- </template>
39
- </view>
40
- </template>
41
- </view>
22
+ <template :key="index" v-for="(item , index) in tabList">
23
+ <view v-if="mode == 'follow' || ( mode == 'tab' && index == innerCurrent)"
24
+ class="u-cate-tab__page-item" :id="'item' + index">
25
+ <slot name="itemList" :item="item">
26
+ </slot>
27
+ <template v-if="!$slots['itemList']">
28
+ <view class="item-title">
29
+ <text>{{item[tabKeyName]}}</text>
30
+ </view>
31
+ <view class="item-container">
32
+ <template v-for="(item1, index1) in item.children" :key="index1">
33
+ <slot name="pageItem" :pageItem="item1">
34
+ <view class="thumb-box" >
35
+ <image class="item-menu-image" :src="item1.icon" mode=""></image>
36
+ <view class="item-menu-name">{{item1[itemKeyName]}}</view>
37
+ </view>
38
+ </slot>
39
+ </template>
40
+ </view>
41
+ </template>
42
+ </view>
43
+ </template>
42
44
  </view>
43
45
  </scroll-view>
44
46
  </view>
@@ -49,6 +51,10 @@
49
51
  export default {
50
52
  name: 'up-cate-tab',
51
53
  props: {
54
+ mode: {
55
+ type: String,
56
+ default: 'follow' // follo跟随联动, tab单一显示。
57
+ },
52
58
  height: {
53
59
  type: String,
54
60
  default: '100%'
@@ -119,10 +125,13 @@
119
125
  addUnit,
120
126
  // 点击左边的栏目切换
121
127
  async swichMenu(index) {
122
- if(this.arr.length == 0) {
123
- await this.getMenuItemTop();
128
+ if (this.mode == 'follow') {
129
+ if(this.arr.length == 0) {
130
+ await this.getMenuItemTop();
131
+ }
132
+ this.scrollIntoView = 'item' + index;
124
133
  }
125
- this.scrollIntoView = 'item' + index;
134
+
126
135
  if (index == this.innerCurrent) return;
127
136
  this.$nextTick(function(){
128
137
  this.innerCurrent = index;
@@ -216,6 +225,7 @@
216
225
  },
217
226
  // 右边菜单滚动
218
227
  async rightScroll(e) {
228
+ if (this.mode !== 'follow') return;
219
229
  this.oldScrollTop = e.detail.scrollTop;
220
230
  // console.log(e.detail.scrollTop)
221
231
  // console.log(JSON.stringify(this.arr))
@@ -261,6 +271,7 @@
261
271
  .u-cate-tab__wrap {
262
272
  flex: 1;
263
273
  display: flex;
274
+ flex-direction: row;
264
275
  overflow: hidden;
265
276
  }
266
277
 
@@ -0,0 +1,109 @@
1
+ <style scoped lang="scss">
2
+ .up-choose {
3
+ ::v-deep .up-tag {
4
+ font-weight: 600;
5
+ }
6
+ &:last-child {
7
+ margin-right: 0;
8
+ }
9
+ }
10
+
11
+ .up-choose-wrap {
12
+ flex-wrap: wrap;
13
+ }
14
+
15
+ .up-choose-nowrap {
16
+ flex-wrap: nowrap;
17
+ white-space: nowrap;
18
+ }
19
+ </style>
20
+
21
+ <template>
22
+ <scroll-view
23
+ :scroll-x="wrap === false"
24
+ :class="['up-choose', wrap ? 'up-choose-wrap' : 'up-choose-nowrap']">
25
+ <template :key="item.id" v-for="(item,index) in options">
26
+ <view :style="{width: width, display: 'inline-block'}">
27
+ <slot :item="item" :index="index">
28
+ <up-tag :type="index == currentIndex ? 'primary' : 'info'"
29
+ size="large" :plain="index == currentIndex ? false : true"
30
+ :class="currentIndex === index ? 'active': ''" :height="itemHeight"
31
+ :style="{width: itemWidth, padding: itemPadding}"
32
+ @click="change(index)">
33
+ {{item[labelName]}}
34
+ </up-tag>
35
+ </slot>
36
+ </view>
37
+ </template>
38
+ </scroll-view>
39
+ </template>
40
+
41
+ <script>
42
+ export default {
43
+ name: 'up-choose',
44
+ props: {
45
+ options:{
46
+ type: Array,
47
+ default: ()=>{
48
+ return [];
49
+ }
50
+ },
51
+ modelValue: {
52
+ type: [Number,String,Array],
53
+ default: false
54
+ },
55
+ type: {
56
+ type: [String],
57
+ default: 'radio'
58
+ },
59
+ itemWidth: {
60
+ type: [String],
61
+ default: 'auto'
62
+ },
63
+ itemHeight: {
64
+ type: [String],
65
+ default: '50px'
66
+ },
67
+ itemPadding: {
68
+ type: [String],
69
+ default: '8px'
70
+ },
71
+ labelName: {
72
+ type: String,
73
+ default: 'title'
74
+ },
75
+ valueName: {
76
+ type: String,
77
+ default: 'value'
78
+ },
79
+ customClick: {
80
+ type: Boolean,
81
+ default: false
82
+ },
83
+ // 是否换行
84
+ wrap: {
85
+ type: Boolean,
86
+ default: true
87
+ }
88
+ },
89
+ data() {
90
+ return {
91
+ currentIndex: ''
92
+ }
93
+ },
94
+ created: function () {
95
+ this.currentIndex = this.modelValue;
96
+ },
97
+ emits: ['update:modelValue', 'custom-click'],
98
+ methods: {
99
+ change(index){
100
+ if (this.customClick) {
101
+ this.$emit('custom-click', index);
102
+ } else {
103
+ this.currentIndex = index;
104
+ this.$emit('update:modelValue', index);
105
+ }
106
+ }
107
+ }
108
+ }
109
+ </script>
@@ -39,7 +39,8 @@
39
39
  <view class="u-steps-item__content__title">
40
40
  <slot name="title">
41
41
  </slot>
42
- <up-text v-if="!$slots['title']" :text="title" :type="parentData.current == index ? 'main' : 'content'" lineHeight="20px"
42
+ <up-text v-if="!$slots['title']" :text="title" lineHeight="20px"
43
+ :type="parentData.current == index ? 'main' : 'content'"
43
44
  :size="parentData.current == index ? 14 : 13"></up-text>
44
45
  </view>
45
46
  <view class="u-steps-item__content__desc">
@@ -313,6 +314,12 @@
313
314
  @include flex;
314
315
  flex: 1;
315
316
 
317
+ &__title {
318
+ // #ifdef H5
319
+ cursor: pointer;
320
+ // #endif
321
+ }
322
+
316
323
  &--row {
317
324
  flex-direction: column;
318
325
  align-items: center;
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙跨端移动组件库,组件丰富维护更新稳定。",
5
- "version": "3.5.28",
6
- "description": "零云®uview-plus已兼容vue3支持多语言,100+全面的组件和便捷的工具会让您信手拈来。近期新增拖动排序、条码、图片裁剪、下拉刷新、虚拟列表、签名、Markdown等。",
5
+ "version": "3.5.39",
6
+ "description": "零云®uview-plus已兼容vue3支持多语言,120+全面的组件和便捷的工具会让您信手拈来。近期新增拖动排序、条码、图片裁剪、下拉刷新、虚拟列表、签名、Markdown等。",
7
7
  "keywords": [
8
8
  "uview",
9
9
  "uview-plus",
@@ -49,7 +49,7 @@
49
49
  "cloud": {
50
50
  "tcb": "√",
51
51
  "aliyun": "√",
52
- "alipay": "x"
52
+ "alipay": ""
53
53
  },
54
54
  "client": {
55
55
  "uni-app": {