var CamareJs = function(){
	console.log('通用第三方的拍照系统');
};
CamareJs.prototype = {
	constructor : CamareJs,
	init : function(opt, flexKey, fileType, cback){
        //return new Promise((resolve, reject) => {
            var arr = flexKey.split(',');
            var farrs = fileType.split('|');
            for(var i=0; i< arr.length; i++) {
                var flexName = arr[i];
                console.log('flexName的值', flexName);
                const outEl = document.createElement('div');
                outEl.className = 'photoBox';
                const inputEl = document.createElement('input');
                inputEl.className = 'inputFile';
                inputEl.type = 'file';
                if(farrs.length>i){
                    inputEl.setAttribute('accept', farrs[i]);
                }else{
                    inputEl.setAttribute('accept', farrs[0]);
                } 
                inputEl.setAttribute('multiple', opt.multiple); 
                const u = navigator.userAgent;
                const isiOS = u.indexOf('iPhone') > -1;
                if(!isiOS ){ 
                    inputEl.setAttribute('capture', 'camera');
                } 
                inputEl.setAttribute('flexName', flexName); 
                outEl.appendChild(inputEl);
                document.getElementById(flexName).appendChild(outEl);
                inputEl.onchange = function(e){
                    const files = e.target.files;
                    console.log('文件个数', files.length);
                    if (files.length == 0) {
                        cback({ errcode: '0001', description: '选择文件不能为空' });
                    } else {
						cback({ errcode: '0000', uploadFile: 'file', inputObj: e, data: files });
                    }
                }
            }
        //})
	}
}