Skip to content

Commit

Permalink
add: qrcode支持props控制是否开启点击预览
Browse files Browse the repository at this point in the history
  • Loading branch information
jry committed Dec 10, 2024
1 parent 9b6e92a commit 04e9c16
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/uni_modules/uview-plus/components/u-qrcode/u-qrcode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export default {
type: String,
default: '生成中'
},
allowPreview: {
type: Boolean,
default: false
},
},
emits: ['result', 'longpress'],
data() {
Expand Down Expand Up @@ -189,26 +193,31 @@ export default {
});
}
},
preview() {
preview(e) {
// 预览图片
// console.log(this.result)
uni.previewImage({
urls: [this.result],
longPressActions: {
itemList: ['保存二维码图片'],
success: function(data) {
// console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
switch (data.tapIndex) {
case 0:
that._saveCode();
break;
if (this.allowPreview) {
uni.previewImage({
urls: [this.result],
longPressActions: {
itemList: ['保存二维码图片'],
success: function(data) {
// console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
switch (data.tapIndex) {
case 0:
that._saveCode();
break;
}
},
fail: function(err) {
console.log(err.errMsg);
}
},
fail: function(err) {
console.log(err.errMsg);
}
}
});
});
}
this.$emit('preview', {
url: this.result
}, e)
},
longpress() {
this.$emit('longpress', this.result)
Expand Down

0 comments on commit 04e9c16

Please sign in to comment.