Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
confucius
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
罗超
confucius
Commits
9156d639
Commit
9156d639
authored
Nov 26, 2021
by
Mac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
494bb368
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
12 deletions
+38
-12
course-form.vue
src/components/course/course-form.vue
+38
-12
No files found.
src/components/course/course-form.vue
View file @
9156d639
...
...
@@ -112,7 +112,7 @@
</div>
<div
class=
"col-6 q-pb-lg q-pr-lg"
>
<q-uploader
:style=
"{ backgroundImage: 'url(' + objOption.B2BIcon + ')' }"
style=
"width: auto;
height: 139px
"
flat
hide-upload-btn
max-files=
"1"
label=
"图标"
accept=
".jpg, image/*"
style=
"width: auto; "
flat
hide-upload-btn
max-files=
"1"
label=
"图标"
accept=
".jpg, image/*"
:factory=
"uploadFile2"
auto-upload
>
</q-uploader>
<q-input
...
...
@@ -356,20 +356,46 @@
let
domImg
=
document
.
querySelector
(
'#background'
);
let
colorthief
=
new
ColorThief
();
domImg
.
addEventListener
(
'load'
,
()
=>
{
// console.log('加载好了并取色', colorthief.getPalette(domImg));//第二个参数可选(1~10)
// console.log('加载好了并取色', colorthief.getPalette(domImg
,2
));//第二个参数可选(1~10)
// console.log('加载好了并取色', colorthief.getColor(domImg));//第二个参数可选(1~10)
let
color
=
colorthief
.
getColor
(
domImg
)
this
.
objOption
.
B2BBackground
=
this
.
rgb2Hex
(
color
[
0
],
color
[
1
],
color
[
2
])
let
color
=
colorthief
.
getColor
(
domImg
,
2
)
this
.
objOption
.
B2BBackground
=
this
.
rgb2Hex
(
`RGB(
${
color
[
0
]}
,
${
color
[
1
]}
,
${
color
[
2
]}
)`
)
console
.
log
(
this
.
objOption
.
B2BBackground
)
})
},
rgb2Hex
(
r
,
g
,
b
){
//rhg转化为16进制
r
=
Math
.
max
(
Math
.
min
(
Number
(
r
),
100
),
0
)
*
2.55
g
=
Math
.
max
(
Math
.
min
(
Number
(
g
),
100
),
0
)
*
2.55
b
=
Math
.
max
(
Math
.
min
(
Number
(
b
),
100
),
0
)
*
2.55
r
=
(
'0'
+
(
Math
.
round
(
r
)
||
0
).
toString
(
16
)).
slice
(
-
2
)
g
=
(
'0'
+
(
Math
.
round
(
g
)
||
0
).
toString
(
16
)).
slice
(
-
2
)
b
=
(
'0'
+
(
Math
.
round
(
b
)
||
0
).
toString
(
16
)).
slice
(
-
2
)
return
'#'
+
r
+
g
+
b
rgb2Hex
(
string
){
//rgb转化为16进制
console
.
log
(
string
)
var
reg
=
/^#
([
0-9a-fA-f
]{3}
|
[
0-9a-fA-f
]{6})
$/
;
if
(
/^
(
rgb|RGB
)
/
.
test
(
string
)){
var
aColor
=
string
.
replace
(
/
(?:\(
|
\)
|rgb|RGB
)
*/g
,
""
).
split
(
","
);
var
strHex
=
"#"
;
for
(
var
i
=
0
;
i
<
aColor
.
length
;
i
++
){
var
hex
=
Number
(
aColor
[
i
]).
toString
(
16
);
if
(
hex
===
"0"
){
hex
+=
hex
;
}
strHex
+=
hex
;
}
if
(
strHex
.
length
!==
7
){
strHex
=
string
;
}
return
strHex
;
}
else
if
(
reg
.
test
(
string
)){
var
aNum
=
string
.
replace
(
/#/
,
""
).
split
(
""
);
if
(
aNum
.
length
===
6
){
return
string
;
}
else
if
(
aNum
.
length
===
3
){
var
numHex
=
"#"
;
for
(
var
i
=
0
;
i
<
aNum
.
length
;
i
+=
1
){
numHex
+=
(
aNum
[
i
]
+
aNum
[
i
]);
}
return
numHex
;
}
}
else
{
return
string
;
}
},
...
...
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