scan code
This commit is contained in:
@@ -5,7 +5,7 @@ import { SessionDataProviderService } from 'src/app/store/session-data-provider.
|
||||
import { BlogDataService } from 'src/app/store/blog-data.service';
|
||||
import {NavController} from "@ionic/angular";
|
||||
import { AlertController } from '@ionic/angular';
|
||||
import { BarcodeScanner } from '@capacitor-community/barcode-scanner';
|
||||
//import { BarcodeScanner } from '@capacitor-community/barcode-scanner';
|
||||
|
||||
@Component({
|
||||
selector: 'app-familylogin',
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {NavController} from "@ionic/angular";
|
||||
import {AlertController, NavController} from "@ionic/angular";
|
||||
import {Router} from "@angular/router";
|
||||
import { BarcodeScanner } from '@capacitor-community/barcode-scanner';
|
||||
import {WrenchService} from "../../services/wrench.service";
|
||||
import {SessionDataProviderService} from "../../store/session-data-provider.service";
|
||||
import {BlogDataService} from "../../store/blog-data.service";
|
||||
@Component({
|
||||
selector: 'app-startscan',
|
||||
templateUrl: './startscan.page.html',
|
||||
@@ -14,9 +17,14 @@ export class StartscanPage implements OnInit {
|
||||
|
||||
constructor(
|
||||
private navctr: NavController,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
private wrenchService: WrenchService,
|
||||
public sessionDataProviderService:SessionDataProviderService,
|
||||
public blogDataService:BlogDataService,
|
||||
private alertController: AlertController
|
||||
) { }
|
||||
|
||||
loginResult: any;
|
||||
blogResult:any;
|
||||
ngOnInit() {
|
||||
this.startScan();
|
||||
}
|
||||
@@ -26,6 +34,30 @@ export class StartscanPage implements OnInit {
|
||||
this.navctr.back();
|
||||
}
|
||||
|
||||
loginQrData: {
|
||||
username: string, sessionid: string, action: number,login_mode: number
|
||||
};
|
||||
startQRLogin(qrString) {
|
||||
// this.username='Y7P0WW9B05';
|
||||
// this.pin='1234';
|
||||
if (qrString == null || qrString == '' ) {
|
||||
return;
|
||||
}
|
||||
this.loginQrData = { username: qrString, sessionid: 'DUMMY-APP-SESSION-STARTER', action: 11022,login_mode: 1105 }
|
||||
this.wrenchService.loginUser(this.loginQrData).subscribe(
|
||||
loginResult => {
|
||||
this.loginResult = loginResult;
|
||||
console.log("INTERNAL RETURN->" + this.loginResult.internal_return);
|
||||
if (loginResult != null && loginResult.internal_return == 100 && this.sessionDataProviderService.ConstructGlobalSessionData(this.loginResult) == true) {
|
||||
// this.getBlogData();
|
||||
this.router.navigate(['tabs/tab1']);
|
||||
}
|
||||
else{
|
||||
this.showAlert("Error","Unable to use the code to login");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async checkPermission() {
|
||||
try {
|
||||
@@ -59,6 +91,7 @@ export class StartscanPage implements OnInit {
|
||||
if(result?.hasContent) {
|
||||
this.scannedResult = result.content;
|
||||
console.log(this.scannedResult);
|
||||
this.startQRLogin( this.scannedResult );
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
@@ -72,5 +105,15 @@ export class StartscanPage implements OnInit {
|
||||
document.querySelector('body').classList.remove('scanner-active');
|
||||
this.content_visibility = '';
|
||||
}
|
||||
async showAlert(mtitle: string, amessage: string) {
|
||||
const alert = await this.alertController.create({
|
||||
header: 'WrenchBoard',
|
||||
subHeader: mtitle,
|
||||
message: amessage,
|
||||
buttons: ['OK'],
|
||||
});
|
||||
|
||||
await alert.present();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user