/* * @Createdby: Microsoft Visual Code * @Author: ferried * @Email: harlancui@outlook.com * @LastEditors: ferried * @Version: 1.0.0-SNAPSHOT * @Description: none * @Date: 2019-05-08 15:15:17 * @LastEditTime: 2019-05-15 14:48:57 */ import { Component, OnInit } from '@angular/core'; import { DeviceService, NavigationBar, UserLocation, UserService } from 'ng-yunzai-mobile'; import { IWindowType, TokenService } from 'ng-yunzai-mobile'; import { HttpClient } from '@angular/common/http'; import {from, Observable} from 'rxjs'; declare let yz; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.less'] }) export class AppComponent implements OnInit { constructor( private device: DeviceService, private tokenService: TokenService, private userService: UserService, private http: HttpClient ) { } ngOnInit(): void { } userLocation(): void { this.device.native.userLocation().subscribe((userLocation: UserLocation) => { alert(userLocation.address); alert(userLocation.latitude); alert(userLocation.longitude); }); } validateInWifi(): void { this.device.native.validateInWifi(['1', '3', 'this is mac adrress']).subscribe((is: boolean) => { alert(is); }); } getWifiMac(): void { this.device.native.getWifiMac().subscribe((macAddress: string) => { alert(macAddress); }); } setNavgationBar(): void { const some: NavigationBar = { showMenu: true, shareFlag: true, items: [{ title: 'a', type: 'icon', icon: 'add', clickId: 'delete' }], onClick(id: string) { console.log(id); } }; this.device.native.setNavigationBar(some); } scanQrCode(): void { this.device.native.scanCode().subscribe((code: string) => { console.log(code); }); } setShare() { this.device.native.share({ shareFlag: true }); } setTitle() { this.device.native.setTitle({ title: '测试啊', }); } getToken() { this.device.native.getToken(); } openWindow() { this.device.native.openWindow({ nBack: true, type: IWindowType.URL, url: 'http://www.baidu.com', success(success) { console.log(success); }, fail(fail) { console.log(fail); }, complete(msg) { console.log(msg); }, listener() { alert('1'); } }); } /** * 联系人详情 */ contactDetails() { const userId = this.userService.get().userId; this.device.native.contactDetails(userId).subscribe((data: any) => { }); } }