Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
70941b8e
U
uni-app
项目概览
DCloud
/
uni-app
2 天 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
70941b8e
编写于
10月 11, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 重构H5端picker
上级
e4c0e281
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
571 addition
and
758 deletion
+571
-758
src/core/helpers/tags.js
src/core/helpers/tags.js
+0
-1
src/core/view/components/picker/index.vue
src/core/view/components/picker/index.vue
+0
-229
src/platforms/h5/components/app/index.vue
src/platforms/h5/components/app/index.vue
+3
-7
src/platforms/h5/components/app/popup/index.js
src/platforms/h5/components/app/popup/index.js
+1
-3
src/platforms/h5/components/app/popup/mixins/picker.js
src/platforms/h5/components/app/popup/mixins/picker.js
+0
-50
src/platforms/h5/view/components/picker/index.vue
src/platforms/h5/view/components/picker/index.vue
+567
-468
未找到文件。
src/core/helpers/tags.js
浏览文件 @
70941b8e
...
...
@@ -8,7 +8,6 @@ module.exports = [
'
uni-page-refresh
'
,
'
uni-actionsheet
'
,
'
uni-modal
'
,
'
uni-picker
'
,
'
uni-toast
'
,
'
uni-resize-sensor
'
,
...
...
src/core/view/components/picker/index.vue
已删除
100644 → 0
浏览文件 @
e4c0e281
<
template
>
<uni-picker
@
click.stop=
"_click"
>
<div>
<slot/>
</div>
</uni-picker>
</
template
>
<
script
>
import
{
emitter
}
from
'
uni-mixins
'
const
{
subscribe
,
unsubscribe
,
publishHandler
}
=
UniViewJSBridge
const
mode
=
{
SELECTOR
:
'
selector
'
,
MULTISELECTOR
:
'
multiSelector
'
,
TIME
:
'
time
'
,
DATE
:
'
date
'
// 暂不支持城市选择
// REGION: 'region'
}
const
fields
=
{
YEAR
:
'
year
'
,
MONTH
:
'
month
'
,
DAY
:
'
day
'
}
export
default
{
name
:
'
Picker
'
,
mixins
:
[
emitter
],
props
:
{
name
:
{
type
:
String
,
default
:
''
},
range
:
{
type
:
Array
,
default
()
{
return
[]
}
},
rangeKey
:
{
type
:
String
,
default
:
''
},
value
:
{
type
:
[
Number
,
String
,
Array
],
default
:
0
},
mode
:
{
type
:
String
,
default
:
mode
.
SELECTOR
,
validator
(
val
)
{
return
Object
.
values
(
mode
).
indexOf
(
val
)
>=
0
}
},
fields
:
{
type
:
String
,
default
:
'
day
'
,
validator
(
val
)
{
return
Object
.
values
(
fields
).
indexOf
(
val
)
>=
0
}
},
start
:
{
type
:
String
,
default
()
{
if
(
this
.
mode
===
mode
.
TIME
)
{
return
'
00:00
'
}
if
(
this
.
mode
===
mode
.
DATE
)
{
let
year
=
(
new
Date
()).
getFullYear
()
-
100
switch
(
this
.
fields
)
{
case
fields
.
YEAR
:
return
year
case
fields
.
MONTH
:
return
year
+
'
-01
'
case
fields
.
DAY
:
return
year
+
'
-01-01
'
}
}
return
''
}
},
end
:
{
type
:
String
,
default
()
{
if
(
this
.
mode
===
mode
.
TIME
)
{
return
'
23:59
'
}
if
(
this
.
mode
===
mode
.
DATE
)
{
let
year
=
(
new
Date
()).
getFullYear
()
+
100
switch
(
this
.
fields
)
{
case
fields
.
YEAR
:
return
year
case
fields
.
MONTH
:
return
year
+
'
-12
'
case
fields
.
DAY
:
return
year
+
'
-12-31
'
}
}
return
''
}
},
disabled
:
{
type
:
[
Boolean
,
String
],
default
:
false
}
},
data
()
{
return
{
valueSync
:
this
.
value
||
0
,
visible
:
false
,
valueChangeSource
:
''
}
},
watch
:
{
value
(
val
)
{
if
(
Array
.
isArray
(
val
))
{
if
(
!
Array
.
isArray
(
this
.
valueSync
))
{
this
.
valueSync
=
[]
}
this
.
valueSync
.
length
=
val
.
length
val
.
forEach
((
val
,
index
)
=>
{
if
(
val
!==
this
.
valueSync
[
index
])
{
this
.
$set
(
this
.
valueSync
,
index
,
val
)
}
})
}
else
if
(
typeof
val
!==
'
object
'
)
{
this
.
valueSync
=
val
}
},
valueSync
(
val
)
{
if
(
!
this
.
valueChangeSource
)
{
this
.
_show
()
}
else
{
this
.
$emit
(
'
update:value
'
,
val
)
}
}
},
created
()
{
this
.
$dispatch
(
'
Form
'
,
'
uni-form-group-update
'
,
{
type
:
'
add
'
,
vm
:
this
})
Object
.
keys
(
this
.
$props
).
forEach
(
key
=>
{
if
(
key
!==
'
value
'
&&
key
!==
'
name
'
)
{
this
.
$watch
(
key
,
this
.
_show
)
}
})
},
beforeDestroy
()
{
this
.
$dispatch
(
'
Form
'
,
'
uni-form-group-update
'
,
{
type
:
'
remove
'
,
vm
:
this
})
},
destroyed
()
{
if
(
this
.
visible
)
{
const
id
=
this
.
$page
.
id
publishHandler
(
'
hidePicker
'
,
{},
id
)
}
},
methods
:
{
_click
()
{
if
(
this
.
disabled
)
{
return
}
const
id
=
this
.
$page
.
id
subscribe
(
`
${
id
}
-picker-change`
,
this
.
change
)
subscribe
(
`
${
id
}
-picker-columnchange`
,
this
.
columnchange
)
subscribe
(
`
${
id
}
-picker-cancel`
,
this
.
cancel
)
this
.
visible
=
true
this
.
_show
()
},
_show
()
{
if
(
this
.
visible
)
{
const
id
=
this
.
$page
.
id
let
options
=
Object
.
assign
({},
this
.
$props
)
options
.
value
=
this
.
valueSync
publishHandler
(
'
showPicker
'
,
options
,
id
)
}
},
change
(
args
)
{
this
.
visible
=
false
const
id
=
this
.
$page
.
id
unsubscribe
(
`
${
id
}
-picker-change`
)
unsubscribe
(
`
${
id
}
-picker-columnchange`
)
unsubscribe
(
`
${
id
}
-picker-cancel`
)
if
(
!
this
.
disabled
)
{
this
.
valueChangeSource
=
'
click
'
let
value
=
args
.
value
this
.
valueSync
=
Array
.
isArray
(
value
)
?
value
.
map
(
val
=>
val
)
:
value
this
.
$trigger
(
'
change
'
,
{},
{
value
})
}
},
columnchange
(
args
)
{
this
.
$trigger
(
'
columnchange
'
,
{},
args
)
},
cancel
(
args
)
{
this
.
visible
=
false
const
id
=
this
.
$page
.
id
unsubscribe
(
`
${
id
}
-picker-change`
)
unsubscribe
(
`
${
id
}
-picker-columnchange`
)
unsubscribe
(
`
${
id
}
-picker-cancel`
)
this
.
$trigger
(
'
cancel
'
,
{},
{})
},
_getFormData
()
{
return
{
value
:
this
.
valueSync
,
key
:
this
.
name
}
},
_resetFormData
()
{
this
.
valueSync
=
''
}
}
}
</
script
>
<
style
>
uni-picker
{
display
:
block
;
}
</
style
>
src/platforms/h5/components/app/index.vue
浏览文件 @
70941b8e
...
...
@@ -10,21 +10,17 @@
v-if=
"hasTabBar"
v-show=
"showTabBar"
v-bind=
"tabBar"
/>
<toast
<toast
v-if=
"$options.components.Toast"
v-bind=
"showToast"
/>
<action-sheet
<action-sheet
v-if=
"$options.components.ActionSheet"
v-bind=
"showActionSheet"
@
close=
"_onActionSheetClose"
/>
<modal
<modal
v-if=
"$options.components.Modal"
v-bind=
"showModal"
@
close=
"_onModalClose"
/>
<picker
v-if=
"$options.components.Picker"
v-bind=
"showPicker"
@
close=
"_onPickerClose"
/>
</uni-app>
</
template
>
<
script
>
...
...
src/platforms/h5/components/app/popup/index.js
浏览文件 @
70941b8e
import
Toast
from
'
./toast
'
import
Modal
from
'
./modal
'
import
Picker
from
'
./picker
'
import
ActionSheet
from
'
./actionSheet
'
export
default
{
Toast
,
Modal
,
Picker
,
ActionSheet
}
}
src/platforms/h5/components/app/popup/mixins/picker.js
已删除
100644 → 0
浏览文件 @
e4c0e281
const
defaultProps
=
{
visible
:
false
,
mode
:
''
,
range
:
[],
rangeKey
:
''
,
value
:
''
,
disabled
:
false
,
start
:
''
,
end
:
''
,
fields
:
'
day
'
,
customItem
:
''
}
export
default
{
data
()
{
return
{
showPicker
:
{
visible
:
false
}
}
},
created
()
{
// 订阅 View 层的 showPicker 事件
UniServiceJSBridge
.
subscribe
(
'
showPicker
'
,
(
args
,
pageId
)
=>
{
// 根据不同参数,渲染不同类型 picker(注意全局仅一个 picker 组件对象,每次 showPicker 需传入当前类型 picker 的完整参数)
this
.
showPicker
=
Object
.
assign
(
defaultProps
,
args
,
{
pageId
,
visible
:
true
})
})
// 订阅 View 层的 hidePicker 事件
UniServiceJSBridge
.
subscribe
(
'
hidePicker
'
,
()
=>
{
this
.
_onPickerClose
()
})
// 订阅页面返回跳转时触发的 uni.onHidePopup 事件,隐藏 picker
UniServiceJSBridge
.
on
(
'
onHidePopup
'
,
()
=>
{
this
.
_onPickerClose
()
})
},
methods
:
{
// 处理 Picker close 回调
_onPickerClose
()
{
// 隐藏 picker 重置数据
this
.
showPicker
.
visible
=
false
this
.
showPicker
.
mode
=
'
selector
'
this
.
showPicker
.
range
=
[]
this
.
showPicker
.
value
=
0
}
}
}
src/platforms/h5/
components/app/popup/picker
.vue
→
src/platforms/h5/
view/components/picker/index
.vue
浏览文件 @
70941b8e
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录