當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript barcode-scanner.BarcodeScanner類代碼示例

本文整理匯總了TypeScript中@ionic-native/barcode-scanner.BarcodeScanner的典型用法代碼示例。如果您正苦於以下問題:TypeScript BarcodeScanner類的具體用法?TypeScript BarcodeScanner怎麽用?TypeScript BarcodeScanner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了BarcodeScanner類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: scanQrCode

  scanQrCode() {
    
    this.barcodeScanner.scan( ).then((barcodeData) => {
      
      if(barcodeData.cancelled || barcodeData.format !== 'QR_CODE') {
        return;
      }
      
      const regex = /kraken:\/\/apikey\?key=(.*?)&secret=(.*)/i;
      // let m = regex.exec(barcodeData.text);

      let output = regex.exec(barcodeData.text);

      if(output) {
        this.apiKey = output[1];
        this.privateKey = output[2];
      }

      this.apiKeyChanged();
      this.privateKeyChanged();
      

    }, (err) => {
        this._displayAlert(err);
    });
  }
開發者ID:wallaceiam,項目名稱:mKraken,代碼行數:26,代碼來源:settings.ts

示例2: scan

 /***
  * 調用二維碼掃描
  * @returns {{codeData: string}}
  */
 scan() {
   return this.barcodeScanner.scan();
   // this.barcodeScanner.scan().then(barcodeData => {
   //   Fun(browserDetection);
   // }).catch(err => {
   //    errorFun(err);
   // });
   // return {
   //   codeData: 'EehM1A6MnVZxs6qH8AEA1pSLeW4RxmqhuU'
   // };
 }
開發者ID:Beethovenw,項目名稱:Elastos.ORG.Wallet.Mobile,代碼行數:15,代碼來源:Native.ts

示例3:

	scanCode() {
		this.barcode.scan().then((barcodeData) => {
			let data = JSON.parse(barcodeData.text);
			this.api.data.url = data.url + "/";
			this.api.data.username = data.username;
			this.api.data.password = "";
			this.api.token = data.token;
			this.api.storage.set("token", data.token);
			this.doLogin();
		}, (err) => {
			this.alert.create({ title: "Oops", subTitle: "Ocurrió un error " + err, buttons: ["Ok"] }).present();
		});
	}
開發者ID:seedgabo,項目名稱:siaphone,代碼行數:13,代碼來源:login.ts

示例4: scanQR

  public scanQR() {
    this.buttonText = "Loading..";
    this.loading = true;

    this._barcodeScanner.scan().then((barcodeData) => {
      if (barcodeData.cancelled) {
        console.log("User cancelled the action!");
        this.buttonText = "Scan";
        this.loading = false;
        return false;
      }
      console.log("Scanned successfully!");
      console.log(barcodeData);
      this.goToResult(barcodeData);
    }, (err) => {
      console.log(err);
    });
  }
開發者ID:cybriz,項目名稱:ionic-projects,代碼行數:18,代碼來源:scan.ts

示例5:

 handler: () => {
   this.barcodeScanner.scan().then((barcodeData) => {
     this.user.accesstoken = barcodeData.text;
     this.userService.PostAccessToken({ accesstoken: this.user.accesstoken }).subscribe((data) => {
       if (data.success) {
         this.user.loginname = data.loginname;
         this.user.avatar_url = data.avatar_url;
         this.events.publish('user', this.user);
         this.storage.set('user', this.user);
         this.navCtrl.push(AccountPage).then(() => {
           let index = this.viewCtrl.index;
           this.navCtrl.remove(index);
         });
         this.utilService.toast('登錄成功');
       }
       else {
         this.utilService.toast('登錄失敗');
       }
     })
   }, (err) => {
     this.alertCtrl.create({
       title: '注意',
       message: '在非手機設備(瀏覽器)時登錄,需填入相關用戶信息,必填!',
       inputs: [
         {
           name: 'loginname',
           placeholder: '用戶名'
         },
         {
           name: 'avatar_url',
           placeholder: '頭像URL',
         },
         {
           name: 'accesstoken',
           placeholder: 'accesstoken',
         }
       ],
       buttons: [
         {
           text: '取消',
           role: 'cancel',
           handler: data => {
           }
         },
         {
           text: '登錄',
           handler: data => {
             if (data.loginname && data.avatar_url && data.accesstoken) {
               this.user.loginname = data.loginname;
               this.user.avatar_url = data.avatar_url;
               this.user.accesstoken = data.accesstoken;
               this.events.publish('user', this.user);
               this.storage.set('user', this.user);
               this.navCtrl.push(AccountPage).then(() => {
                 let index = this.viewCtrl.index;
                 this.navCtrl.remove(index);
               });
             } else {
               return false;
             }
           }
         }
       ]
     }).present();
     console.log(err);
   });
 }
開發者ID:lqxlcc,項目名稱:Ionic2-CNodeClub,代碼行數:67,代碼來源:login.ts


注:本文中的@ionic-native/barcode-scanner.BarcodeScanner類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。