|
@@ -1,8 +1,10 @@
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
import { Storage } from '@ionic/storage'
|
|
|
import { UserData } from '../../providers/user-data';
|
|
|
+import { CameraSetting } from '../../providers/camera-photo'
|
|
|
import { commonService } from '../../providers/common.service'
|
|
|
-import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
|
|
+import { Camera } from '@ionic-native/camera/ngx';
|
|
|
+// import { ImagePicker, ImagePickerOptions } from '@ionic-native/image-picker/ngx';
|
|
|
// import { PhotoService, Photo } from '../services/photo.service';
|
|
|
|
|
|
@Component({
|
|
@@ -16,6 +18,8 @@ export class SampleDetailPage implements OnInit {
|
|
|
constructor(
|
|
|
// public photoService: PhotoService,
|
|
|
private camera: Camera,
|
|
|
+ private cameraSetting: CameraSetting,
|
|
|
+ // private imagePicker: ImagePicker,
|
|
|
private storage: Storage,
|
|
|
public commonService: commonService,
|
|
|
public userData: UserData) { }
|
|
@@ -66,21 +70,31 @@ export class SampleDetailPage implements OnInit {
|
|
|
}
|
|
|
|
|
|
takePicture(sample) {
|
|
|
- const options: CameraOptions = {
|
|
|
- quality: 90,
|
|
|
- destinationType: this.camera.DestinationType.DATA_URL,
|
|
|
- encodingType: this.camera.EncodingType.JPEG,
|
|
|
- mediaType: this.camera.MediaType.PICTURE,
|
|
|
- targetWidth: 1800,
|
|
|
- targetHeight: 1350
|
|
|
- // 1500
|
|
|
- }
|
|
|
+ this.showPicture(sample, this.cameraSetting.takePhotoOption)
|
|
|
+ }
|
|
|
+
|
|
|
+ choosePicture(sample) {
|
|
|
+ // const options: ImagePickerOptions = {
|
|
|
+ // maximumImagesCount: 5,
|
|
|
+ // outputType: 1,
|
|
|
+ // width: 1800,
|
|
|
+ // height: 1350,
|
|
|
+ // quality: 90
|
|
|
+ // };
|
|
|
+
|
|
|
+ // this.imagePicker.getPictures(options).then((results) => {
|
|
|
+ // for (var i = 0; i < results.length; i++) {
|
|
|
+ // console.log('Image URI: ' + results[i]);
|
|
|
+ // }
|
|
|
+ // }, (err) => { });
|
|
|
+ this.showPicture(sample, this.cameraSetting.albumOption)
|
|
|
+ }
|
|
|
|
|
|
+ showPicture(sample, options) {
|
|
|
this.camera.getPicture(options).then((imageData) => {
|
|
|
sample.imgList.push(
|
|
|
'data:image/png;base64,' + imageData
|
|
|
)
|
|
|
- // sample.imgUrl = 'data:image/png;base64,' + imageData
|
|
|
if (sample.imageData) {
|
|
|
sample.imageData = sample.imageData + ',' + imageData
|
|
|
} else {
|
|
@@ -103,7 +117,7 @@ export class SampleDetailPage implements OnInit {
|
|
|
for (let j of i['qaIdList']) {
|
|
|
this.userData.deleteSampleQa(j)
|
|
|
}
|
|
|
- if (i.qalog && i.imageData) {
|
|
|
+ if (i.qalog && i.imageData) {
|
|
|
let form = {
|
|
|
sdpId: i.sdpId,
|
|
|
mark: i.qalog,
|
|
@@ -127,7 +141,7 @@ export class SampleDetailPage implements OnInit {
|
|
|
deletePicture(sample, index) {
|
|
|
sample.imgList.splice(index, 1)
|
|
|
let arr = sample.imageData.split(',')
|
|
|
- arr.splice(index,1)
|
|
|
+ arr.splice(index, 1)
|
|
|
sample.imageData = arr.toString()
|
|
|
}
|
|
|
}
|