|
@@ -4,7 +4,8 @@ import { UserData } from '../../providers/user-data';
|
|
import { CameraSetting } from '../../providers/camera-photo'
|
|
import { CameraSetting } from '../../providers/camera-photo'
|
|
import { commonService } from '../../providers/common.service'
|
|
import { commonService } from '../../providers/common.service'
|
|
import { Camera } from '@ionic-native/camera/ngx';
|
|
import { Camera } from '@ionic-native/camera/ngx';
|
|
-// import { ImagePicker, ImagePickerOptions } from '@ionic-native/image-picker/ngx';
|
|
|
|
|
|
+import { ImagePicker, ImagePickerOptions } from '@ionic-native/image-picker/ngx';
|
|
|
|
+import { Base64 } from '@ionic-native/base64/ngx';
|
|
// import { PhotoService, Photo } from '../services/photo.service';
|
|
// import { PhotoService, Photo } from '../services/photo.service';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
@@ -17,9 +18,10 @@ export class SampleDetailPage implements OnInit {
|
|
public photos = [];
|
|
public photos = [];
|
|
constructor(
|
|
constructor(
|
|
// public photoService: PhotoService,
|
|
// public photoService: PhotoService,
|
|
|
|
+ private base64: Base64,
|
|
private camera: Camera,
|
|
private camera: Camera,
|
|
private cameraSetting: CameraSetting,
|
|
private cameraSetting: CameraSetting,
|
|
- // private imagePicker: ImagePicker,
|
|
|
|
|
|
+ private imagePicker: ImagePicker,
|
|
private storage: Storage,
|
|
private storage: Storage,
|
|
public commonService: commonService,
|
|
public commonService: commonService,
|
|
public userData: UserData) { }
|
|
public userData: UserData) { }
|
|
@@ -73,20 +75,32 @@ export class SampleDetailPage implements OnInit {
|
|
}
|
|
}
|
|
|
|
|
|
choosePicture(sample) {
|
|
choosePicture(sample) {
|
|
- // const options: ImagePickerOptions = {
|
|
|
|
- // maximumImagesCount: 5,
|
|
|
|
- // outputType: 1,
|
|
|
|
- // width: 1800,
|
|
|
|
- // height: 1350,
|
|
|
|
- // quality: 90
|
|
|
|
- // };
|
|
|
|
|
|
+ const options: ImagePickerOptions = {
|
|
|
|
+ maximumImagesCount: 10,
|
|
|
|
+ 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)
|
|
|
|
|
|
+ this.imagePicker.getPictures(options).then((results) => {
|
|
|
|
+ for (var i = 0; i < results.length; i++) {
|
|
|
|
+ this.base64.encodeFile(results[i]).then((base64File: string) => {
|
|
|
|
+ sample.imgList.push(
|
|
|
|
+ base64File
|
|
|
|
+ )
|
|
|
|
+ let imageData = base64File.split('base64,')[1]
|
|
|
|
+ if (sample.imageData) {
|
|
|
|
+ sample.imageData = sample.imageData + ',' + imageData
|
|
|
|
+ } else {
|
|
|
|
+ sample.imageData = '' + imageData
|
|
|
|
+ }
|
|
|
|
+ }, (err) => {
|
|
|
|
+ console.log(err);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }, (err) => { });
|
|
|
|
+ // this.showPicture(sample, this.cameraSetting.albumOption)
|
|
}
|
|
}
|
|
|
|
|
|
showPicture(sample, options) {
|
|
showPicture(sample, options) {
|