-
Notifications
You must be signed in to change notification settings - Fork 1
/
qrcode.vue
83 lines (79 loc) · 2.33 KB
/
qrcode.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<template>
<scroller show-scrollbar="false">
<div class="group">
<mpwx-btn class="btn" label='生成二维码' id="1" @onBtnClicked="gen"></mpwx-btn>
<mpwx-btn class="btn" label='生成二维码(Base64数据)' id="2" @onBtnClicked="gen2"></mpwx-btn>
</div>
<image ref="img" class="image" autoBitmapRecycle="false"></image>
</scroller>
</template>
<script>
const qrcode = weex.requireModule('qrcode');
var modal = weex.requireModule('modal');
import MpwxBtn from "../mpwx-btn"
export default {
components : {MpwxBtn},
data() {
return {
value: '---'
}
},
methods: {
gen() {
var self = this;
self.value = '---';
qrcode.gen(self.$refs.img, {
content: "Hello, World!",
size: 200,
color: '#41B883',
logo: 'http://cs.txmpay.com:28080/logo_a.png'
}, (e) => {
if(e.result === 'cancel') {
modal.toast({
message: "gen qrcode failed.",
gravity: "bottom",
duration: 1
});
}
});
},
gen2() {
var self = this;
self.value = '---';
qrcode.gen(self.$refs.img, {
content: "bG1zcGF5LmNvbQ==",
size: 200,
type: "base64"
}, (e) => {
if(e.result === 'cancel') {
modal.toast({
message: "gen qrcode failed.",
gravity: "bottom",
duration: 1
});
}
});
}
}
}
</script>
<style scoped>
.group {
flex-direction: column;
width: 650px;
margin-left: 50px;
margin-top: 50px;
}
.image {
min-width: 400px;
min-height: 400px;
margin-top: 50px;
align-self: center;
width: 200px;
height: 200px;
}
.btn {
margin-bottom: 12px;
margin-top: 12px;
}
</style>