Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
46a78570
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
46a78570
编写于
11月 07, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(h5): 日期类型 picker 在桌面 Chrome、Firefox 浏览器默认使用系统日历
上级
bbb80ff5
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
82 addition
and
33 deletion
+82
-33
src/platforms/h5/view/components/picker/index.vue
src/platforms/h5/view/components/picker/index.vue
+82
-33
未找到文件。
src/platforms/h5/view/components/picker/index.vue
浏览文件 @
46a78570
...
...
@@ -19,9 +19,10 @@
/>
</transition>
<div
v-if=
"!system"
:class=
"
{ 'uni-picker-toggle': visible }"
:style="popupStyle.content"
class="uni-picker"
class="uni-picker
-custom
"
>
<div
class=
"uni-picker-header"
...
...
@@ -82,6 +83,21 @@
<div>
<slot
/>
</div>
<div
v-if=
"system"
class=
"uni-picker-system"
>
<input
ref=
"input"
:value=
"valueSync"
:type=
"mode"
tabindex=
"-1"
:min=
"start"
:max=
"end"
:class=
"[system, popupStyle.dock]"
@
change.stop=
"_input"
>
</div>
<keypress
:disable=
"!visible"
@
esc=
"_cancel"
...
...
@@ -107,7 +123,7 @@ function getDefaultStartValue () {
return
year
.
toString
()
case
fields
.
MONTH
:
return
year
+
'
-01
'
case
fields
.
DAY
:
default
:
return
year
+
'
-01-01
'
}
}
...
...
@@ -125,7 +141,7 @@ function getDefaultEndValue () {
return
year
.
toString
()
case
fields
.
MONTH
:
return
year
+
'
-12
'
case
fields
.
DAY
:
default
:
return
year
+
'
-12-31
'
}
}
...
...
@@ -176,15 +192,12 @@ export default {
type
:
String
,
default
:
mode
.
SELECTOR
,
validator
(
val
)
{
return
Object
.
values
(
mode
).
in
dexOf
(
val
)
>=
0
return
Object
.
values
(
mode
).
in
cludes
(
val
)
}
},
fields
:
{
type
:
String
,
default
:
'
day
'
,
validator
(
val
)
{
return
Object
.
values
(
fields
).
indexOf
(
val
)
>=
0
}
default
:
''
},
start
:
{
type
:
String
,
...
...
@@ -234,7 +247,7 @@ export default {
return
[
dateArray
[
0
]]
case
fields
.
MONTH
:
return
[
dateArray
[
0
],
dateArray
[
1
]]
case
fields
.
DAY
:
default
:
return
[
dateArray
[
0
],
dateArray
[
1
],
dateArray
[
2
]]
}
}
...
...
@@ -263,6 +276,16 @@ export default {
return
type
}
return
String
(
navigator
.
vendor
).
indexOf
(
'
Apple
'
)
===
0
&&
navigator
.
maxTouchPoints
>
0
?
selectorType
.
PICKER
:
selectorType
.
SELECT
},
system
()
{
if
(
this
.
mode
===
mode
.
DATE
&&
!
Object
.
values
(
fields
).
includes
(
this
.
fields
)
&&
this
.
isDesktop
&&
/win|mac/i
.
test
(
navigator
.
platform
))
{
if
(
navigator
.
vendor
===
'
Google Inc.
'
)
{
return
'
chrome
'
}
else
if
(
/Firefox/
.
test
(
navigator
.
userAgent
))
{
return
'
firefox
'
}
}
return
''
}
},
watch
:
{
...
...
@@ -542,7 +565,15 @@ export default {
value
})
},
_cancel
()
{
_cancel
(
$event
)
{
if
(
this
.
system
===
'
firefox
'
)
{
// Firefox 在 input 同位置区域点击无法隐藏控件
const
{
top
,
left
,
width
,
height
}
=
this
.
popover
const
{
pageX
,
pageY
}
=
$event
if
(
pageX
>
left
&&
pageX
<
left
+
width
&&
pageY
>
top
&&
pageY
<
top
+
height
)
{
return
}
}
this
.
_close
()
this
.
$trigger
(
'
cancel
'
,
{},
{})
},
...
...
@@ -559,6 +590,12 @@ export default {
if
(
this
.
mode
===
mode
.
SELECTOR
&&
this
.
selectorTypeComputed
===
selectorType
.
SELECT
)
{
this
.
$refs
.
select
.
scrollTop
=
this
.
valueArray
[
0
]
*
34
}
},
_input
(
$event
)
{
this
.
valueSync
=
$event
.
target
.
value
this
.
$nextTick
(()
=>
{
this
.
_change
()
})
}
}
}
...
...
@@ -566,6 +603,7 @@ export default {
<
style
>
uni-picker
{
position
:
relative
;
display
:
block
;
cursor
:
pointer
;
}
...
...
@@ -590,11 +628,11 @@ uni-picker[disabled] {
font-size
:
16px
;
}
.uni-picker-container
.uni-picker
*
{
.uni-picker-container
.uni-picker
-custom
*
{
box-sizing
:
border-box
;
}
.uni-picker-container
.uni-picker
{
.uni-picker-container
.uni-picker
-custom
{
position
:
fixed
;
left
:
0
;
bottom
:
0
;
...
...
@@ -607,7 +645,7 @@ uni-picker[disabled] {
transition
:
transform
0.3s
,
visibility
0.3s
;
}
.uni-picker-container
.uni-picker.uni-picker-toggle
{
.uni-picker-container
.uni-picker
-custom
.uni-picker-toggle
{
visibility
:
visible
;
transform
:
translate
(
0
,
0
);
}
...
...
@@ -678,37 +716,48 @@ uni-picker[disabled] {
color
:
#007aff
;
}
/* .uni-picker
{
position: relativ
e;
.uni-picker-container
.uni-picker-select
{
display
:
non
e
;
}
.uni-picker-units {
.uni-picker-system
{
position
:
absolute
;
display: flex;
display
:
none
;
display
:
block
;
top
:
0
;
left
:
0
;
width
:
100%
;
line-height: 16px;
font-size: 14px;
top: 50%;
margin-top: 22.5px;
transform: translateY(-50%);
height
:
100%
;
overflow
:
hidden
;
color: #666666;
pointer-events: none;
}
.uni-picker-units > div {
flex: 1;
text-align: center;
transform: translateX(2em);
} */
.uni-picker-container
.uni-picker-select
{
display
:
none
;
.uni-picker-system
>
input
{
position
:
absolute
;
border
:
none
;
height
:
100%
;
opacity
:
0
;
}
.uni-picker-system
>
input
.firefox
{
top
:
0
;
left
:
0
;
width
:
100%
;
}
.uni-picker-system
>
input
.chrome
{
/* 翻转且使用较大字体保证可点击日历按钮 */
top
:
0
;
right
:
100%
;
font-size
:
9999px
;
transform-origin
:
100%
0
;
transform
:
scaleX
(
-1
);
}
@media
screen
and
(
min-width
:
500px
)
and
(
min-height
:
500px
)
{
.uni-mask.uni-picker-mask
{
background
:
none
;
}
.uni-picker-container
.uni-picker
{
.uni-picker-container
.uni-picker
-custom
{
width
:
300px
;
left
:
50%
;
right
:
auto
;
...
...
@@ -729,7 +778,7 @@ uni-picker[disabled] {
overflow
:
hidden
;
border-radius
:
0
0
5px
5px
;
}
.uni-picker-container
.uni-picker.uni-picker-toggle
{
.uni-picker-container
.uni-picker
-custom
.uni-picker-toggle
{
opacity
:
1
;
transform
:
translate
(
-50%
,
-50%
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录