Commit 4c83d3aa authored by liwei's avatar liwei

修改了oss上传逻辑

parent 69672575
......@@ -365,10 +365,10 @@ import {
} from '@/api/contentManagement/activity'
import { VueEditor } from 'vue2-editor'
import { yesOrNo, enableOrDisable } from '@/utils/allPageData'
import {uploadLocal, uploadPublic} from '@/api/system/ossInfo'
import { uploadLocal, uploadPublic } from '@/api/system/ossInfo'
import 'quill/dist/quill.core.css'
import { getOssUrl } from '@/api/contentManagement/opmArticle'
import axios from 'axios'
export default {
components: {
VueEditor
......@@ -497,18 +497,30 @@ export default {
const formData = new FormData()
formData.append('file', file)
formData.append('temp', 'CmsActivity')
formData.append('bucket', 'cust-91isoft')
formData.append('fileType', file.type)
try {
// 发起上传请求
const response = await uploadPublic(formData)
const businessId = response.data.businessId
// 更新 fileList,保存文件的 URL 和其他信息
this.fileList = [{
url: response.data.url,
businessId: businessId
}]
this.form.pictureId = businessId
this.imageUrl = response.data.url
uploadPublic(formData).then(response => {
axios({
method: 'PUT',
url: response.data.url,
data: file,
headers: {
'Content-Type': file.type
}
}).then(res => {
getOssUrl(response.data.ossInfoId).then(res1 => {
const businessId = response.data.ossInfoId
// 更新 fileList,保存文件的 URL 和其他信息
this.fileList = [{
url: res1.data,
businessId: businessId
}]
this.form.pictureId = businessId
this.imageUrl = res1.data
})
})
})
} catch (error) {
console.error('上传失败:', error)
}
......
......@@ -195,7 +195,7 @@ import { enableOrDisable, typeField } from '@/utils/allPageData'
import commonField from '@/utils/commonField'
import { uploadPublic } from '@/api/system/ossInfo'
import { getOssUrl } from '@/api/contentManagement/opmArticle'
import axios from 'axios'
export default {
name: 'CmsBanner',
data() {
......@@ -443,18 +443,30 @@ export default {
const formData = new FormData()
formData.append('file', file)
formData.append('temp', 'CmsBanner')
formData.append('bucket', 'cust-91isoft')
formData.append('fileType', file.type)
try {
// 发起上传请求
const response = await uploadPublic(formData)
const businessId = response.data.businessId
// 更新 fileList,保存文件的 URL 和其他信息
this.fileList = [{
url: response.data.url,
businessId: businessId
}]
this.form.pictureId = businessId
this.imageUrl = response.data.url
uploadPublic(formData).then(response => {
axios({
method: 'PUT',
url: response.data.url,
data: file,
headers: {
'Content-Type': file.type
}
}).then(res => {
getOssUrl(response.data.ossInfoId).then(res1 => {
const businessId = response.data.ossInfoId
// 更新 fileList,保存文件的 URL 和其他信息
this.fileList = [{
url: res1.data,
businessId: businessId
}]
this.form.pictureId = businessId
this.imageUrl = res1.data
})
})
})
} catch (error) {
console.error('上传失败:', error)
}
......
......@@ -167,7 +167,7 @@ import { yesOrNo, enableOrDisable } from '@/utils/allPageData'
import { uploadPublic } from '@/api/system/ossInfo'
import { getOssUrl } from '@/api/contentManagement/opmArticle'
import 'quill/dist/quill.core.css'
import axios from 'axios'
export default {
components: {
VueEditor
......@@ -307,18 +307,30 @@ export default {
const formData = new FormData()
formData.append('file', file)
formData.append('temp', 'CmsNotice')
formData.append('bucket', 'cust-91isoft')
formData.append('fileType', file.type)
try {
// 发起上传请求
const response = await uploadPublic(formData)
const businessId = response.data.businessId
// 更新 fileList,保存文件的 URL 和其他信息
this.fileList = [{
url: response.data.url,
businessId: businessId
}]
this.form.pictureId = businessId
this.imageUrl = response.data.url
uploadPublic(formData).then(response => {
axios({
method: 'PUT',
url: response.data.url,
data: file,
headers: {
'Content-Type': file.type
}
}).then(res => {
getOssUrl(response.data.ossInfoId).then(res1 => {
const businessId = response.data.ossInfoId
// 更新 fileList,保存文件的 URL 和其他信息
this.fileList = [{
url: res1.data,
businessId: businessId
}]
this.form.pictureId = businessId
this.imageUrl = res1.data
})
})
})
} catch (error) {
console.error('上传失败:', error)
}
......
......@@ -582,7 +582,7 @@ import { getOptions } from '@/utils/options'
import { getMemInfo, getPrivateInfo, updateMemInfo } from '@/api/contentManagement/memInfo'
import { uploadPublic } from '@/api/system/ossInfo'
import { getOssUrl } from '@/api/contentManagement/opmArticle'
import axios from 'axios'
export default {
data() {
return {
......@@ -833,6 +833,7 @@ export default {
getMemInfo(this.$route.query.bussinessId).then(response => {
if (response.code === 200) {
this.form = response.data
console.log('response.data:',response.data)
if (response.data.avatarOpen === null) {
this.form.avatarOpen = 0
}
......@@ -1049,19 +1050,31 @@ export default {
}
const formData = new FormData()
formData.append('file', file)
formData.append('temp', 'CmsNotice')
formData.append('bucket', 'cust-91isoft')
formData.append('temp', 'OpmMember')
formData.append('fileType', file.type)
try {
// 发起上传请求
const response = await uploadPublic(formData)
const businessId = response.data.businessId
// 更新 fileList,保存文件的 URL 和其他信息
this.fileList = [{
url: response.data.url,
businessId: businessId
}]
this.form.avatar = businessId
this.imageUrl = response.data.url
uploadPublic(formData).then(response => {
axios({
method: 'PUT',
url: response.data.url,
data: file,
headers: {
'Content-Type': file.type
}
}).then(res => {
getOssUrl(response.data.ossInfoId).then(res1 => {
const businessId = response.data.ossInfoId
// 更新 fileList,保存文件的 URL 和其他信息
this.fileList = [{
url: res1.data,
businessId: businessId
}]
this.form.avatar = businessId
this.imageUrl = res1.data
})
})
})
} catch (error) {
console.error('上传失败:', error)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment