Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mallapp
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
mallapp
Commits
66787efa
Commit
66787efa
authored
Jun 29, 2020
by
zhangjianguo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
颜色判定
parent
7a614b1e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
0 deletions
+75
-0
goodsku.vue
components/goods/goodsku.vue
+39
-0
goodsaction.vue
pages/goods/components/goodsaction.vue
+36
-0
No files found.
components/goods/goodsku.vue
View file @
66787efa
...
...
@@ -97,6 +97,7 @@ export default {
goodprice
:
''
,
goodamount
:
''
,
mc
:
''
,
fu
:
''
,
secondary
:
''
,
gc
:
1
,
bian
:
false
,
...
...
@@ -151,6 +152,7 @@ export default {
this
.
goodimage
=
this
.
g
.
cover_pic
;
this
.
mc
=
this
.
$uiConfig
.
mainColor
;
this
.
fu
=
this
.
$uiConfig
.
secondary
;
this
.
secondary
=
this
.
$uiConfig
.
secondary
;
this
.
skuObj
=
this
.
skued
.
id
?
this
.
skued
:
null
;
if
(
this
.
skuObj
)
{
...
...
@@ -186,6 +188,7 @@ export default {
}
});
}
this
.
getfu
()
this
.
formatDisableSku
();
this
.
formatChosenTips
();
}
...
...
@@ -193,6 +196,42 @@ export default {
// this.g = this.good;
},
methods
:
{
getfu
(){
let
fucolor
=
this
.
colorRgb
(
this
.
fu
)
;
var
RgbValue
=
fucolor
.
replace
(
"rgb("
,
""
).
replace
(
")"
,
""
);
var
RgbValueArry
=
RgbValue
.
split
(
","
);
var
grayLevel
=
RgbValueArry
[
0
]
*
0.299
+
RgbValueArry
[
1
]
*
0.587
+
RgbValueArry
[
2
]
*
0.114
;
console
.
log
(
grayLevel
)
if
(
grayLevel
>=
192
){
this
.
btn1
.
color
=
this
.
mc
;
}
else
{
this
.
btn1
.
color
=
'#FFF'
;
}
},
colorRgb
(
color
)
{
var
sColor
=
color
.
toLowerCase
();
//十六进制颜色值的正则表达式
var
reg
=
/^#
([
0-9a-fA-f
]{3}
|
[
0-9a-fA-f
]{6})
$/
;
// 如果是16进制颜色
if
(
sColor
&&
reg
.
test
(
sColor
))
{
if
(
sColor
.
length
===
4
)
{
var
sColorNew
=
"#"
;
for
(
var
i
=
1
;
i
<
4
;
i
+=
1
)
{
sColorNew
+=
sColor
.
slice
(
i
,
i
+
1
).
concat
(
sColor
.
slice
(
i
,
i
+
1
));
}
sColor
=
sColorNew
;
}
//处理六位的颜色值
var
sColorChange
=
[];
for
(
var
i
=
1
;
i
<
7
;
i
+=
2
)
{
sColorChange
.
push
(
parseInt
(
"0x"
+
sColor
.
slice
(
i
,
i
+
2
)));
}
return
sColorChange
.
join
(
","
);
}
return
sColor
;
},
joinCar
()
{
if
(
this
.
skuObj
&&
this
.
skuObj
.
id
)
{
this
.
request2
(
...
...
pages/goods/components/goodsaction.vue
View file @
66787efa
...
...
@@ -64,12 +64,48 @@ export default {
this
.
bian
=
this
.
$utils
.
is_biang
;
this
.
btn1
.
background
=
this
.
fu
;
this
.
btn2
.
background
=
this
.
mc
;
this
.
getfu
()
let
t
=
getCurrentPages
();
this
.
path
=
'/'
+
t
[
t
.
length
-
1
].
route
;
//console.log(t[t.length - 1]);
this
.
favorStatus
=
this
.
favorite
;
},
methods
:
{
getfu
(){
let
fucolor
=
this
.
colorRgb
(
this
.
fu
)
;
var
RgbValue
=
fucolor
.
replace
(
"rgb("
,
""
).
replace
(
")"
,
""
);
var
RgbValueArry
=
RgbValue
.
split
(
","
);
var
grayLevel
=
RgbValueArry
[
0
]
*
0.299
+
RgbValueArry
[
1
]
*
0.587
+
RgbValueArry
[
2
]
*
0.114
;
console
.
log
(
grayLevel
)
if
(
grayLevel
>=
192
){
this
.
btn1
.
color
=
this
.
mc
;
}
else
{
this
.
btn1
.
color
=
'#FFF'
;
}
},
colorRgb
(
color
)
{
var
sColor
=
color
.
toLowerCase
();
//十六进制颜色值的正则表达式
var
reg
=
/^#
([
0-9a-fA-f
]{3}
|
[
0-9a-fA-f
]{6})
$/
;
// 如果是16进制颜色
if
(
sColor
&&
reg
.
test
(
sColor
))
{
if
(
sColor
.
length
===
4
)
{
var
sColorNew
=
"#"
;
for
(
var
i
=
1
;
i
<
4
;
i
+=
1
)
{
sColorNew
+=
sColor
.
slice
(
i
,
i
+
1
).
concat
(
sColor
.
slice
(
i
,
i
+
1
));
}
sColor
=
sColorNew
;
}
//处理六位的颜色值
var
sColorChange
=
[];
for
(
var
i
=
1
;
i
<
7
;
i
+=
2
)
{
sColorChange
.
push
(
parseInt
(
"0x"
+
sColor
.
slice
(
i
,
i
+
2
)));
}
return
sColorChange
.
join
(
","
);
}
return
sColor
;
},
goCart
()
{
uni
.
redirectTo
({
url
:
'/pages/cart/cart'
...
...
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