二维码条形码扫描

 1 vm.QRcode = function () {
 2         cordova.plugins.barcodeScanner.scan(
 3             function (result) {
 4                 //alert("We got a barcode\n" +
 5                 //    "Result: " + result.text + "\n" +
 6                 //    "Format: " + result.format + "\n" +
 7                 //    "Cancelled: " + result.cancelled);
 8                 console.log(result.text);
 9                 vm.search = result.text;
10                 document.getElementById('txt_barcode').value = vm.search;
11             },
12             function (error) {
13                 alert("Scanning failed: " + error);
14             }
15         );
16     };
 1             <div class="list">
 2                     <div class="item item-input-inset">
 3                         <label class="item-input-wrapper" style="background-color:#ffffff">
 4                             <input id="txt_barcode" type="text" ng-model="vm.search" placeholder="Barcode/UPC/Description" style="width: 100%;">
 5                         </label>
 6                         <button class="button button-small button-icon icon ion-ios-barcode-outline" ng-click="vm.QRcode()"></button>
 7                     </div>
 8                     <div class="item">
 9                         <button class="button button-block button-positive" ng-click="vm.search1(1)"> <b>Search</b> </button>
10                     </div>
11                 </div>        

 

posted @ 2016-03-10 14:11  fanhq  阅读(261)  评论(0编辑  收藏  举报