uview-plus 3.3.20 → 3.3.22

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.21(2024-08-15)
2
+ improvement: 优化二维码组件loading及支持预览与长按事件 #351
3
+
4
+ fix: 修复swipe-action自动关闭其它功能及组件卸载自动关闭
5
+
1
6
  ## 3.3.20(2024-08-15)
2
7
  refactor: props默认值文件移至组件文件夹内便于查找
3
8
  ## 3.3.19(2024-08-14)
@@ -1,7 +1,17 @@
1
1
  <template>
2
- <view class="u-qrcode">
3
- <canvas class="u-qrcode__canvas" :id="cid" :canvas-id="cid" :style="{ width: size + unit, height: size + unit }" />
4
- <image v-show="show" :src="result" :style="{ width: size + unit, height: size + unit }" />
2
+ <view class="u-qrcode" @longpress="longpress">
3
+ <view class="u-qrcode__content" @click="preview">
4
+ <canvas class="u-qrcode__canvas"
5
+ :id="cid" :canvas-id="cid" :style="{ width: size + unit, height: size + unit }" />
6
+ <view v-if="showLoading && loading" class="u-qrcode__loading"
7
+ :style="{ width: size + unit, height: size + unit }">
8
+ <up-loading-icon vertical :text="loadingText" textSize="14px"></up-loading-icon>
9
+ </view>
10
+ <!-- <image v-show="show" :src="result" :style="{ width: size + unit, height: size + unit }" /> -->
11
+ </view>
12
+ <!-- <up-action-sheet :actions="list" cancelText="取消"
13
+ v-model:show="popupShow" @select="selectClick">
14
+ </up-action-sheet> -->
5
15
  </view>
6
16
  </template>
7
17
 
@@ -73,23 +83,32 @@ export default {
73
83
  },
74
84
  loadingText: {
75
85
  type: String,
76
- default: '二维码生成中'
86
+ default: '生成中'
77
87
  },
78
88
  },
89
+ emits: ['result', 'longpress'],
79
90
  data() {
80
91
  return {
92
+ loading: false,
81
93
  result: '',
94
+ popupShow: false,
95
+ list: [
96
+ {
97
+ name: '保存二维码',
98
+ }
99
+ ]
82
100
  }
83
101
  },
84
102
  methods: {
85
103
  _makeCode() {
86
104
  let that = this
87
105
  if (!this._empty(this.val)) {
106
+ this.loading = true
88
107
  qrcode = new QRCode({
89
108
  context: that, // 上下文环境
90
109
  canvasId: that.cid, // canvas-id
91
110
  usingComponents: that.usingComponents, // 是否是自定义组件
92
- showLoading: that.showLoading, // 是否显示loading
111
+ showLoading: false, // 是否显示loading
93
112
  loadingText: that.loadingText, // loading文字
94
113
  text: that.val, // 生成内容
95
114
  size: that.size, // 二维码大小
@@ -130,9 +149,42 @@ export default {
130
149
  });
131
150
  }
132
151
  },
152
+ preview() {
153
+ // 预览图片
154
+ console.log(this.result)
155
+ uni.previewImage({
156
+ urls: [this.result],
157
+ longPressActions: {
158
+ itemList: ['保存二维码图片'],
159
+ success: function(data) {
160
+ // console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
161
+ switch (data.tapIndex) {
162
+ case 0:
163
+ that._saveCode();
164
+ break;
165
+ }
166
+ },
167
+ fail: function(err) {
168
+ console.log(err.errMsg);
169
+ }
170
+ }
171
+ });
172
+ },
173
+ longpress() {
174
+ this.$emit('longpress', this.result)
175
+ },
176
+ selectClick(index) {
177
+ switch (index) {
178
+ case 0:
179
+ alert('保存二维码')
180
+ this._saveCode();
181
+ break;
182
+ }
183
+ },
133
184
  _result(res) {
185
+ this.loading = false;
134
186
  this.result = res;
135
- this.$emit('result', res)
187
+ this.$emit('result', res);
136
188
  },
137
189
  _empty(v) {
138
190
  let tp = typeof v,
@@ -187,13 +239,26 @@ export default {
187
239
  </script>
188
240
  <style lang="scss" scoped>
189
241
  .u-qrcode {
190
- position: relative;
242
+ &__loading {
243
+ display: flex;
244
+ justify-content: center;
245
+ align-items: center;
246
+ background-color: #f7f7f7;
247
+ position: absolute;
248
+ top: 0;
249
+ bottom: 0;
250
+ left: 0;
251
+ right: 0;
252
+ }
253
+ &__content {
254
+ position: relative;
191
255
 
192
- &__canvas {
193
- position: fixed;
194
- top: -99999rpx;
195
- left: -99999rpx;
196
- z-index: -99999;
256
+ &__canvas {
257
+ position: fixed;
258
+ top: -99999rpx;
259
+ left: -99999rpx;
260
+ z-index: -99999;
261
+ }
197
262
  }
198
263
  }
199
264
  </style>
@@ -6,6 +6,11 @@ export const props = defineMixin({
6
6
  autoClose: {
7
7
  type: Boolean,
8
8
  default: () => defProps.swipeAction.autoClose
9
+ },
10
+ // 是否存在打开的按钮组
11
+ opendItem: {
12
+ type: Boolean,
13
+ default: false
9
14
  }
10
15
  }
11
16
  })
@@ -35,6 +35,7 @@
35
35
  return [this.autoClose]
36
36
  }
37
37
  },
38
+ emits: ['opendItem:update'],
38
39
  watch: {
39
40
  // 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件
40
41
  parentData() {
@@ -45,6 +46,11 @@
45
46
  })
46
47
  }
47
48
  },
49
+ opendItem(val) {
50
+ if (val == false) {
51
+ this.closeAll()
52
+ }
53
+ }
48
54
  },
49
55
  created() {
50
56
  this.children = []
@@ -59,6 +65,15 @@
59
65
  }
60
66
  })
61
67
  }
68
+ },
69
+ closeAll() {
70
+ // 关闭所有单元格
71
+ this.children.map((item, index) => {
72
+ item.closeHandler()
73
+ })
74
+ },
75
+ setOpendItem(ins) {
76
+ this.$emit('opendItem:update', true)
62
77
  }
63
78
  }
64
79
  }
@@ -14,7 +14,7 @@ export default {
14
14
  if (this.disabled) return
15
15
  // 打开或关闭单元格
16
16
  if (newValue === 'close' && this.status === 'open') {
17
- this.closeSwipeAction(instance, ownerInstance)
17
+ this.closeSwipeAction()
18
18
  } else if(newValue === 'open' && this.status === 'close') {
19
19
  this.openSwipeAction()
20
20
  }
@@ -28,7 +28,13 @@ export default {
28
28
  },
29
29
  methods: {
30
30
  clickHandler() {
31
- },
31
+ },
32
+ closeHandler() {
33
+ this.closeSwipeAction()
34
+ },
35
+ setStatus(status) {
36
+ this.status = status
37
+ },
32
38
  getBtnWidth() {
33
39
  let view = uni.createSelectorQuery().in(this).select(".u-swipe-action-item__right");
34
40
  view.fields({
@@ -49,8 +55,9 @@ export default {
49
55
  this.state.startX = touches[0].pageX
50
56
  this.state.startY = touches[0].pageY
51
57
 
52
- // todo关闭其它
53
- // this.$parent && this.$parent.closeOther(this)
58
+ // 关闭其它
59
+ // console.log(this.parent)
60
+ this.parent && this.parent.closeOther(this)
54
61
  },
55
62
  touchmove(event) {
56
63
  // console.log(event)
@@ -101,7 +101,7 @@
101
101
  // #ifdef APP-NVUE
102
102
  nvue,
103
103
  // #endif
104
- // #ifdef APP-VUE || MP-WEIXIN || H5 || MP-QQ || H5
104
+ // #ifdef APP-VUE || MP-WEIXIN || MP-QQ || H5
105
105
  wxs,
106
106
  // #endif
107
107
  // #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO
@@ -127,8 +127,13 @@
127
127
  // #ifndef APP-NVUE
128
128
  wxsInit(newValue, oldValue) {
129
129
  this.queryRect()
130
- }
130
+ },
131
131
  // #endif
132
+ status(newValue) {
133
+ if (newValue === 'open') {
134
+ this.parent && this.parent.setOpendItem(this)
135
+ }
136
+ }
132
137
  },
133
138
  computed: {
134
139
  wxsInit() {
@@ -138,6 +143,9 @@
138
143
  mounted() {
139
144
  this.init()
140
145
  },
146
+ beforeUmount() {
147
+ this.closeHandler()
148
+ },
141
149
  methods: {
142
150
  addUnit,
143
151
  getPx,
@@ -359,9 +359,7 @@
359
359
  &__text {
360
360
  font-size: 15px;
361
361
  color: $u-content-color;
362
- /* #ifndef APP-NVUE */
363
362
  white-space: nowrap !important;
364
- /* #endif */
365
363
 
366
364
  &--disabled {
367
365
  color: $u-disabled-color !important;
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.20",
5
+ "version": "3.3.22",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
7
7
  "keywords": [
8
8
  "uview",