uniapp 生成二维码
import uQRCode from '@/uni_modules/Sansnn-uQRCode/js_sdk/u-qrcode';
signData :{},
showqrcode :false,
data 引入
method 方法
//关闭二维码弹窗
closeQrcode(){
if (this.qrTime) {
clearInterval(this.qrTime);
this.qrTime = null;
}
},
//获取签名二维码
signCreate(id) {
this.signData.value = window.location.origin +
// 地址 自行定义: 这里的地址 仅仅作为例子展示, 建议用能 访问到的地址,但是不带 ip和端口
"/h5/pages/page/educational/cultivatePunch/cultivatePunch?basicCourseScheduleId=" +
id + new Date().getTime()
this.signData.size = 256
const ctx = uni.createCanvasContext('qrcode');
const uqrcode = new uQRCode({
text: this.signData.value,
size: this.signData.size
},
ctx
);
uqrcode.make();
uqrcode.draw();
this.qrTime = setInterval(()=>{
this.signData.value = window.location.origin +
" 这里的地址自行定义 " +
id+ new Date().getTime()
this.signData.size = 256
const ctx = uni.createCanvasContext('qrcode');
const uqrcode = new uQRCode({
text: this.signData.value,
size: this.signData.size
},
ctx
);
uqrcode.make();
uqrcode.draw();
},5000)
this.showqrcode = true
},
<!-- 二维码弹窗 -->
<u-popup v-model="showqrcode" mode="center" :mask-close-able="false" :closeable="true" class="qrcode-class" @close="closeQrcode">
<view class="" style="padding: 30upx;">
<canvas id="qrcode" canvas-id="qrcode" :style="{ width: `${signData.size}px`, height: `${signData.size}px` }"></canvas>
<view style="font-size: 34upx;margin: 10upx 0;">请学员用手机扫码进行签到或签退</view>
</view>
</u-popup>

浙公网安备 33010602011771号