当前位置: 首页>>代码示例>>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;未经允许,请勿转载。