当前位置:   article > 正文

使用hBuilder打包成app扫一扫_hb封装app可以扫一扫

hb封装app可以扫一扫

参考地址:
https://www.cnblogs.com/huanhuan55/p/11541683.html
https://www.cnblogs.com/e0yu/p/7843505.html
https://blog.csdn.net/qq_39816586/article/details/90700002
http://blog.sina.com.cn/s/blog_60b5e13e0102xnse.html
https://blog.csdn.net/qq_35844177/article/details/78951825
http://www.html5plus.org/doc/zh_cn/barcode.html
参考Demo:https://blog.csdn.net/qq_37896578/article/details/96480198
项目代码:

<template>
  <div class="scan">
    <div @click="sao">扫一扫</div>
    <!-- <button type="button" class="mui-btn mui-btn-blue mui-btn-block" id="startCanOne" @click="ben">识别本地</button> -->
    <div id="bcid">
    </div>
  </div>
</template>

<script>
  let scan = null
  let filters=null
  let styles = {frameColor: "#0f0",scanbarColor: "#0f0"};//边框属性,中间线属性,背景色
  export default {
    data () {
      return {
        codeUrl: '',
      }
    },
    methods: {
      sao(){
        $('#bcid').css({'display':'block'});
          let that=this
          that.startRecognize ()
          that.startScan ()
      },
      // 创建扫描控件
      startRecognize () { 
        let that = this
        if (!window.plus) return
        scan = new plus.barcode.Barcode('bcid',filters,styles)
        scan.onmarked = onmarked
        function onmarked (type, result, file) {
          switch (type) {
            case plus.barcode.QR:
              type = 'QR'
              break
            case plus.barcode.EAN13:
              type = 'EAN13'
              break
            case plus.barcode.EAN8:
              type = 'EAN8'
              break
            default:
              type = '其它' + type
              break
          }
          result = result.replace(/\n/g, '')
          that.codeUrl = result
          alert(result)
          if(result=='我是冯昭'){
//             window.location.href="http://www.baidu.com"
            that.closeScan();
            $('#bcid').css({'display':'none'});
          }else{
//             window.location.href="https://www.51zxw.net/"
            that.closeScan();
            $('#bcid').css({'display':'none'});
          }
        }
      },
      // 开始扫描
      startScan () {
        if (!window.plus) return
        scan.start()
      },
      // 关闭扫描
      cancelScan () {
        if (!window.plus) return
        scan.cancel()
      },
      // 关闭条码识别控件
      closeScan () {
        if (!window.plus) return
        scan.close()
      },
    }
  }
</script>
  • 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

关注我的微信公众号【前端基础教程从0开始】,加我微信,可以免费为您解答问题。回复“1”,拉你进程序员技术讨论群。回复“小程序”,领取300个优秀的小程序开源代码+一套入门教程。回复“领取资源”,领取300G前端,Java,微信小程序,Python等资源,让我们一起学前端。

<style lang="less">
  .scan {
    height: 100%;
    #bcid {
      width: 100%;
      position: fixed;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      height: 100%;
      text-align: center;
      color: #fff;
      background-color: black;
      display: none;
    }
  }
</style>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

hBuilder如何使用,上面的参考地址有

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/854716
推荐阅读
相关标签
  

闽ICP备14008679号