scan.js 953 B

123456789101112131415161718192021222324252627282930313233
  1. // #ifdef APP-PLUS
  2. const shangMiPrint = uni.requireNativePlugin('G5KJ-ShangMiPrint')
  3. const globalEvent = uni.requireNativePlugin('globalEvent')
  4. export default {
  5. data() {
  6. return {
  7. }
  8. },
  9. created(){
  10. this.listenScan()
  11. },
  12. methods: {
  13. listenScan(){
  14. let that = this
  15. //商米收银台
  16. if(plus.device.vendor == 'SUNMI'){
  17. //https://ext.dcloud.net.cn/plugin?id=3514
  18. //初始化
  19. shangMiPrint.init()
  20. //扫码返回
  21. globalEvent.addEventListener('scancode',function(e){
  22. if(e.code == 'ok'){
  23. let productIdCode = e.data
  24. //that.$msg(productIdCode)
  25. uni.$emit('listenGetScanCode',{code:productIdCode})
  26. }
  27. })
  28. console.log('商米监听扫码...')
  29. }
  30. }
  31. }
  32. }
  33. // #endif