Commit df64aa0b authored by 黄奎's avatar 黄奎
parents 13f7e083 dbdf4dbb
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
</div> </div>
<div class="col-6 q-pb-lg q-pr-lg"> <div class="col-6 q-pb-lg q-pr-lg">
<q-uploader :style="{ backgroundImage: 'url(' + objOption.B2BIcon + ')' }" <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> :factory="uploadFile2" auto-upload>
</q-uploader> </q-uploader>
<q-input <q-input
...@@ -356,20 +356,46 @@ ...@@ -356,20 +356,46 @@
let domImg = document.querySelector('#background'); let domImg = document.querySelector('#background');
let colorthief = new ColorThief(); let colorthief = new ColorThief();
domImg.addEventListener('load', () => { 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) // console.log('加载好了并取色', colorthief.getColor(domImg));//第二个参数可选(1~10)
let color = colorthief.getColor(domImg) let color = colorthief.getColor(domImg,2)
this.objOption.B2BBackground = this.rgb2Hex(color[0],color[1],color[2])
this.objOption.B2BBackground = this.rgb2Hex( `RGB(${color[0]}, ${color[1]}, ${color[2]})` )
console.log(this.objOption.B2BBackground)
}) })
}, },
rgb2Hex(r,g,b){//rhg转化为16进制 rgb2Hex(string){//rgb转化为16进制
r = Math.max(Math.min(Number(r), 100), 0) * 2.55 console.log(string)
g = Math.max(Math.min(Number(g), 100), 0) * 2.55 var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
b = Math.max(Math.min(Number(b), 100), 0) * 2.55 if(/^(rgb|RGB)/.test(string)){
r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2) var aColor = string.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(",");
g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2) var strHex = "#";
b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2) for(var i=0; i<aColor.length; i++){
return '#' + r + g + b 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 @@ ...@@ -431,15 +457,18 @@
this.objOption.CourseSubject = res.Data.CourseSubject; this.objOption.CourseSubject = res.Data.CourseSubject;
this.objOption.B2BIcon = res.Data.B2BIcon ; this.objOption.B2BIcon = res.Data.B2BIcon ;
this.objOption.B2BBackground = res.Data.B2BBackground; this.objOption.B2BBackground = res.Data.B2BBackground;
this.objOption.CourseEmphasis = res.Data.CourseEmphasis; this.CourseEmphasis=[]
if(this.objOption.CourseEmphasis && this.objOption.CourseEmphasis!=''){ setTimeout(()=>{//Todo 暂时不知道什么原因 偶尔会出现2个 所以加了一个延迟
this.CourseEmphasis=this.objOption.CourseEmphasis.split(",") if(res.Data.CourseEmphasis && res.Data.CourseEmphasis!=''){
}else{ this.CourseEmphasis=res.Data.CourseEmphasis.split(",").map(Number)
this.CourseEmphasis=[]
this.keynoteList.map((x)=>{ }else{
this.CourseEmphasis.push(x.Id) this.keynoteList.map((x)=>{
}) this.CourseEmphasis.push(x.Id)
} })
}
},100)
if (res.Data.StepPriceList && res.Data.StepPriceList.length > 0) { if (res.Data.StepPriceList && res.Data.StepPriceList.length > 0) {
this.ladderPriceList = res.Data.StepPriceList; 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