|
@@ -435,6 +435,15 @@ var app = new Vue({
|
|
|
dataBlobtoFile: function (dataurl, filename) {//将base64转换为文件
|
|
dataBlobtoFile: function (dataurl, filename) {//将base64转换为文件
|
|
|
return new File([dataurl], filename, {type: 'image/jpeg'});
|
|
return new File([dataurl], filename, {type: 'image/jpeg'});
|
|
|
},
|
|
},
|
|
|
|
|
+ //
|
|
|
|
|
+ dataURLtoBlob: function(dataurl) {
|
|
|
|
|
+ var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
|
|
|
|
|
+ bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
|
|
|
|
+ while (n--) {
|
|
|
|
|
+ u8arr[n] = bstr.charCodeAt(n);
|
|
|
|
|
+ }
|
|
|
|
|
+ return new Blob([u8arr], {type: mime});
|
|
|
|
|
+ },
|
|
|
// 删除图片
|
|
// 删除图片
|
|
|
picDel: function (id) {
|
|
picDel: function (id) {
|
|
|
var fileId = $("#pic_" + id).attr('data-id');
|
|
var fileId = $("#pic_" + id).attr('data-id');
|
|
@@ -662,19 +671,23 @@ var app = new Vue({
|
|
|
var url = canvas.toDataURL('image/jepg');
|
|
var url = canvas.toDataURL('image/jepg');
|
|
|
var timestamp = Date.parse(new Date());
|
|
var timestamp = Date.parse(new Date());
|
|
|
var name = timestamp + ".jpg";
|
|
var name = timestamp + ".jpg";
|
|
|
- alert(33)
|
|
|
|
|
|
|
+ alert(url)
|
|
|
if(_this.cropParams.type>0 && id>=0){
|
|
if(_this.cropParams.type>0 && id>=0){
|
|
|
alert(34)
|
|
alert(34)
|
|
|
_this.picList[id] = _this.cropParams;
|
|
_this.picList[id] = _this.cropParams;
|
|
|
_this.picList[id].url = url;
|
|
_this.picList[id].url = url;
|
|
|
_this.picList[id].preview = url;
|
|
_this.picList[id].preview = url;
|
|
|
|
|
|
|
|
|
|
+ var blob = _this.dataURLtoBlob(url);
|
|
|
|
|
+ _this.picList[id].fileData = _this.dataBlobtoFile(blob, name);
|
|
|
// _this.picList[id].fileData = _this.dataURLtoFile(url, name);
|
|
// _this.picList[id].fileData = _this.dataURLtoFile(url, name);
|
|
|
}else{
|
|
}else{
|
|
|
alert(341)
|
|
alert(341)
|
|
|
var data = _this.cropParams;
|
|
var data = _this.cropParams;
|
|
|
data.url = url;
|
|
data.url = url;
|
|
|
data.preview = url;
|
|
data.preview = url;
|
|
|
|
|
+ var blob = _this.dataURLtoBlob(url);
|
|
|
|
|
+ _this.picList[id].fileData = _this.dataBlobtoFile(blob, name);
|
|
|
// data.fileData = _this.dataURLtoFile(url, name);
|
|
// data.fileData = _this.dataURLtoFile(url, name);
|
|
|
_this.picList.push(data);
|
|
_this.picList.push(data);
|
|
|
}
|
|
}
|