You need to sign in or sign up before continuing.
Commit 9dfeb43f by 杨北旺

上传图片格式处理

1 parent 3bb822d9
...@@ -52,7 +52,7 @@ export default { ...@@ -52,7 +52,7 @@ export default {
// 根据手机屏幕宽度计算图片宽度 // 根据手机屏幕宽度计算图片宽度
computedWidth(){ computedWidth(){
const screen = window.screen.width const screen = window.screen.width
const imageW = (screen - (16*2+10*2+6.8256*3))/3 const imageW = (screen - (16*2+10*2+8*3))/3
this.size = `${imageW}px` this.size = `${imageW}px`
}, },
// 获取附件信息 // 获取附件信息
...@@ -95,6 +95,7 @@ export default { ...@@ -95,6 +95,7 @@ export default {
this.currentItem = item this.currentItem = item
}, },
afterRread(file, e) { afterRread(file, e) {
console.log(file,e);
this.uploadImage(file) this.uploadImage(file)
}, },
beforeDelete(file, e) { beforeDelete(file, e) {
...@@ -104,7 +105,11 @@ export default { ...@@ -104,7 +105,11 @@ export default {
// 上传图片 // 上传图片
uploadImage(file) { uploadImage(file) {
const imgFile = file.content const imgFile = file.content
const base64 = file.file.name.split('.')[1] + '@' + imgFile.split(',')[1] console.log(file.file.name);
let fileName = file.file.name
let index = fileName.lastIndexOf(".")
fileName = fileName.substring(index+1,fileName.length);
const base64 = fileName+ '@' + imgFile.split(',')[1]
let para = { let para = {
file: base64, file: base64,
fileType: 'image' fileType: 'image'
...@@ -113,6 +118,8 @@ export default { ...@@ -113,6 +118,8 @@ export default {
upload.uploadImageApi(para).then(res => { upload.uploadImageApi(para).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.uploadFile(res.data) this.uploadFile(res.data)
}else{
this.showToast(res.message)
} }
}) })
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!