Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pptist
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
pptist
Commits
702228f2
Commit
702228f2
authored
May 23, 2024
by
罗超
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'router' of
http://gitlab.oytour.com/viitto/pptist
into router
parents
eae0d90f
11b15a34
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
473 additions
and
81 deletions
+473
-81
colorExtraction.ts
src/utils/colorExtraction.ts
+236
-0
common.ts
src/utils/common.ts
+5
-0
AutoLogin.vue
src/views/Auth/AutoLogin.vue
+7
-1
index.vue
src/views/Editor/Thumbnails/index.vue
+96
-31
PreviewCover.vue
src/views/Preview/PreviewCover.vue
+89
-22
Index.vue
src/views/TemplateCenter/Index.vue
+31
-18
colour.vue
src/views/TemplateCenter/colour.vue
+3
-3
font.vue
src/views/TemplateCenter/font.vue
+3
-3
nation.vue
src/views/TemplateCenter/nation.vue
+3
-3
No files found.
src/utils/colorExtraction.ts
0 → 100644
View file @
702228f2
/**
* 颜色盒子类
*
* @param {Array} colorRange [[rMin, rMax],[gMin, gMax], [bMin, bMax]] 颜色范围
* @param {any} total 像素总数, imageData / 4
* @param {any} data 像素数据集合
*/
class
ColorBox
{
colorRange
:
unknown
[];
total
:
number
;
data
:
Uint8ClampedArray
;
volume
:
number
;
rank
:
number
;
constructor
(
colorRange
:
any
[],
total
:
number
,
data
:
Uint8ClampedArray
)
{
this
.
colorRange
=
colorRange
;
this
.
total
=
total
;
this
.
data
=
data
;
this
.
volume
=
(
colorRange
[
0
][
1
]
-
colorRange
[
0
][
0
])
*
(
colorRange
[
1
][
1
]
-
colorRange
[
1
][
0
])
*
(
colorRange
[
2
][
1
]
-
colorRange
[
2
][
0
]);
this
.
rank
=
total
*
this
.
volume
;
}
getColor
()
{
const
total
=
this
.
total
;
const
data
=
this
.
data
;
let
redCount
=
0
,
greenCount
=
0
,
blueCount
=
0
;
for
(
let
i
=
0
;
i
<
total
;
i
++
)
{
redCount
+=
data
[
i
*
4
];
greenCount
+=
data
[
i
*
4
+
1
];
blueCount
+=
data
[
i
*
4
+
2
];
}
return
[
redCount
/
total
,
greenCount
/
total
,
blueCount
/
total
];
}
}
// 获取切割边
const
getCutSide
=
(
colorRange
:
number
[][])
=>
{
// r:0,g:1,b:2
const
arr
=
[];
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
arr
.
push
(
colorRange
[
i
][
1
]
-
colorRange
[
i
][
0
]);
}
return
arr
.
indexOf
(
Math
.
max
(
arr
[
0
],
arr
[
1
],
arr
[
2
]));
}
// 切割颜色范围
const
cutRange
=
(
colorRange
:
number
[][],
colorSide
:
number
,
cutValue
:
any
)
=>
{
const
arr1
:
number
[][]
=
[];
const
arr2
:
number
[][]
=
[];
colorRange
.
forEach
(
function
(
item
)
{
arr1
.
push
(
item
.
slice
());
arr2
.
push
(
item
.
slice
());
})
arr1
[
colorSide
][
1
]
=
cutValue
;
arr2
[
colorSide
][
0
]
=
cutValue
;
return
[
arr1
,
arr2
];
}
// 找到出现次数为中位数的颜色
const
__quickSort
=
(
arr
:
any
[]):
any
=>
{
if
(
arr
.
length
<=
1
)
{
return
arr
;
}
const
pivotIndex
=
Math
.
floor
(
arr
.
length
/
2
);
const
pivot
=
arr
.
splice
(
pivotIndex
,
1
)[
0
];
const
left
=
[];
const
right
=
[];
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
].
count
<=
pivot
.
count
)
{
left
.
push
(
arr
[
i
]);
}
else
{
right
.
push
(
arr
[
i
]);
}
}
return
__quickSort
(
left
).
concat
([
pivot
],
__quickSort
(
right
));
}
const
getMedianColor
=
(
colorCountMap
:
Record
<
string
,
number
>
,
total
:
number
)
=>
{
const
arr
=
[];
for
(
const
key
in
colorCountMap
)
{
arr
.
push
({
color
:
parseInt
(
key
),
count
:
colorCountMap
[
key
]
})
}
const
sortArr
=
__quickSort
(
arr
);
let
medianCount
=
0
;
const
medianIndex
=
Math
.
floor
(
sortArr
.
length
/
2
)
for
(
let
i
=
0
;
i
<=
medianIndex
;
i
++
)
{
medianCount
+=
sortArr
[
i
].
count
;
}
return
{
color
:
parseInt
(
sortArr
[
medianIndex
].
color
),
count
:
medianCount
}
}
// 切割颜色盒子
const
cutBox
=
(
colorBox
:
{
colorRange
:
number
[][];
total
:
number
;
data
:
Uint8ClampedArray
})
=>
{
const
colorRange
=
colorBox
.
colorRange
;
const
cutSide
=
getCutSide
(
colorRange
);
const
colorCountMap
:
Record
<
string
,
number
>
=
{};
const
total
=
colorBox
.
total
;
const
data
=
colorBox
.
data
;
// 统计出各个值的数量
for
(
let
i
=
0
;
i
<
total
;
i
++
)
{
const
color
=
data
[
i
*
4
+
cutSide
];
if
(
colorCountMap
[
color
])
{
colorCountMap
[
color
]
+=
1
;
}
else
{
colorCountMap
[
color
]
=
1
;
}
}
const
medianColor
=
getMedianColor
(
colorCountMap
,
total
);
const
cutValue
=
medianColor
.
color
;
const
cutCount
=
medianColor
.
count
;
const
newRange
=
cutRange
(
colorRange
,
cutSide
,
cutValue
);
const
box1
=
new
ColorBox
(
newRange
[
0
],
cutCount
,
data
.
slice
(
0
,
cutCount
*
4
));
const
box2
=
new
ColorBox
(
newRange
[
1
],
total
-
cutCount
,
data
.
slice
(
cutCount
*
4
));
return
[
box1
,
box2
];
}
// 队列切割
const
queueCut
=
(
queue
:
any
[],
num
:
number
)
=>
{
while
(
queue
.
length
<
num
)
{
queue
.
sort
((
a
:
{
rank
:
number
},
b
:
{
rank
:
number
})
=>
{
return
a
.
rank
-
b
.
rank
});
const
colorBox
=
queue
.
pop
();
const
result
=
cutBox
(
colorBox
);
queue
=
queue
.
concat
(
result
);
}
return
queue
.
slice
(
0
,
num
)
}
// 颜色去重
const
colorFilter
=
(
colorArr
:
number
[][],
difference
:
number
)
=>
{
for
(
let
i
=
0
;
i
<
colorArr
.
length
;
i
++
)
{
for
(
let
j
=
i
+
1
;
j
<
colorArr
.
length
;
j
++
)
{
if
(
Math
.
abs
(
colorArr
[
i
][
0
]
-
colorArr
[
j
][
0
])
<
difference
&&
Math
.
abs
(
colorArr
[
i
][
1
]
-
colorArr
[
j
][
1
])
<
difference
&&
Math
.
abs
(
colorArr
[
i
][
2
]
-
colorArr
[
j
][
2
])
<
difference
)
{
colorArr
.
splice
(
j
,
1
)
j
--
}
}
}
return
colorArr
}
/**
* 提取颜色
* @param colorNumber 提取最大颜色数量
* @param img 需要提取的图片
* @param difference 图片颜色筛选精准度
* @param callback 回调函数
*/
const
themeColor
=
(
colorNumber
:
number
,
img
:
CanvasImageSource
,
difference
:
number
,
callback
:
(
arg0
:
number
[][])
=>
void
)
=>
{
const
canvas
=
document
.
createElement
(
'canvas'
)
as
HTMLCanvasElement
;
const
ctx
=
canvas
.
getContext
(
'2d'
)
as
CanvasRenderingContext2D
;
let
width
=
0
let
height
=
0
let
imageData
=
null
canvas
.
width
=
img
.
width
as
number
;
width
=
canvas
.
width
as
number
canvas
.
height
=
img
.
height
as
number
height
=
canvas
.
height
ctx
.
drawImage
(
img
,
0
,
0
,
width
,
height
);
imageData
=
ctx
.
getImageData
(
0
,
0
,
width
,
height
).
data
;
const
total
=
imageData
.
length
/
4
;
let
rMin
=
255
,
rMax
=
0
,
gMin
=
255
,
gMax
=
0
,
bMin
=
255
,
bMax
=
0
;
// 获取范围
for
(
let
i
=
0
;
i
<
total
;
i
++
)
{
const
red
=
imageData
[
i
*
4
];
const
green
=
imageData
[
i
*
4
+
1
];
const
blue
=
imageData
[
i
*
4
+
2
];
if
(
red
<
rMin
)
{
rMin
=
red
;
}
if
(
red
>
rMax
)
{
rMax
=
red
;
}
if
(
green
<
gMin
)
{
gMin
=
green
;
}
if
(
green
>
gMax
)
{
gMax
=
green
;
}
if
(
blue
<
bMin
)
{
bMin
=
blue
;
}
if
(
blue
>
bMax
)
{
bMax
=
blue
;
}
}
const
colorRange
=
[[
rMin
,
rMax
],
[
gMin
,
gMax
],
[
bMin
,
bMax
]];
const
colorBox
=
new
ColorBox
(
colorRange
,
total
,
imageData
);
const
colorBoxArr
=
queueCut
([
colorBox
],
colorNumber
);
let
colorArr
=
[];
for
(
let
j
=
0
;
j
<
colorBoxArr
.
length
;
j
++
)
{
colorBoxArr
[
j
].
total
&&
colorArr
.
push
(
colorBoxArr
[
j
].
getColor
())
}
colorArr
=
colorFilter
(
colorArr
,
difference
)
callback
(
colorArr
);
}
export
default
themeColor
src/utils/common.ts
View file @
702228f2
import
{
array
}
from
'@amcharts/amcharts4/core'
import
{
padStart
}
from
'lodash'
/**
...
...
@@ -184,4 +185,8 @@ export const DominantColour = () =>{
{
ColorName
:
'黑'
,
ColorValue
:
'#000000'
,
Id
:
11
},
{
ColorName
:
'灰'
,
ColorValue
:
'#BABABA'
,
Id
:
12
},
]
}
export
const
getRgbLevel
=
(
colorarr
:
any
)
=>
{
return
colorarr
[
0
]
*
0.299
+
colorarr
[
1
]
*
0.587
+
colorarr
[
2
]
*
0.114
}
\ No newline at end of file
src/views/Auth/AutoLogin.vue
View file @
702228f2
...
...
@@ -32,7 +32,13 @@ const userLoginHandler = async ()=>{
router
.
push
({
path
:
`/market`
})
}
else
{
}
else
if
(
forword
&&
forword
!=
''
&&
forword
.
toLocaleLowerCase
().
indexOf
(
'previewcover'
)){
router
.
push
({
path
:
forword
})
}
else
{
router
.
push
({
path
:
"/space"
})
...
...
src/views/Editor/Thumbnails/index.vue
View file @
702228f2
...
...
@@ -45,11 +45,18 @@
<div
class=
"page-number"
>
幻灯片 {{slideIndex + 1}} / {{slides.length}}
</div>
</div>
<!-- <div style="position: fixed;left: 200px;top: -100px;opacity: 0;">
<canvas style="display: none" id="canvas"></canvas>
<div
id="extract-color-id"
class="extract-color"
style="display: flex;padding: 0 20px; justify-content:end;">
</div>
</div> -->
</template>
<
script
lang=
"ts"
setup
>
import
{
computed
,
nextTick
,
ref
,
reactive
,
watch
,
inject
}
from
'vue'
import
{
computed
,
nextTick
,
ref
,
reactive
,
watch
,
inject
,
onMounted
}
from
'vue'
import
{
storeToRefs
}
from
'pinia'
import
{
useMainStore
,
useSlidesStore
,
useKeyboardStore
,
useScreenStore
,
useSellTemplateStore
}
from
'@/store'
import
{
fillDigit
}
from
'@/utils/common'
...
...
@@ -60,7 +67,7 @@ import useScreening from '@/hooks/useScreening'
import
useLoadSlides
from
'@/hooks/useLoadSlides'
import
{
injectKeyDataSource
,
injectKeyTemplate
}
from
'@/types/injectKey'
import
ConfigService
from
'@/services/ConfigService'
import
{
getHtmlPlainText
,
query
}
from
'@/utils/common'
import
{
getHtmlPlainText
,
query
,
getRgbLevel
}
from
'@/utils/common'
import
useEditor
from
'@/utils/Editor/index'
import
{
VIEWPORT_SIZE
,
VIEWPORT_VER_SIZE
}
from
'@/configs/canvas'
...
...
@@ -73,6 +80,7 @@ import FileService from '@/services/FileService'
import
{
Slide
}
from
'@/types/slides'
import
{
uniqueId
}
from
'lodash'
import
{
useUserStore
}
from
"@/store"
;
import
themeColor
from
'@/utils/colorExtraction'
;
const
mainStore
=
useMainStore
()
const
slidesStore
=
useSlidesStore
()
...
...
@@ -119,9 +127,14 @@ 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'
,
'https://im.oytour.com/pptist/static/logo4.png'
'https://im.oytour.com/pptist/static/logo4.png'
,
'https://im.oytour.com/pptist/static/logo5.png'
,
'https://im.oytour.com/pptist/static/logo6.png'
,
])
const
tempDatas
=
({}
as
any
)
const
colorList
=
ref
([]
as
any
)
watch
(()
=>
slideIndex
.
value
,
()
=>
{
// 清除多选状态的幻灯片
if
(
selectedSlidesIndex
.
value
.
length
)
{
...
...
@@ -412,6 +425,17 @@ const GetTripTemplate = async () =>{
else
if
(
TempId
.
value
)
queryMsg
.
TempId
=
TempId
.
value
let
dataRes
=
await
ConfigService
.
GetTripTemplateSlide
(
queryMsg
);
if
(
dataRes
.
data
.
resultCode
==
1
)
{
// colorList.value = []
tempDatas
.
value
=
dataRes
.
data
.
data
// for(let i=0;i
<
tempDatas
.
value
.
PageImageList
.
length
;
i
++
){
// const img = new Image();
// img.src = `${tempDatas.value.PageImageList[i]}`;
// img.crossOrigin = 'anonymous';
// img.onload = () => {
// themeColor(1, img, 20, SetColor);
// };
// }
if
(
SalesBack
.
value
==
0
||
(
SalesBack
.
value
==
1
&&
searchData
.
value
.
TempId
)){
let
viewportRatios
=
0
if
(
dataRes
.
data
.
data
.
TemplateType
!=
2
)
{
...
...
@@ -457,28 +481,8 @@ const GetTripTemplate = async () =>{
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
.
indexOf
(
'logo'
)
!=-
1
)
index
=
indexs
})
let
eles
=
x
.
elements
.
filter
(
y
=>
y
.
layerName
&&
y
.
layerName
.
indexOf
(
'logo'
)
!=-
1
)
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
)
CoverImgStore
.
setCoverImg
(
dataRes
.
data
.
data
.
CoverImg
)
slidesStore
.
updateSlideIndex
(
0
)
datas
.
DataSource
.
pageType
=
newSlides
[
0
].
pageType
if
(
SalesBack
.
value
==
0
)
slidesStore
.
setTitle
(
dataRes
.
data
.
data
.
Title
)
getColorShade
(
newSlides
)
}
queryObj
.
value
.
TempId
=
dataRes
.
data
.
data
.
TempId
...
...
@@ -519,18 +523,56 @@ const generateUniqueId = () => {
return
'-'
+
timestamp
+
'-'
+
randomNum
}
const
ResolveTripLogoHandler
=
async
(
items
:
any
,
slideIndex
:
number
)
=>
{
// 获取是否深色
const
getColorShade
=
async
(
newSlides
:
any
)
=>
{
let
dark
=
false
// 根据集团渲染logo
// if(tempDatas.value.AuthType
<=
1
){
// for(let j=0;j
<
colorList
.
value
.
length
;
j
++
){
// if (getRgbLevel(colorList.value[j].Color) > 50) dark = true
// }
// for(let i=0;i
<
newSlides
.
length
;
i
++
){
// if(i>colorList.value.length-2) dark = false
// let x = newSlides[i]
// let eles = x.elements.filter(y=>y.layerName && y.layerName.indexOf('logo')!=-1)
// let newElementsImg = await ResolveTripLogoHandler(eles,i,dark)
// let newElements = []
// x.elements.forEach(y=>{
// if(newElementsImg?.elements){
// newElementsImg?.elements.forEach(z=>{
// if(y.id==z.id) y = JSON.parse(JSON.stringify(z))
// })
// }
// newElements.push(y)
// })
// x.elements = newElements
// }
// }
layoutsStore
.
setLayouts
(
JSON
.
parse
(
JSON
.
stringify
(
newSlides
)))
if
(
searchData
.
value
.
sellId
&&!
searchData
.
value
.
TempId
)
return
slidesStore
.
setSlides
(
newSlides
)
CoverImgStore
.
setCoverImg
(
tempDatas
.
value
.
CoverImg
)
slidesStore
.
updateSlideIndex
(
0
)
datas
.
DataSource
.
pageType
=
newSlides
[
0
].
pageType
if
(
SalesBack
.
value
==
0
)
slidesStore
.
setTitle
(
tempDatas
.
value
.
Title
)
}
// 替换logo
const
ResolveTripLogoHandler
=
async
(
items
:
any
,
slideIndex
:
number
,
dark
:
false
)
=>
{
let
elements
=
[]
let
tempNewSlide
:
any
=
null
let
templateObj
=
JSON
.
parse
(
JSON
.
stringify
(
items
))
for
(
let
i
=
0
;
i
<
templateObj
.
length
;
i
++
){
try
{
let
Colors
=
templateObj
[
i
].
layerName
.
split
(
','
)
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
[
3
]
if
(
scale
<
1
)
templateObj
[
i
].
src
=
acquiesceLogo
.
value
[
1
]
let
scale
=
parseInt
(
tempSize
.
width
/
tempSize
.
height
)
// if(Colors[1]||scale==6) templateObj[i].filters.invert = '20%'
if
(
scale
==
1
)
templateObj
[
i
].
src
=
dark
==
true
?
acquiesceLogo
.
value
[
0
]:
acquiesceLogo
.
value
[
3
]
if
(
scale
<
1
)
templateObj
[
i
].
src
=
dark
==
true
?
acquiesceLogo
.
value
[
1
]:
acquiesceLogo
.
value
[
4
]
if
(
scale
>
1
)
templateObj
[
i
].
src
=
dark
==
true
?
acquiesceLogo
.
value
[
2
]:
acquiesceLogo
.
value
[
5
]
if
(
tempNewSlide
){
tempNewSlide
.
elements
.
push
(...
templateObj
)
}
else
{
...
...
@@ -551,17 +593,39 @@ const ResolveTripLogoHandler = async (items:any, slideIndex:number) =>{
}
y
.
height
=
height
y
.
width
=
width
}
catch
(
error
)
{
}
}
return
{
elements
,
newSlider
:
tempNewSlide
,
}
}
const
SetColor
=
(
colorArr
:
number
[][])
=>
{
// 初始化删除多余子节点
const
extractColor
=
document
.
querySelector
(
'#extract-color-id'
)
as
HTMLElement
;
while
(
extractColor
.
firstChild
)
{
extractColor
.
removeChild
(
extractColor
.
firstChild
);
}
// 创建子节点
for
(
let
index
=
0
;
index
<
colorArr
.
length
;
index
++
)
{
const
bgc
=
'('
+
colorArr
[
index
][
0
]
+
','
+
colorArr
[
index
][
1
]
+
','
+
colorArr
[
index
][
2
]
+
')'
;
const
colorBlock
=
document
.
createElement
(
'div'
)
as
HTMLElement
;
colorBlock
.
id
=
`color-block-id
${
index
}
`
;
colorBlock
.
style
.
cssText
=
'height: 50px;width: 50px;margin-right: 10px;border-radius: 50%;'
;
colorBlock
.
style
.
backgroundColor
=
`rgb
${
bgc
}
`
;
let
list
=
[
parseInt
(
colorArr
[
index
][
0
]),
parseInt
(
colorArr
[
index
][
1
]),
parseInt
(
colorArr
[
index
][
2
])]
let
obj
=
{
Color
:
list
}
colorList
.
value
.
push
(
obj
)
extractColor
.
appendChild
(
colorBlock
);
}
}
const
copySlidHandlerLogo
=
(
slideIndex
:
number
)
=>
{
let
newSlide
=
JSON
.
parse
(
JSON
.
stringify
(
slides
.
value
[
slideIndex
]))
newSlide
.
id
=
uniqueId
()
...
...
@@ -811,6 +875,7 @@ const contextmenusThumbnailItem = (): ContextmenuItem[] => {
},
]
}
if
(
searchData
.
value
.
sellId
&&!
searchData
.
value
.
TempId
)
sellGetTripTemplate
()
if
(
!
query
().
ViewSlideshow
)
GetTripTemplate
()
...
...
src/views/Preview/PreviewCover.vue
View file @
702228f2
...
...
@@ -20,6 +20,14 @@
</div>
</div>
</div>
<div
style=
"position: fixed;left: 200px;top: -100px;opacity: 0;"
>
<canvas
style=
"display: none"
id=
"canvas"
></canvas>
<div
id=
"extract-color-id"
class=
"extract-color"
style=
"display: flex;padding: 0 20px; justify-content:end;"
>
</div>
</div>
</
template
>
<
script
setup
lang=
"ts"
>
...
...
@@ -33,6 +41,8 @@ import { ref } from 'vue';
import
{
ElLoading
}
from
'element-plus'
import
{
useRouter
}
from
'vue-router'
import
{
useUserStore
}
from
"@/store"
;
import
themeColor
from
'@/utils/colorExtraction'
;
import
{
getRgbLevel
}
from
'@/utils/common'
const
router
=
useRouter
()
const
param
=
router
.
currentRoute
.
value
.
params
...
...
@@ -44,9 +54,14 @@ 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'
,
'https://im.oytour.com/pptist/static/logo4.png'
'https://im.oytour.com/pptist/static/logo4.png'
,
'https://im.oytour.com/pptist/static/logo5.png'
,
'https://im.oytour.com/pptist/static/logo6.png'
,
])
const
tempDatas
=
({}
as
any
)
const
colorList
=
([]
as
any
)
const
w
=
ref
(
0
)
const
h
=
ref
(
0
)
...
...
@@ -55,11 +70,22 @@ const loadSliders = async ()=>{
let
response
=
await
ConfigService
.
GetTripTemplateSlide
({
TempId
:
parseInt
(
param
.
tempId
.
toString
())})
loadingObj
.
close
()
if
(
response
.
data
.
resultCode
==
1
)
{
let
dataObj
=
response
.
data
.
data
w
.
value
=
dataObj
.
Width
h
.
value
=
dataObj
.
Height
colorList
.
value
=
[]
tempDatas
.
value
=
dataObj
for
(
let
i
=
0
;
i
<
tempDatas
.
value
.
PageImageList
.
length
;
i
++
){
const
img
=
new
Image
();
img
.
src
=
`
${
tempDatas
.
value
.
PageImageList
[
i
]}
`
;
img
.
crossOrigin
=
'anonymous'
;
img
.
onload
=
()
=>
{
themeColor
(
1
,
img
,
20
,
SetColor
);
};
}
if
(
w
.
value
>
0
){
viewportRatio
.
value
=
h
.
value
/
w
.
value
if
(
viewportRatio
.
value
>=
1
)
VIEWPORT_VER_SIZE
.
Value
=
w
.
value
...
...
@@ -72,37 +98,57 @@ const loadSliders = async ()=>{
SlidesData
&&
SlidesData
.
forEach
((
x
:
any
,
i
:
number
)
=>
{
newSlides
.
push
(
x
)
})
// 根据集团渲染logo
if
(
userInfo
.
value
&&
userInfo
.
value
.
RB_Group_id
<=
1
){
return
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
.
indexOf
(
'logo'
)
!=-
1
)
index
=
indexs
setTimeout
(()
=>
{
getColorShade
(
newSlides
)
},
500
)
}
}
// 获取是否深色
const
getColorShade
=
async
(
newSlides
:
any
)
=>
{
let
dark
=
false
// 根据集团渲染logo
console
.
log
(
tempDatas
.
value
.
AuthType
<=
1
,
'-----------'
)
if
(
tempDatas
.
value
.
AuthType
<=
1
){
for
(
let
j
=
0
;
j
<
colorList
.
value
.
length
;
j
++
){
if
(
getRgbLevel
(
colorList
.
value
[
j
].
Color
)
>
50
)
dark
=
true
}
for
(
let
i
=
0
;
i
<
newSlides
.
length
;
i
++
){
if
(
i
>
colorList
.
value
.
length
-
2
)
dark
=
false
let
x
=
newSlides
[
i
]
let
eles
=
x
.
elements
.
filter
(
y
=>
y
.
layerName
&&
y
.
layerName
.
indexOf
(
'logo'
)
!=-
1
)
let
newElementsImg
=
await
ResolveTripLogoHandler
(
eles
,
i
,
dark
)
let
newElements
=
[]
x
.
elements
.
forEach
(
y
=>
{
if
(
newElementsImg
?.
elements
){
newElementsImg
?.
elements
.
forEach
(
z
=>
{
if
(
y
.
id
==
z
.
id
)
y
=
JSON
.
parse
(
JSON
.
stringify
(
z
))
})
let
eles
=
x
.
elements
.
filter
(
y
=>
y
.
layerName
&&
y
.
layerName
.
indexOf
(
'logo'
)
!=-
1
)
let
newElements
=
await
ResolveTripLogoHandler
(
eles
,
i
)
x
.
elements
=
x
.
elements
.
concat
(
newElements
?.
elements
)
if
(
index
>=
0
)
x
.
elements
.
splice
(
index
,
1
)
}
}
slidesStore
.
setSlides
(
newSlides
)
newElements
.
push
(
y
)
})
x
.
elements
=
newElements
}
}
slidesStore
.
setSlides
(
newSlides
)
slidesStore
.
updateSlideIndex
(
0
)
}
const
ResolveTripLogoHandler
=
async
(
items
:
any
,
slideIndex
:
number
)
=>
{
const
ResolveTripLogoHandler
=
async
(
items
:
any
,
slideIndex
:
number
,
dark
:
false
)
=>
{
let
elements
=
[]
let
tempNewSlide
:
any
=
null
let
templateObj
=
JSON
.
parse
(
JSON
.
stringify
(
items
))
for
(
let
i
=
0
;
i
<
templateObj
.
length
;
i
++
){
try
{
let
Colors
=
templateObj
[
i
].
layerName
.
split
(
','
)
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
[
3
]
if
(
scale
<
1
)
templateObj
[
i
].
src
=
acquiesceLogo
.
value
[
1
]
let
scale
=
parseInt
(
tempSize
.
width
/
tempSize
.
height
)
// if(Colors[1]||scale==6) templateObj[i].filters.invert = '20%'
if
(
scale
==
1
)
templateObj
[
i
].
src
=
dark
==
true
?
acquiesceLogo
.
value
[
0
]:
acquiesceLogo
.
value
[
3
]
if
(
scale
<
1
)
templateObj
[
i
].
src
=
dark
==
true
?
acquiesceLogo
.
value
[
1
]:
acquiesceLogo
.
value
[
4
]
if
(
scale
>
1
)
templateObj
[
i
].
src
=
dark
==
true
?
acquiesceLogo
.
value
[
2
]:
acquiesceLogo
.
value
[
5
]
if
(
tempNewSlide
){
tempNewSlide
.
elements
.
push
(...
templateObj
)
}
else
{
...
...
@@ -134,6 +180,27 @@ const ResolveTripLogoHandler = async (items:any, slideIndex:number) =>{
}
}
const
SetColor
=
(
colorArr
:
number
[][])
=>
{
// 初始化删除多余子节点
const
extractColor
=
document
.
querySelector
(
'#extract-color-id'
)
as
HTMLElement
;
while
(
extractColor
.
firstChild
)
{
extractColor
.
removeChild
(
extractColor
.
firstChild
);
}
// 创建子节点
for
(
let
index
=
0
;
index
<
colorArr
.
length
;
index
++
)
{
const
bgc
=
'('
+
colorArr
[
index
][
0
]
+
','
+
colorArr
[
index
][
1
]
+
','
+
colorArr
[
index
][
2
]
+
')'
;
const
colorBlock
=
document
.
createElement
(
'div'
)
as
HTMLElement
;
colorBlock
.
id
=
`color-block-id
${
index
}
`
;
colorBlock
.
style
.
cssText
=
'height: 50px;width: 50px;margin-right: 10px;border-radius: 50%;'
;
colorBlock
.
style
.
backgroundColor
=
`rgb
${
bgc
}
`
;
let
list
=
[
parseInt
(
colorArr
[
index
][
0
]),
parseInt
(
colorArr
[
index
][
1
]),
parseInt
(
colorArr
[
index
][
2
])]
let
obj
=
{
Color
:
list
}
colorList
.
value
.
push
(
obj
)
extractColor
.
appendChild
(
colorBlock
);
}
}
if
(
param
.
tempId
){
loadSliders
()
...
...
src/views/TemplateCenter/Index.vue
View file @
702228f2
...
...
@@ -3,12 +3,12 @@
<div
class=
"col row flex-between"
>
<div
class=
"row wrap"
>
<div
class=
"row items-center q-mb-lg"
>
<span
class=
"fz14 q-pr-
sm
shrink"
>
关键字:
</span>
<span
class=
"fz14 q-pr-
md
shrink"
>
关键字:
</span>
<el-input
style=
"max-width:212px"
v-model=
"queryObj.Title"
placeholder=
"请输入关键字"
clearable
@
keyup
.
enter=
"search"
></el-input>
</div>
<div
class=
"row items-center q-mb-lg"
>
<span
class=
"fz14 q-pr-
sm
shrink"
>
模版:
</span>
<div
class=
"row items-center q-mb-lg
q-pl-lg
"
>
<span
class=
"fz14 q-pr-
md
shrink"
>
模版:
</span>
<el-select
v-model=
"queryObj.TemplateType"
class=
"ml-1 shrink TemSel"
placeholder=
"模版类型"
clearable
>
...
...
@@ -20,8 +20,8 @@
/>
</el-select>
</div>
<div
class=
"row items-center q-mb-lg"
>
<span
class=
"fz14 q-pr-
sm
shrink"
>
版型:
</span>
<div
class=
"row items-center q-mb-lg
q-pl-lg
"
>
<span
class=
"fz14 q-pr-
md
shrink"
>
版型:
</span>
<el-select
v-model=
"queryObj.TempType"
class=
"ml-1 shrink TemSel"
placeholder=
"版型"
clearable
>
...
...
@@ -33,8 +33,8 @@
/>
</el-select>
</div>
<div
class=
"row items-center q-mb-lg"
>
<span
class=
"fz14 q-pr-
sm
shrink"
>
国家:
</span>
<div
class=
"row items-center q-mb-lg
q-pl-lg
"
>
<span
class=
"fz14 q-pr-
md
shrink"
>
国家:
</span>
<el-select
v-model=
"queryObj.CountryList"
multiple
class=
"ml-1 shrink TemSel"
placeholder=
"国家"
clearable
>
...
...
@@ -47,8 +47,8 @@
/>
</el-select>
</div>
<div
class=
"row items-center q-mb-lg"
>
<span
class=
"fz14 q-pr-
sm
shrink"
>
季节:
</span>
<div
class=
"row items-center q-mb-lg
q-pl-lg
"
>
<span
class=
"fz14 q-pr-
md
shrink"
>
季节:
</span>
<el-select
v-model=
"queryObj.SeasonList"
multiple
class=
"ml-1 shrink TemSel"
placeholder=
"季节"
clearable
>
...
...
@@ -61,8 +61,8 @@
/>
</el-select>
</div>
<div
class=
"row items-center q-mb-lg"
>
<span
class=
"fz14 q-pr-
sm
shrink"
>
颜色:
</span>
<div
class=
"row items-center q-mb-lg
q-pl-lg
"
>
<span
class=
"fz14 q-pr-
md
shrink"
>
颜色:
</span>
<el-select
v-model=
"queryObj.ColorList"
multiple
class=
"ml-1 shrink TemSel"
placeholder=
"颜色"
clearable
>
...
...
@@ -133,11 +133,23 @@
<span
class=
"text-info"
>
{{
scope
.
row
.
CreateTime
}}
</span>
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
width=
"
24
0"
>
<el-table-column
label=
"操作"
width=
"
12
0"
>
<
template
#
default=
"scope"
>
<el-button
type=
"primary"
:icon=
"Edit"
size=
"small"
@
click=
"goToTemplate(scope.row)"
>
编辑
</el-button>
<el-button
type=
"primary"
:icon=
"View"
size=
"small"
@
click=
"getTemplate(scope.row)"
>
详情
</el-button>
<el-button
type=
"primary"
:icon=
"Delete"
size=
"small"
@
click=
"deleteTemplate(scope.row)"
>
删除
</el-button>
<el-button
type=
"default"
link
:icon=
"Edit"
size=
"small"
@
click=
"goToTemplate(scope.row)"
>
编辑
</el-button>
<el-dropdown
class=
"q-pl-lg"
trigger=
"click"
>
<el-icon
class=
"q-pt-sm"
size=
"16"
color=
"#b1b7cf"
><MoreFilled
/></el-icon>
<template
#
dropdown
>
<el-dropdown-menu
class=
"q-pa-md"
>
<el-dropdown-item
@
click=
"getTemplate(scope.row)"
>
<el-button
type=
"default"
link
:icon=
"View"
size=
"small"
>
详情
</el-button>
</el-dropdown-item>
<el-dropdown-item
@
click=
"deleteTemplate(scope.row)"
>
<el-button
type=
"default"
link
:icon=
"Delete"
size=
"small"
>
删除
</el-button>
</el-dropdown-item>
</el-dropdown-menu>
</
template
>
</el-dropdown>
</template>
</el-table-column>
</el-table>
...
...
@@ -428,9 +440,10 @@ const getTemplate = async (item:any) => {
*/
const
goToTemplate
=
(
item
:
any
)
=>
{
let
url
=
''
if
(
model
.
value
==
2
)
url
=
createSaleCreateLink
(
item
.
TempId
,
item
.
TemplateType
)
else
if
(
model
.
value
==
0
&&
router
.
currentRoute
.
value
.
params
.
configId
)
url
=
createOpEditorLink
(
parseInt
(
router
.
currentRoute
.
value
.
params
.
configId
.
toString
()),
item
.
TempId
)
else
if
(
model
.
value
==
1
)
url
=
managerTemplateLink
(
item
.
TempId
,
item
.
TemplateType
)
// if(model.value==2) url = createSaleCreateLink(item.TempId,item.TemplateType)
// else if(model.value==0 && router.currentRoute.value.params.configId) url = createOpEditorLink(parseInt(router.currentRoute.value.params.configId.toString()),item.TempId)
// else if(model.value==1) url = managerTemplateLink(item.TempId,item.TemplateType)
url
=
managerTemplateLink
(
item
.
TempId
,
item
.
TemplateType
)
if
(
url
!=
''
)
{
router
.
push
({
path
:
url
...
...
src/views/TemplateCenter/colour.vue
View file @
702228f2
...
...
@@ -61,10 +61,10 @@
{{
scope
.
row
.
Content
}}
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
width=
"1
6
0"
>
<el-table-column
label=
"操作"
width=
"1
3
0"
>
<
template
#
default=
"scope"
>
<el-button
type=
"
primary"
:icon=
"Edit"
size=
"small"
@
click
.
stop=
"editDelete(scope.row)"
>
编辑
</el-button>
<el-button
type=
"
primary"
:icon=
"Delete"
size=
"small"
@
click
.
stop=
"editDelete(scope.row,scope.$index)"
>
删除
</el-button>
<el-button
type=
"
default"
link
:icon=
"Edit"
size=
"small"
@
click
.
stop=
"editDelete(scope.row)"
>
编辑
</el-button>
<el-button
type=
"
default"
link
:icon=
"Delete"
size=
"small"
@
click
.
stop=
"editDelete(scope.row,scope.$index)"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
...
...
src/views/TemplateCenter/font.vue
View file @
702228f2
...
...
@@ -38,10 +38,10 @@
{{
scope
.
row
.
reduceUrl
}}
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
width=
"1
6
0"
>
<el-table-column
label=
"操作"
width=
"1
3
0"
>
<
template
#
default=
"scope"
>
<el-button
type=
"
primary"
:icon=
"Edit"
size=
"small"
@
click
.
stop=
"editDelete(scope.row)"
>
编辑
</el-button>
<el-button
type=
"
primary"
:icon=
"Delete"
size=
"small"
@
click
.
stop=
"editDelete(scope.row,scope.$index)"
>
删除
</el-button>
<el-button
type=
"
default"
link
:icon=
"Edit"
size=
"small"
@
click
.
stop=
"editDelete(scope.row)"
>
编辑
</el-button>
<el-button
type=
"
default"
link
:icon=
"Delete"
size=
"small"
@
click
.
stop=
"editDelete(scope.row,scope.$index)"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
...
...
src/views/TemplateCenter/nation.vue
View file @
702228f2
...
...
@@ -22,10 +22,10 @@
{{
scope
.
row
.
Name
}}
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
width=
"1
6
0"
>
<el-table-column
label=
"操作"
width=
"1
3
0"
>
<
template
#
default=
"scope"
>
<el-button
type=
"
primary"
:icon=
"Edit"
size=
"small"
@
click
.
stop=
"editDelete(scope.row)"
>
编辑
</el-button>
<el-button
type=
"
primary"
:icon=
"Delete"
size=
"small"
@
click
.
stop=
"editDelete(scope.row,scope.$index)"
>
删除
</el-button>
<el-button
type=
"
default"
link
:icon=
"Edit"
size=
"small"
@
click
.
stop=
"editDelete(scope.row)"
>
编辑
</el-button>
<el-button
type=
"
default"
link
:icon=
"Delete"
size=
"small"
@
click
.
stop=
"editDelete(scope.row,scope.$index)"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment