Commit 15ca1172 authored by zhengke's avatar zhengke

上传图方法

parent c89ea5ab
...@@ -3,7 +3,7 @@ export const domainManager = () => { ...@@ -3,7 +3,7 @@ export const domainManager = () => {
const obj = { const obj = {
domainUrl: locationName.indexOf('oytour') !== -1 ? "http://reborn.oytour.com/api/common/post" : "http://192.168.10.214/api/common/post", domainUrl: locationName.indexOf('oytour') !== -1 ? "http://reborn.oytour.com/api/common/post" : "http://192.168.10.214/api/common/post",
//上传站点 //上传站点
UploadUrl: locationName.indexOf('oytour') !== -1 ? "http://upload.oytour.com" : "http://192.168.10.214:8120", UploadUrl: locationName.indexOf('oytour') !== -1 ? "http://upload.oytour.com" : "http://192.168.5.46:8120",
//文件站点 //文件站点
ViittoFileUrl: locationName.indexOf('oytour') !== -1 ? "http://imgfile.oytour.com" : 'http://192.168.10.214:8130', ViittoFileUrl: locationName.indexOf('oytour') !== -1 ? "http://imgfile.oytour.com" : 'http://192.168.10.214:8130',
// 通知erp // 通知erp
......
import { domainManager } from '@/utils/domainManager'
class AliyunUpload { class AliyunUpload {
static readonly REGION = 'oss-cn-chengdu' static readonly REGION = 'oss-cn-chengdu'
static readonly ACCESS_KEY_ID = 'LTAI5tFgqt1pwnoA35cigYTr' static readonly ACCESS_KEY_ID = 'LTAI5tFgqt1pwnoA35cigYTr'
...@@ -18,12 +18,19 @@ class AliyunUpload { ...@@ -18,12 +18,19 @@ class AliyunUpload {
static UploadAsync = async (file:any,name:string)=>{ static UploadAsync = async (file:any,name:string)=>{
try { try {
const oss = this.GetOSS() let path = "/Sale/Uploadvideo/"
const headers = { const formData = new FormData();
'Cache-Control':'public,max-age=31536000' formData.append('file', file);
}; const response = await fetch(`${domainManager().UploadUrl}/Upload/UploadToALiOSS?filePath=${path}`, {
let result = await oss.put(name,file,{headers}) method: 'POST',
return 'https://im.oytour.com/'+name//result.url body: formData,
});
if(response.ok){
let result = await response.text()
let datas = JSON.parse(result)
return datas.FilePath
}
return ''
} catch (error) { } catch (error) {
return '' return ''
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
placeholder="输入关键字快速查找" clearable placeholder="输入关键字快速查找" clearable
class="input-with-select q-pl-lg" @keyup.enter="SearchHandler()"> class="input-with-select q-pl-lg" @keyup.enter="SearchHandler()">
<template #append> <template #append>
<el-button type="primary" @click="SearchHandler">搜索</el-button> <el-button style="color: #fff;" type="primary" @click="SearchHandler">搜索</el-button>
</template> </template>
</el-input> </el-input>
</el-col> </el-col>
...@@ -44,9 +44,7 @@ ...@@ -44,9 +44,7 @@
<el-pagination <el-pagination
v-model:current-page="currentPage" v-model:current-page="currentPage"
:page-size="datas.queryMsg.pageSize" :page-size="datas.queryMsg.pageSize"
:small="small" small="small"
:disabled="disabled"
:background="background"
layout="prev, pager, next" layout="prev, pager, next"
:total="datas.queryMsg.total" :total="datas.queryMsg.total"
@size-change="handleSizeChange" @size-change="handleSizeChange"
......
...@@ -72,6 +72,7 @@ import { ElLoading, ElMessageBox } from 'element-plus' ...@@ -72,6 +72,7 @@ import { ElLoading, ElMessageBox } from 'element-plus'
import FileService from '@/services/FileService' import FileService from '@/services/FileService'
import { Slide } from '@/types/slides' import { Slide } from '@/types/slides'
import { uniqueId } from 'lodash' import { uniqueId } from 'lodash'
import { useUserStore } from "@/store";
const mainStore = useMainStore() const mainStore = useMainStore()
const slidesStore = useSlidesStore() const slidesStore = useSlidesStore()
...@@ -81,6 +82,7 @@ const { selectedSlidesIndex: _selectedSlidesIndex, thumbnailsFocus } = storeToRe ...@@ -81,6 +82,7 @@ const { selectedSlidesIndex: _selectedSlidesIndex, thumbnailsFocus } = storeToRe
const { slides, currentSlide, slideIndex, layoutSlides, viewportRatio } = storeToRefs(slidesStore) const { slides, currentSlide, slideIndex, layoutSlides, viewportRatio } = storeToRefs(slidesStore)
const { ctrlKeyState, shiftKeyState } = storeToRefs(keyboardStore) const { ctrlKeyState, shiftKeyState } = storeToRefs(keyboardStore)
const { SalesEditor, SalesBack, SalesTripId } = storeToRefs(useSellTemplateStore()) const { SalesEditor, SalesBack, SalesTripId } = storeToRefs(useSellTemplateStore())
const { userInfo } = storeToRefs(useUserStore())
const { slidesLoadLimit } = useLoadSlides() const { slidesLoadLimit } = useLoadSlides()
const TemplateTypeStore = useScreenStore() const TemplateTypeStore = useScreenStore()
...@@ -113,6 +115,12 @@ const searchData = ref({} as any) ...@@ -113,6 +115,12 @@ const searchData = ref({} as any)
datas.DataSource = inject(injectKeyDataSource) datas.DataSource = inject(injectKeyDataSource)
searchData.value = inject(injectKeyTemplate) searchData.value = inject(injectKeyTemplate)
const acquiesceLogo = ref([
'https://im.oytour.com/pptist/static/logo1.png',
'https://im.oytour.com/pptist/static/logo2.png',
'https://im.oytour.com/pptist/static/logo3.png'
])
watch(() => slideIndex.value, () => { watch(() => slideIndex.value, () => {
// 清除多选状态的幻灯片 // 清除多选状态的幻灯片
if (selectedSlidesIndex.value.length) { if (selectedSlidesIndex.value.length) {
...@@ -428,25 +436,41 @@ const GetTripTemplate = async () =>{ ...@@ -428,25 +436,41 @@ const GetTripTemplate = async () =>{
newSlides = SlidesData newSlides = SlidesData
} }
let IDs = [] let IDs = []
newSlides.forEach((x,index)=>{ for(let i=0;i<newSlides.length;i++){
let ids = x.id.split('-') let ids = newSlides[i].id.split('-')
let existId = IDs.findIndex(y=>{ y==x.id }) == -1 let existId = IDs.findIndex(y=>{ y==newSlides[i].id }) == -1
if(existId) IDs.push(x.id) if(existId) IDs.push(newSlides[i].id)
else { else {
//Math.floor(Math.random() * newSlides.length) //Math.floor(Math.random() * newSlides.length)
//Math.floor(Math.random())+index //Math.floor(Math.random())+i
let id = generateUniqueId() let id = generateUniqueId()
x.id = `${ids[0]}-${ids[1]}${id}` x.id = `${ids[0]}-${ids[1]}${id}`
} }
x.elements.forEach(y=>{ newSlides[i].elements.forEach(y=>{
if(x.pageType!=1&&y.TemplateDataSource&&y.TemplateDataSource.index==null){ if(newSlides[i].pageType!=1&&y.TemplateDataSource&&y.TemplateDataSource.index==null){
Reflect.set(y.TemplateDataSource, 'index', null) Reflect.set(y.TemplateDataSource, 'index', null)
} }
}) })
}) }
if(ConfigId.value>0){ if(ConfigId.value>0){
newSlides = newSlides.filter((x:Slide)=>!x.isTripItems) newSlides = newSlides.filter((x:Slide)=>!x.isTripItems)
} }
// 根据集团渲染logo
if(userInfo.value&&userInfo.value.RB_Group_id<=1){
for(let i=0;i<newSlides.length;i++){
let x = newSlides[i]
let index =null
x.elements.forEach((y,indexs)=>{
if(y.layerName && y.layerName=='logo') index = indexs
})
let eles = x.elements.filter(y=>y.layerName && y.layerName=='logo')
let newElements = await ResolveTripLogoHandler(eles,i)
x.elements = x.elements.concat(newElements?.elements)
if(index>=0) x.elements.splice(index,1)
}
}
layoutsStore.setLayouts(JSON.parse(JSON.stringify(newSlides))) layoutsStore.setLayouts(JSON.parse(JSON.stringify(newSlides)))
if(searchData.value.sellId&&!searchData.value.TempId) return if(searchData.value.sellId&&!searchData.value.TempId) return
slidesStore.setSlides(newSlides) slidesStore.setSlides(newSlides)
...@@ -495,6 +519,57 @@ const generateUniqueId = () => { ...@@ -495,6 +519,57 @@ const generateUniqueId = () => {
return '-' + timestamp + '-' + randomNum return '-' + timestamp + '-' + randomNum
} }
const ResolveTripLogoHandler = async (items:any, slideIndex:number) =>{
let elements = []
let tempNewSlide:any = null
let templateObj = JSON.parse(JSON.stringify(items))
for(let i=0;i<templateObj.length;i++){
try {
let y = templateObj[i]
let tempSize = await FileService.getImageSizeWithoutDownloading(templateObj[i].src)
let scale = tempSize.width/tempSize.height
if(scale==1) templateObj[i].src = acquiesceLogo.value[0]
if(scale>1) templateObj[i].src = acquiesceLogo.value[2]
if(scale<1) templateObj[i].src = acquiesceLogo.value[1]
if(tempNewSlide){
tempNewSlide.elements.push(...templateObj)
}else{
elements.push(...templateObj)
tempNewSlide = copySlidHandlerLogo(slideIndex)
}
let newTempSize = await FileService.getImageSizeWithoutDownloading(templateObj[i].src)
let width = 0
let height = 0
//按照宽度进行缩放
let ratio = newTempSize.width / y.width
width = y.width
height = newTempSize.height / ratio
if(height<y.height){
ratio = height / y.height
height = y.height
width = width / ratio
}
y.height = height
y.width = width
} catch (error) {
}
}
return {
elements,
newSlider:tempNewSlide,
}
}
const copySlidHandlerLogo = (slideIndex:number)=>{
let newSlide = JSON.parse(JSON.stringify(slides.value[slideIndex]))
newSlide.id = uniqueId()
newSlide.elements = newSlide.elements.filter((y:any)=>!y.layerName || y.layerName!='logo')
return newSlide
}
// 销售模版数据 // 销售模版数据
const sellGetTripTemplate = async () =>{ const sellGetTripTemplate = async () =>{
try { try {
......
...@@ -679,10 +679,12 @@ ...@@ -679,10 +679,12 @@
const GetTemplateColors = async () => { const GetTemplateColors = async () => {
let pageRes = await LineService.GetTemplateConfigDataList(queryColors.value); let pageRes = await LineService.GetTemplateConfigDataList(queryColors.value);
let colorArr = pageRes.data.data let colorArr = pageRes.data.data
for(let i=0;i<colorArr.length;i++){ if(colorArr.length>0){
if(colorArr[i].Content==queryObj.value.ColorStr) { for(let i=0;i<colorArr.length;i++){
queryColor.value.Code = Number(colorArr[i].Code) if(colorArr[i].Content==queryObj.value.ColorStr) {
getColor() queryColor.value.Code = Number(colorArr[i].Code)
getColor()
}
} }
} }
} }
......
...@@ -235,5 +235,6 @@ watch(isHandleElement, () => { ...@@ -235,5 +235,6 @@ watch(isHandleElement, () => {
} }
.clip-box{ .clip-box{
-webkit-background-clip: text !important; -webkit-background-clip: text !important;
cursor: pointer;
} }
</style> </style>
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