提交 ff59356a 编写于 作者: Q qiang

fix: 解决透明渐变导航栏按钮背景色和文字颜色配置不生效的问题

上级 79b2408c
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<div class="uni-page-head-hd"> <div class="uni-page-head-hd">
<div <div
v-show="backButton" v-show="backButton"
class="uni-page-head-btn"
@click="_back"> @click="_back">
<i <i
:style="{color:color,fontSize:'27px'}" :style="{color:color,fontSize:'27px'}"
...@@ -17,7 +18,8 @@ ...@@ -17,7 +18,8 @@
<div <div
v-if="btn.float === 'left'" v-if="btn.float === 'left'"
:key="index" :key="index"
:style="{marginRight:index>0?'5px':'0px'}"> :style="{marginRight:index>0?'5px':'0px',backgroundColor: btn.background}"
class="uni-page-head-btn">
<i <i
:style="_formatBtnStyle(btn)" :style="_formatBtnStyle(btn)"
class="uni-btn-icon" class="uni-btn-icon"
...@@ -59,16 +61,18 @@ ...@@ -59,16 +61,18 @@
:placeholder-style="`color:${searchInput.placeholderColor}`" :placeholder-style="`color:${searchInput.placeholderColor}`"
class="uni-page-head-search-input" class="uni-page-head-search-input"
confirm-type="search" confirm-type="search"
@focus="__focus" @focus="_focus"
@blur="__blur" @blur="_blur"
@input="__input" @input="_input"
/> />
</div> </div>
<div class="uni-page-head-ft"> <div class="uni-page-head-ft">
<template v-for="(btn,index) in btns"> <template v-for="(btn,index) in btns">
<div <div
v-if="btn.float !== 'left'" v-if="btn.float !== 'left'"
:key="index"> :key="index"
:style="{backgroundColor: btn.background}"
class="uni-page-head-btn">
<i <i
:style="_formatBtnStyle(btn)" :style="_formatBtnStyle(btn)"
class="uni-btn-icon" class="uni-btn-icon"
...@@ -143,12 +147,13 @@ uni-page-head .uni-page-head-bd { ...@@ -143,12 +147,13 @@ uni-page-head .uni-page-head-bd {
user-select: auto; user-select: auto;
} }
.uni-btn-icon { .uni-page-head-btn {
max-width: 48px; max-width: 48px;
word-break: keep-all; word-break: keep-all;
margin: 0 2px; margin: 0 2px;
overflow: hidden; overflow: hidden;
word-break: keep-all; word-break: keep-all;
background-color: rgba(153,153,153,1);
} }
.uni-page-head-search { .uni-page-head-search {
...@@ -383,13 +388,13 @@ export default { ...@@ -383,13 +388,13 @@ export default {
} }
return style return style
}, },
__focus () { _focus () {
this.focus = true this.focus = true
}, },
__blur () { _blur () {
this.focus = false this.focus = false
}, },
__input () { _input () {
UniServiceJSBridge.emit('onNavigationBarSearchInputChanged', { UniServiceJSBridge.emit('onNavigationBarSearchInputChanged', {
text: this.text text: this.text
}) })
......
...@@ -9,13 +9,17 @@ export default { ...@@ -9,13 +9,17 @@ export default {
const titleElem = this.$el.querySelector('.uni-page-head__title') const titleElem = this.$el.querySelector('.uni-page-head__title')
const iconElems = this.$el.querySelectorAll('.uni-btn-icon') const iconElems = this.$el.querySelectorAll('.uni-btn-icon')
const iconElemsStyles = [] const iconElemsStyles = []
const textColor = this.textColor
for (let i = 0; i < iconElems.length; i++) { for (let i = 0; i < iconElems.length; i++) {
iconElemsStyles.push(iconElems[i].style) iconElemsStyles.push(iconElems[i].style)
} }
const borderRadiusElems = this.$el.querySelectorAll('.uni-page-head-hd>div,.uni-page-head-ft>div') const borderRadiusElems = this.$el.querySelectorAll('.uni-page-head-btn')
const oldColors = []
const borderRadiusElemsStyles = [] const borderRadiusElemsStyles = []
for (let i = 0; i < borderRadiusElems.length; i++) { for (let i = 0; i < borderRadiusElems.length; i++) {
borderRadiusElemsStyles.push(borderRadiusElems[i].style) let borderRadiusElem = borderRadiusElems[i]
oldColors.push(getComputedStyle(borderRadiusElem).backgroundColor)
borderRadiusElemsStyles.push(borderRadiusElem.style)
} }
this._A = 0 this._A = 0
UniViewJSBridge.on('onPageScroll', ({ UniViewJSBridge.on('onPageScroll', ({
...@@ -27,7 +31,7 @@ export default { ...@@ -27,7 +31,7 @@ export default {
} }
if (alpha > 0.5 && this._A <= 0.5) { if (alpha > 0.5 && this._A <= 0.5) {
iconElemsStyles.forEach(function (iconElemStyle) { iconElemsStyles.forEach(function (iconElemStyle) {
iconElemStyle.color = '#000' iconElemStyle.color = textColor
}) })
} else if (alpha <= 0.5 && this._A > 0.5) { } else if (alpha <= 0.5 && this._A > 0.5) {
iconElemsStyles.forEach(function (iconElemStyle) { iconElemsStyles.forEach(function (iconElemStyle) {
...@@ -40,8 +44,11 @@ export default { ...@@ -40,8 +44,11 @@ export default {
titleElem.style.opacity = alpha titleElem.style.opacity = alpha
} }
transparentElemStyle.backgroundColor = `rgba(${this._R},${this._G},${this._B},${alpha})` transparentElemStyle.backgroundColor = `rgba(${this._R},${this._G},${this._B},${alpha})`
borderRadiusElemsStyles.forEach(function (borderRadiusElemStyle) { borderRadiusElemsStyles.forEach(function (borderRadiusElemStyle, index) {
borderRadiusElemStyle.backgroundColor = `rgba(153,153,153,${1 - alpha})` let oldColor = oldColors[index]
let rgba = oldColor.match(/\d+/g)
rgba[3] = (1 - alpha) * (rgba.length === 4 ? rgba[3] : 1)
borderRadiusElemStyle.backgroundColor = `rgba(${rgba})`
}) })
}) })
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册