Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
ecf6b822
U
uni-app
项目概览
DCloud
/
uni-app
大约 1 个月 前同步成功
通知
702
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ecf6b822
编写于
2月 26, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: titleNView支持searchInput配置
上级
8f267fc7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
162 addition
and
16 deletion
+162
-16
src/core/helpers/patch.js
src/core/helpers/patch.js
+13
-1
src/core/service/bridge/on.js
src/core/service/bridge/on.js
+5
-1
src/platforms/h5/components/page/pageHead.vue
src/platforms/h5/components/page/pageHead.vue
+144
-14
未找到文件。
src/core/helpers/patch.js
浏览文件 @
ecf6b822
...
...
@@ -34,6 +34,18 @@ export function mergeTitleNView (navigationBar, titleNView) {
if
(
hasOwn
(
titleNView
,
'
type
'
))
{
navigationBar
.
type
=
titleNView
.
type
}
if
(
hasOwn
(
titleNView
,
'
searchInput
'
)
&&
typeof
titleNView
.
searchInput
===
'
object
'
)
{
navigationBar
.
searchInput
=
Object
.
assign
({
autoFocus
:
false
,
align
:
'
center
'
,
color
:
'
#000000
'
,
backgroundColor
:
'
rgba(255,255,255,0.5)
'
,
borderRadius
:
'
0px
'
,
placeholder
:
''
,
placeholderColor
:
'
#CCCCCC
'
,
disabled
:
false
},
titleNView
.
searchInput
)
}
}
return
navigationBar
}
}
src/core/service/bridge/on.js
浏览文件 @
ecf6b822
...
...
@@ -69,5 +69,9 @@ export default function initOn (on) {
on
(
'
onTabItemTap
'
,
createCallCurrentPageHook
(
'
onTabItemTap
'
))
on
(
'
onNavigationBarButtonTap
'
,
createCallCurrentPageHook
(
'
onNavigationBarButtonTap
'
))
on
(
'
onNavigationBarSearchInputChanged
'
,
createCallCurrentPageHook
(
'
onNavigationBarSearchInputChanged
'
))
on
(
'
onNavigationBarSearchInputConfirmed
'
,
createCallCurrentPageHook
(
'
onNavigationBarSearchInputConfirmed
'
))
on
(
'
onNavigationBarSearchInputClicked
'
,
createCallCurrentPageHook
(
'
onNavigationBarSearchInputClicked
'
))
on
(
'
onWebInvokeAppService
'
,
onWebInvokeAppService
)
}
}
src/platforms/h5/components/page/pageHead.vue
浏览文件 @
ecf6b822
...
...
@@ -3,13 +3,16 @@
<div
:style=
"
{transitionDuration:duration,transitionTimingFunction:timingFunc,backgroundColor:bgColor,color:textColor}"
:class="{'uni-page-head-transparent':type==='transparent'}"
class="uni-page-head">
class="uni-page-head"
>
<div
class=
"uni-page-head-hd"
>
<div
v-show=
"backButton"
@
click=
"_back"
><i
<div
v-show=
"backButton"
@
click=
"_back"
>
<i
:style=
"
{color:color,fontSize:'27px'}"
class="uni-btn-icon">

</i></div>
class="uni-btn-icon">

</i>
</div>
<template
v-for=
"(btn,index) in btns"
>
<div
v-if=
"btn.float === 'left'"
...
...
@@ -19,38 +22,66 @@
:style=
"_formatBtnStyle(btn)"
class=
"uni-btn-icon"
@
click=
"_onBtnClick(index)"
v-html=
"_formatBtnFontText(btn)"
/>
v-html=
"_formatBtnFontText(btn)"
/>
</div>
</
template
>
</div>
<div
class=
"uni-page-head-bd"
>
<div
v-if=
"!searchInput"
class=
"uni-page-head-bd"
>
<div
:style=
"{fontSize:titleSize,opacity:type==='transparent'?0:1}"
class=
"uni-page-head__title"
>
class=
"uni-page-head__title"
>
<i
v-if=
"loading"
class=
"uni-loading"
/>
class=
"uni-loading"
/>
{{ titleText }}
</div>
</div>
<div
v-if=
"searchInput"
:style=
"{'background-color':searchInput.backgroundColor}"
class=
"uni-page-head-search"
>
<div
:style=
"{color:searchInput.placeholderColor}"
:class=
"[`uni-page-head-search-placeholder-${focus?'left':searchInput.align}`]"
class=
"uni-page-head-search-placeholder"
>
{{ text || composing ? '' : searchInput.placeholder }}
</div>
<v-uni-input
ref=
"input"
v-model=
"text"
:focus=
"searchInput.autoFocus"
:disabled=
"searchInput.disabled"
:style=
"{'border-radius':searchInput.borderRadius,color:searchInput.color}"
:placeholder-style=
"`color:${searchInput.placeholderColor}`"
class=
"uni-page-head-search-input"
confirm-type=
"search"
@
focus=
"__focus"
@
blur=
"__blur"
@
input=
"__input"
/>
</div>
<div
class=
"uni-page-head-ft"
>
<
template
v-for=
"(btn,index) in btns"
>
<div
v-if=
"btn.float !== 'left'"
:key=
"index"
:style=
"
{marginRight:index>0?'5px':'0px'}">
:key=
"index"
>
<i
:style=
"_formatBtnStyle(btn)"
class=
"uni-btn-icon"
@
click=
"_onBtnClick(index)"
v-html=
"_formatBtnFontText(btn)"
/>
v-html=
"_formatBtnFontText(btn)"
/>
</div>
</
template
>
</div>
</div>
<div
v-if=
"type!=='transparent'"
class=
"uni-placeholder"
/>
class=
"uni-placeholder"
/>
</uni-page-head>
</template>
<
style
>
...
...
@@ -64,7 +95,7 @@ uni-page-head .uni-page-head {
left
:
0
;
width
:
100%
;
height
:
44px
;
padding
:
12px
5
px
;
padding
:
7px
3
px
;
display
:
flex
;
overflow
:
hidden
;
justify-content
:
space-between
;
...
...
@@ -112,6 +143,59 @@ uni-page-head .uni-page-head-bd {
user-select
:
auto
;
}
.uni-btn-icon
{
max-width
:
48px
;
word-break
:
keep-all
;
margin
:
0
2px
;
overflow
:
hidden
;
word-break
:
keep-all
;
}
.uni-page-head-search
{
position
:
relative
;
display
:
flex
;
flex
:
1
;
margin
:
0
2px
;
line-height
:
30px
;
font-size
:
16px
;
}
.uni-page-head-search-input
{
width
:
100%
;
height
:
100%
;
padding-left
:
34px
;
}
.uni-page-head-search-placeholder
{
position
:
absolute
;
max-width
:
100%
;
height
:
100%
;
padding-left
:
34px
;
overflow
:
hidden
;
word-break
:
keep-all
;
}
.uni-page-head-search-placeholder-right
{
right
:
0
;
}
.uni-page-head-search-placeholder-center
{
left
:
50%
;
transform
:
translateX
(
-50%
);
}
.uni-page-head-search-placeholder
::before
{
position
:
absolute
;
top
:
0
;
left
:
2px
;
width
:
30px
;
content
:
"\ea0e"
;
display
:
block
;
font-size
:
20px
;
font-family
:
"uni"
;
text-align
:
center
;
}
uni-page-head
.uni-page-head-ft
{
display
:
flex
;
align-items
:
center
;
...
...
@@ -122,6 +206,7 @@ uni-page-head .uni-page-head-ft {
uni-page-head
.uni-page-head__title
{
font-weight
:
bold
;
font-size
:
16px
;
line-height
:
30px
;
text-align
:
center
;
overflow
:
hidden
;
white-space
:
nowrap
;
...
...
@@ -200,6 +285,19 @@ export default {
default
()
{
return
[]
}
},
searchInput
:
{
type
:
[
Object
,
Boolean
],
default
()
{
return
false
}
}
},
data
()
{
return
{
focus
:
false
,
text
:
''
,
composing
:
false
}
},
computed
:
{
...
...
@@ -222,6 +320,27 @@ export default {
return
btns
}
},
mounted
()
{
if
(
this
.
searchInput
)
{
const
input
=
this
.
$refs
.
input
input
.
$watch
(
'
composing
'
,
val
=>
{
this
.
composing
=
val
})
if
(
this
.
searchInput
.
disabled
)
{
input
.
$on
(
'
click
'
,
()
=>
{
UniServiceJSBridge
.
emit
(
'
onNavigationBarSearchInputClicked
'
,
''
)
})
}
else
{
input
.
$refs
.
input
.
addEventListener
(
'
keyup
'
,
event
=>
{
if
(
event
.
key
.
toUpperCase
()
===
'
ENTER
'
)
{
UniServiceJSBridge
.
emit
(
'
onNavigationBarSearchInputConfirmed
'
,
{
text
:
this
.
text
})
}
})
}
}
},
methods
:
{
_back
()
{
if
(
getCurrentPages
().
length
===
1
)
{
...
...
@@ -263,6 +382,17 @@ export default {
style
.
fontFamily
=
btn
.
fontFamily
}
return
style
},
__focus
()
{
this
.
focus
=
true
},
__blur
()
{
this
.
focus
=
false
},
__input
()
{
UniServiceJSBridge
.
emit
(
'
onNavigationBarSearchInputChanged
'
,
{
text
:
this
.
text
})
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录