let base64url = '';
let base64 = {
    imageUrlToBase64,
    getBase64Image,
	getbase64url
}
                function imageUrlToBase64(base) { 
				// console.log(base,1);
				var that =this
				let imgUrl = base;
				var img = document.createElement('img');
				img.src = imgUrl;
				//设置图片跨域访问
				img.crossOrigin = 'anonymous',
				// console.log(img);
				img.onload = function () {
				   var dataImg = that.getBase64Image(img);
				   var img1 = document.createElement('img');
				   var imgInsert = document.getElementById('imgInsert')
				   img1.src = dataImg;
				   document.body.appendChild(img1);
				   console.log(dataImg);
				   base64url = dataImg;
				}
			}
			function getbase64url(){
				return base64url;
			}
			function getBase64Image(img) {
			   // console.log(img);
			   var canvas = document.createElement("canvas");
			   console.log(canvas);
			   canvas.width = img.width;
			   canvas.height = img.height;
			   var ctx = canvas.getContext("2d");
			   ctx.drawImage(img, 0, 0, img.width, img.height);
			   var dataURL = canvas.toDataURL("image/png");
			   // console.log(dataURL);
			   return dataURL
			}
module.exports = base64