12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { Injectable } from "@angular/core"
- import { PhotoViewer } from '@ionic-native/photo-viewer/ngx';
- import { HTTP } from '@ionic-native/http/ngx'
- @Injectable({
- providedIn: 'root'
- })
- export class commonService {
- constructor(private photoViewer: PhotoViewer, private http: HTTP) { }
- fullScreenImg(data) {
- if (typeof data === 'string') {
- this.photoViewer.show(data)
- } else {
- this.photoViewer.show(data.pictures[0].bigPicture);
- }
- }
- convertBase64(url) {
- this.http.get(url, {}, { 'responseType': 'blob' })
- .then(data => {
- console.log(data.status);
- console.log(data.data); // data received by server
- console.log(data.headers);
- })
- .catch(error => {
- console.log(error.status);
- console.log(error.error); // error message as string
- console.log(error.headers);
- });
- }
- getFormatDate = (date) => {
- let currentdate
- if (date) {
- let seperator1 = "-";
- let year = date.getFullYear();
- let month = date.getMonth() + 1;
- let strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- currentdate = year + seperator1 + month + seperator1 + strDate
- }
- return currentdate;
- }
- // toDataUrl(url, callback) {
- // var xhr = new XMLHttpRequest();
- // xhr.onload = function () {
- // var reader = new FileReader();
- // reader.onloadend = function () {
- // callback(reader.result);
- // }
- // reader.readAsDataURL(xhr.response);
- // };
- // xhr.open('GET', url);
- // xhr.responseType = 'blob';
- // xhr.send();
- // }
- }
|