Commit 15ca1172 authored by zhengke's avatar zhengke

上传图方法

parent c89ea5ab
......@@ -3,7 +3,7 @@ export const domainManager = () => {
const obj = {
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',
// 通知erp
......
import { domainManager } from '@/utils/domainManager'
class AliyunUpload {
static readonly REGION = 'oss-cn-chengdu'
static readonly ACCESS_KEY_ID = 'LTAI5tFgqt1pwnoA35cigYTr'
......@@ -18,12 +18,19 @@ class AliyunUpload {
static UploadAsync = async (file:any,name:string)=>{
try {
const oss = this.GetOSS()
const headers = {
'Cache-Control':'public,max-age=31536000'
};
let result = await oss.put(name,file,{headers})
return 'https://im.oytour.com/'+name//result.url
let path = "/Sale/Uploadvideo/"
const formData = new FormData();
formData.append('file', file);
const response = await fetch(`${domainManager().UploadUrl}/Upload/UploadToALiOSS?filePath=${path}`, {
method: 'POST',
body: formData,
});
if(response.ok){
let result = await response.text()
let datas = JSON.parse(result)
return datas.FilePath
}
return ''
} catch (error) {
return ''
}
......
......@@ -23,7 +23,7 @@
placeholder="输入关键字快速查找" clearable
class="input-with-select q-pl-lg" @keyup.enter="SearchHandler()">
<template #append>
<el-button type="primary" @click="SearchHandler">搜索</el-button>
<el-button style="color: #fff;" type="primary" @click="SearchHandler">搜索</el-button>
</template>
</el-input>
</el-col>
......@@ -44,9 +44,7 @@
<el-pagination
v-model:current-page="currentPage"
:page-size="datas.queryMsg.pageSize"
:small="small"
:disabled="disabled"
:background="background"
small="small"
layout="prev, pager, next"
:total="datas.queryMsg.total"
@size-change="handleSizeChange"
......
......@@ -72,6 +72,7 @@ import { ElLoading, ElMessageBox } from 'element-plus'
import FileService from '@/services/FileService'
import { Slide } from '@/types/slides'
import { uniqueId } from 'lodash'
import { useUserStore } from "@/store";
const mainStore = useMainStore()
const slidesStore = useSlidesStore()
......@@ -81,6 +82,7 @@ const { selectedSlidesIndex: _selectedSlidesIndex, thumbnailsFocus } = storeToRe
const { slides, currentSlide, slideIndex, layoutSlides, viewportRatio } = storeToRefs(slidesStore)
const { ctrlKeyState, shiftKeyState } = storeToRefs(keyboardStore)
const { SalesEditor, SalesBack, SalesTripId } = storeToRefs(useSellTemplateStore())
const { userInfo } = storeToRefs(useUserStore())
const { slidesLoadLimit } = useLoadSlides()
const TemplateTypeStore = useScreenStore()
......@@ -113,6 +115,12 @@ const searchData = ref({} as any)
datas.DataSource = inject(injectKeyDataSource)
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, () => {
// 清除多选状态的幻灯片
if (selectedSlidesIndex.value.length) {
......@@ -428,25 +436,41 @@ const GetTripTemplate = async () =>{
newSlides = SlidesData
}
let IDs = []
newSlides.forEach((x,index)=>{
let ids = x.id.split('-')
let existId = IDs.findIndex(y=>{ y==x.id }) == -1
if(existId) IDs.push(x.id)
for(let i=0;i<newSlides.length;i++){
let ids = newSlides[i].id.split('-')
let existId = IDs.findIndex(y=>{ y==newSlides[i].id }) == -1
if(existId) IDs.push(newSlides[i].id)
else {
//Math.floor(Math.random() * newSlides.length)
//Math.floor(Math.random())+index
//Math.floor(Math.random())+i
let id = generateUniqueId()
x.id = `${ids[0]}-${ids[1]}${id}`
}
x.elements.forEach(y=>{
if(x.pageType!=1&&y.TemplateDataSource&&y.TemplateDataSource.index==null){
newSlides[i].elements.forEach(y=>{
if(newSlides[i].pageType!=1&&y.TemplateDataSource&&y.TemplateDataSource.index==null){
Reflect.set(y.TemplateDataSource, 'index', null)
}
})
})
}
if(ConfigId.value>0){
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)))
if(searchData.value.sellId&&!searchData.value.TempId) return
slidesStore.setSlides(newSlides)
......@@ -495,6 +519,57 @@ const generateUniqueId = () => {
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 () =>{
try {
......
......@@ -679,10 +679,12 @@
const GetTemplateColors = async () => {
let pageRes = await LineService.GetTemplateConfigDataList(queryColors.value);
let colorArr = pageRes.data.data
for(let i=0;i<colorArr.length;i++){
if(colorArr[i].Content==queryObj.value.ColorStr) {
queryColor.value.Code = Number(colorArr[i].Code)
getColor()
if(colorArr.length>0){
for(let i=0;i<colorArr.length;i++){
if(colorArr[i].Content==queryObj.value.ColorStr) {
queryColor.value.Code = Number(colorArr[i].Code)
getColor()
}
}
}
}
......
......@@ -235,5 +235,6 @@ watch(isHandleElement, () => {
}
.clip-box{
-webkit-background-clip: text !important;
cursor: pointer;
}
</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