| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <template>
- <view class="qrcode">
- <view class="name">
- <image :src="avatar" mode="" class="name-img"></image>
- <view class="">
- {{ name }}
- </view>
- </view>
- <view class="ma">
- <div class="qrCode" ref="qrCodeDiv"></div>
- <view class="id">
- <!-- {{ id }} -->
- </view>
- </view>
- </view>
- </template>
- <script>
- import QRCode from 'qrcodejs2';
- export default {
- onLoad(options) {
- this.id = options.id
- console.log(this.id)
- this.$nextTick(function () {
- this.bindQRCode();
- })
- },
- mounted() {
- const data = this.$store.state.user.userInfo
- this.avatar = data.avatar
- this.name = data.nickname || data.real_name
- console.log(this.avatar);
- console.log(this.name);
- },
- data() {
- return {
- id: '',
- avatar: '',
- name: '',
- }
- },
- methods: {
- bindQRCode() {
- new QRCode(this.$refs.qrCodeDiv, {
- render : "canvas",
- text: this.id,
- width: 170,
- height: 170,
- colorDark: "#333333", //二维码颜色
- colorLight: "#ffffff", //二维码背景色
- correctLevel: QRCode.CorrectLevel.L//容错率,L/M/H
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background-color: #fff;
- height: 100%;
- }
- .qrcode {
- text-align: center;
- .name {
- margin: 100rpx;
- image {
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- border: solid 1rpx #eaeaea;
- }
- }
- .ma {
- margin: 0 auto;
- padding: 50rpx;
- width: 450rpx;
- height: 450rpx;
- border: solid 1rpx #3b66f5;
- .name-img {
- width: 300rpx;
- height: 300rpx;
- }
-
- .id {
- font-size: 30rpx;
- margin: 20rpx 0;
- }
- }
- .about {
- margin: 30rpx;
- }
- }
- </style>
|