You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<template> <view class="pageBg"> <view class="pageBgImg"> <topNavbar title="驾校二维码"></topNavbar> <view class="pad"> <view class="card"> <!-- <view class="refresh_row" @click="refresh"> <view class="text">刷新二维码</view> <view class="icon"> <image src="@/static/images/index/ic_shuaxin.png" mode=""></image> </view> </view> --> <view class="qcode"> <canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px;"></canvas> </view> </view> <view class="card"> <user-info/> </view> </view> </view> </view> </template>
<script> import UQRCode from 'uqrcodejs'; var qr = new UQRCode(); export default { data() { return { } }, onShow() { this.$nextTick(()=>{ this.refresh() }) this.test() }, methods: { refresh() { let { schoolId, schoolName} = this.vuex_userInfo // 设置二维码内容
qr.data = JSON.stringify({ schoolId, schoolName: encodeURIComponent(schoolName), QrType: 1, }) // 设置二维码大小,必须与canvas设置的宽高一致
qr.size = 200; qr.margin = 10; qr.errorCorrectLevel = UQRCode.errorCorrectLevel.L // 调用制作二维码方法
qr.make() qr.foregroundImageSrc = require('./coach.png') // 获取canvas上下文
var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件,this必须传入
// 设置uQRCode实例的canvas上下文
qr.canvasContext = canvasContext; // 调用绘制方法将二维码图案绘制到canvas上
qr.drawCanvas(); }, test() { // 里面只能有哈,没有也行,但是不能有别的
let reg = /^哈*$/ let b = reg.test('哈哈') // 最少要一次或一次以上
let reg2 = /^哈*$/ let b2 = reg2.test('') //false
let reg3 = new RegExp(/^1\d{10}$/) let b3 = reg3.test('18267103167') //false
console.log( b3) }, } } </script>
<style lang="scss" scoped> .qcode { width: 100%; display: flex; align-items: center; justify-content: center; padding: 50rpx 0; } .card { padding: 28rpx; margin-bottom: 24rpx; } .refresh_row { display: flex; justify-content: flex-end; align-items: center; padding: 10rpx 0; .text { color: $themC; font-size: 28rpx; } .icon { width: 24rpx; height: 24rpx; margin-left: 6rpx; } } </style>
|