Commit df64aa0b authored by 黄奎's avatar 黄奎
parents 13f7e083 dbdf4dbb
......@@ -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;
}
},
......@@ -431,15 +457,18 @@
this.objOption.CourseSubject = res.Data.CourseSubject;
this.objOption.B2BIcon = res.Data.B2BIcon ;
this.objOption.B2BBackground = res.Data.B2BBackground;
this.objOption.CourseEmphasis = res.Data.CourseEmphasis;
if(this.objOption.CourseEmphasis && this.objOption.CourseEmphasis!=''){
this.CourseEmphasis=this.objOption.CourseEmphasis.split(",")
}else{
this.CourseEmphasis=[]
this.keynoteList.map((x)=>{
this.CourseEmphasis.push(x.Id)
})
}
this.CourseEmphasis=[]
setTimeout(()=>{//Todo 暂时不知道什么原因 偶尔会出现2个 所以加了一个延迟
if(res.Data.CourseEmphasis && res.Data.CourseEmphasis!=''){
this.CourseEmphasis=res.Data.CourseEmphasis.split(",").map(Number)
}else{
this.keynoteList.map((x)=>{
this.CourseEmphasis.push(x.Id)
})
}
},100)
if (res.Data.StepPriceList && res.Data.StepPriceList.length > 0) {
this.ladderPriceList = res.Data.StepPriceList;
}
......
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