hw-cus-ui 1.1.17 → 1.1.19

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.
@@ -10,6 +10,7 @@
10
10
  borderTopRightRadius: isDrag ? '20rpx' : '0'
11
11
  }"
12
12
  >
13
+ <!-- 拖拽手柄区域 -->
13
14
  <view
14
15
  v-if="isDrag"
15
16
  class="draggable-popup-handle"
@@ -20,6 +21,7 @@
20
21
  >
21
22
  <view class="draggable-popup-handle-line"></view>
22
23
  </view>
24
+ <!-- 弹窗内容区域 -->
23
25
  <view class="draggable-popup-content" :style="{ height: isDrag ? contentPopupTop + 'px' : 'auto' }">
24
26
  <slot></slot>
25
27
  </view>
@@ -29,17 +31,46 @@
29
31
 
30
32
  <script>
31
33
  import { useDebounceFn } from '@vueuse/core';
34
+
35
+ /**
36
+ * 可拖拽底部弹窗组件
37
+ * 支持手势拖拽控制弹窗位置,可以向上拖拽展开或向下拖拽收起
38
+ */
32
39
  export default {
33
40
  name: 'DraggableBottomPopup',
34
41
  props: {
42
+ /**
43
+ * 弹窗高度计算比例(相对于屏幕高度)
44
+ * @type {String}
45
+ * @default '0.4'
46
+ */
35
47
  heightCalc: {
36
48
  type: String,
37
49
  default: '0.4'
38
50
  },
51
+ /**
52
+ * 至少保留50px在屏幕内
53
+ * @type {Number}
54
+ * @default 50
55
+ */
56
+ reservedHeight: {
57
+ type: Number,
58
+ default: () => 50
59
+ },
60
+ /**
61
+ * 弹窗背景颜色
62
+ * @type {String}
63
+ * @default '#ffffff'
64
+ */
39
65
  bg: {
40
66
  type: String,
41
67
  default: () => '#ffffff'
42
68
  },
69
+ /**
70
+ * 是否启用拖拽功能
71
+ * @type {Boolean}
72
+ * @default true
73
+ */
43
74
  isDrag: {
44
75
  type: Boolean,
45
76
  default: () => true
@@ -47,18 +78,19 @@ export default {
47
78
  },
48
79
  data() {
49
80
  return {
50
- startY: 0,
51
- startTop: 0,
52
- popupTop: 0,
53
- windowHeight: 0,
54
- contentPopupTop: 0,
55
- isMoving: false,
81
+ startY: 0, // 触摸开始时的Y坐标
82
+ startTop: 0, // 触摸开始时弹窗的top值
83
+ popupTop: 0, // 当前弹窗的top位置
84
+ windowHeight: 0, // 窗口高度
85
+ contentPopupTop: 0, // 内容区域的高度
86
+ isMoving: false, // 是否正在移动中
56
87
  containerHeight: 0, // 容器高度
57
- updateContentPopupTop: null // 防抖函数
88
+ updateContentPopupTop: null // 防抖函数,用于更新内容区域高度
58
89
  };
59
90
  },
60
91
 
61
92
  mounted() {
93
+ // 组件挂载后初始化窗口信息和弹窗位置
62
94
  this.getWindowInfo();
63
95
  this.initPopupPosition();
64
96
  // 初始化防抖函数
@@ -66,7 +98,12 @@ export default {
66
98
  this.contentPopupTop = this.windowHeight - this.popupTop - 25;
67
99
  }, 300);
68
100
  },
101
+
69
102
  methods: {
103
+ /**
104
+ * 获取窗口信息
105
+ * 设置窗口高度并初始化弹窗位置到屏幕外(隐藏状态)
106
+ */
70
107
  getWindowInfo() {
71
108
  const systemInfo = uni.getSystemInfoSync();
72
109
  this.windowHeight = systemInfo.windowHeight;
@@ -74,6 +111,10 @@ export default {
74
111
  this.popupTop = this.windowHeight;
75
112
  },
76
113
 
114
+ /**
115
+ * 初始化弹窗位置
116
+ * 获取容器实际高度并设置默认显示位置
117
+ */
77
118
  initPopupPosition() {
78
119
  this.$nextTick(() => {
79
120
  // 获取内容高度
@@ -93,12 +134,22 @@ export default {
93
134
  });
94
135
  },
95
136
 
137
+ /**
138
+ * 处理触摸开始事件
139
+ * 记录触摸起始位置和当前弹窗位置
140
+ * @param {TouchEvent} e - 触摸事件对象
141
+ */
96
142
  handleTouchStart(e) {
97
143
  this.isMoving = true;
98
144
  this.startY = e.touches[0].clientY;
99
145
  this.startTop = this.popupTop;
100
146
  },
101
147
 
148
+ /**
149
+ * 处理触摸移动事件
150
+ * 根据手指移动距离调整弹窗位置,并限制拖拽范围
151
+ * @param {TouchEvent} e - 触摸事件对象
152
+ */
102
153
  handleTouchMove(e) {
103
154
  if (!this.isMoving) return;
104
155
 
@@ -114,7 +165,7 @@ export default {
114
165
 
115
166
  // 保留一部分在屏幕内,方便拖回
116
167
  if (this.containerHeight > 0) {
117
- const maxTop = this.windowHeight - 50; // 至少保留50px在屏幕内
168
+ const maxTop = this.windowHeight - this.reservedHeight;
118
169
  if (newTop > maxTop) {
119
170
  newTop = maxTop;
120
171
  }
@@ -125,6 +176,11 @@ export default {
125
176
  this.updateContentPopupTop();
126
177
  },
127
178
 
179
+ /**
180
+ * 处理触摸结束事件
181
+ * 结束拖拽操作并根据最终位置调整弹窗状态
182
+ * @param {TouchEvent} e - 触摸事件对象
183
+ */
128
184
  handleTouchEnd(e) {
129
185
  if (!this.isMoving) return;
130
186
  this.isMoving = false;
@@ -144,6 +200,12 @@ export default {
144
200
  }
145
201
  this.changeTop();
146
202
  },
203
+
204
+ /**
205
+ * 发送位置变化事件
206
+ * 向父组件通知弹窗位置的变化
207
+ * @param {Number} top - 当前弹窗的top值
208
+ */
147
209
  changeTop() {
148
210
  this.$emit('changeTop', this.popupTop);
149
211
  }
@@ -96,21 +96,15 @@ import { ref, onMounted, watch, nextTick } from 'vue';
96
96
  const props = defineProps({
97
97
  range: {
98
98
  type: Array,
99
- default: function () {
100
- return [];
101
- }
99
+ default: []
102
100
  },
103
101
  rangeNext: {
104
102
  type: Array,
105
- default: function () {
106
- return [];
107
- }
103
+ default: []
108
104
  },
109
105
  request: {
110
106
  type: Function,
111
- default: function () {
112
- return null;
113
- }
107
+ default: null
114
108
  },
115
109
  idKey: {
116
110
  //字段key值
@@ -331,6 +325,7 @@ onMounted(() => {
331
325
  });
332
326
 
333
327
  function queryList(pageNum, pageSize) {
328
+ if (!props.request) return;
334
329
  props
335
330
  .request({
336
331
  pageSize,
@@ -431,6 +426,8 @@ function _confirm() {
431
426
  * @param {Array} parents - 父节点对象数组
432
427
  */
433
428
  function _renderTreeList(list = [], rank = 0, parentId = [], parents = []) {
429
+ val = [];
430
+ temporarySelectedValue = [];
434
431
  if (Array.isArray(props.modelValue)) {
435
432
  val = props.modelValue || [];
436
433
  } else {
package/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  ## 更新问题版本
7
7
 
8
+ - 1.1.18版本:修复拖拽被遮挡问题
8
9
  - 1.1.17版本:修复列表类型问题
9
10
  - 1.1.16版本:修复列表类型问题
10
11
  - 1.1.15版本:修复列表类型问题
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hw-cus-ui",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
4
4
  "description": "使用该组件库需安装uniapp插件@dcloudio/uni-ui",
5
5
  "main": "index.ts",
6
6
  "scripts": {