在线生成二维码资源在线预览

由于工作需要,需要生成课程中的资源二维码,学生可以直接扫描查看素材,方便教师教学。

我是借助于qrcode.js做的二维码,只需要传一些参数就可以了。下面是代码:

首先引入js插件,编写二维码的显示框。生成二维码的js在页面加载时直接生成二维码,当鼠标从“素材二维码,扫一扫上经过时显示二维码”

<!--二维码插件-->
<script src="<?php echo $this->stylepath; ?>/js/jquery.qrcode.min.js"></script>
<div style="width: 200px;float: right;position:relative;z-index: 9999999;padding-right: 6px;">
                            <button class="button" id="ma" style="float:right; margin-left: 15px;width:150px;">素材二维码,扫一扫</button>
                            <div class="ermas" id="code" style="display: none;position:absolute;top:40px;right:6px;width:150px;height:150px;">

                            </div>
                        </div>
<script type="text/javascript">

                            function showErweima() {
                                var id;
                                id=<?php echo $course_resource->id;?>;
                                //alert(id);
                                $("#code").qrcode({
                                    render: "table", //table方式
                                    width: 150, //宽度
                                    height:150, //高度
                                    text: "http://falvwenmi.ejianweis.com.cn/wap/htmlv/material/footage2.html?"+id, //任意内容
                                });
                            }
                            showErweima()

</script>

<script>
    $("#ma").hover(function(){
        console.log("aaa")
        $("#code").toggle();
    })
</script>

 

posted @ 2019-08-15 10:48  楠...楠  阅读(711)  评论(2编辑  收藏  举报