Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wychl
uni-app
提交
2981847d
U
uni-app
项目概览
wychl
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2981847d
编写于
4月 29, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: app-v3 weex 编译模式 picker 组件使用 webview 版
上级
5146ce00
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
191 addition
and
55 deletion
+191
-55
packages/uni-app-plus/template/weex/__uniapppicker.html
packages/uni-app-plus/template/weex/__uniapppicker.html
+5
-5
packages/uni-cli-shared/template/weex/__uniapppicker.html
packages/uni-cli-shared/template/weex/__uniapppicker.html
+5
-5
src/platforms/app-plus/view/components/picker/index.vue
src/platforms/app-plus/view/components/picker/index.vue
+76
-45
src/platforms/app-plus/view/components/picker/webview.js
src/platforms/app-plus/view/components/picker/webview.js
+105
-0
未找到文件。
packages/uni-app-plus/template/weex/__uniapppicker.html
浏览文件 @
2981847d
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
packages/uni-cli-shared/template/weex/__uniapppicker.html
浏览文件 @
2981847d
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
src/platforms/app-plus/view/components/picker/index.vue
浏览文件 @
2981847d
...
...
@@ -10,6 +10,7 @@
<
script
>
import
{
emitter
}
from
'
uni-mixins
'
import
{
showPage
}
from
'
./page
'
import
*
as
webview
from
'
./webview
'
const
mode
=
{
SELECTOR
:
'
selector
'
,
...
...
@@ -152,6 +153,13 @@ export default {
})
this
.
_setValueSync
()
},
mounted
()
{
webview
.
exists
((
exists
)
=>
{
if
(
exists
)
{
webview
.
initPicker
()
}
})
},
beforeDestroy
()
{
this
.
$dispatch
(
'
Form
'
,
'
uni-form-group-update
'
,
{
type
:
'
remove
'
,
...
...
@@ -195,55 +203,72 @@ export default {
},
_showPicker
(
data
)
{
if
((
data
.
mode
===
mode
.
TIME
||
data
.
mode
===
mode
.
DATE
)
&&
!
data
.
fields
)
{
plus
.
nativeUI
[
this
.
mode
===
mode
.
TIME
?
'
pickTime
'
:
'
pickDate
'
]((
res
)
=>
{
const
date
=
res
.
date
this
.
$trigger
(
'
change
'
,
{},
{
value
:
this
.
mode
===
mode
.
TIME
?
`
${
padLeft
(
date
.
getHours
())}
:
${
padLeft
(
date
.
getMinutes
())}
`
:
`
${
date
.
getFullYear
()}
-
${
padLeft
(
date
.
getMonth
()
+
1
)}
-
${
padLeft
(
date
.
getDate
())}
`
})
},
()
=>
{
this
.
$trigger
(
'
cancel
'
,
{},
{})
},
this
.
mode
===
mode
.
TIME
?
{
time
:
getDate
(
this
.
value
,
mode
.
TIME
)
}
:
{
date
:
getDate
(
this
.
value
,
mode
.
DATE
),
minDate
:
getDate
(
this
.
start
,
mode
.
DATE
),
maxDate
:
getDate
(
this
.
end
,
mode
.
DATE
)
})
this
.
_showNativePicker
(
data
)
}
else
{
data
.
fields
=
Object
.
values
(
fields
).
includes
(
data
.
fields
)
?
data
.
fields
:
fields
.
DAY
let
res
=
{
event
:
'
cancel
'
}
this
.
page
=
showPage
({
url
:
'
__uniapppicker
'
,
data
,
style
:
{
titleNView
:
false
,
animationType
:
'
none
'
,
animationDuration
:
0
,
background
:
'
rgba(0,0,0,0)
'
,
popGesture
:
'
none
'
},
onMessage
:
(
message
)
=>
{
const
event
=
message
.
event
if
(
event
===
'
created
'
)
{
this
.
_updatePicker
(
data
)
return
}
if
(
event
===
'
columnchange
'
)
{
delete
message
.
event
this
.
$trigger
(
event
,
{},
message
)
return
}
res
=
message
},
onClose
:
()
=>
{
this
.
page
=
null
const
event
=
res
.
event
delete
res
.
event
this
.
$trigger
(
event
,
{},
res
)
}
webview
.
exists
((
exists
)
=>
{
this
[
exists
?
'
_showWebviewPicker
'
:
'
_showWeexPicker
'
](
data
)
})
}
},
_showNativePicker
(
data
)
{
plus
.
nativeUI
[
this
.
mode
===
mode
.
TIME
?
'
pickTime
'
:
'
pickDate
'
]((
res
)
=>
{
const
date
=
res
.
date
this
.
$trigger
(
'
change
'
,
{},
{
value
:
this
.
mode
===
mode
.
TIME
?
`
${
padLeft
(
date
.
getHours
())}
:
${
padLeft
(
date
.
getMinutes
())}
`
:
`
${
date
.
getFullYear
()}
-
${
padLeft
(
date
.
getMonth
()
+
1
)}
-
${
padLeft
(
date
.
getDate
())}
`
})
},
()
=>
{
this
.
$trigger
(
'
cancel
'
,
{},
{})
},
this
.
mode
===
mode
.
TIME
?
{
time
:
getDate
(
this
.
value
,
mode
.
TIME
)
}
:
{
date
:
getDate
(
this
.
value
,
mode
.
DATE
),
minDate
:
getDate
(
this
.
start
,
mode
.
DATE
),
maxDate
:
getDate
(
this
.
end
,
mode
.
DATE
)
})
},
_showWeexPicker
(
data
)
{
let
res
=
{
event
:
'
cancel
'
}
this
.
page
=
showPage
({
url
:
'
__uniapppicker
'
,
data
,
style
:
{
titleNView
:
false
,
animationType
:
'
none
'
,
animationDuration
:
0
,
background
:
'
rgba(0,0,0,0)
'
,
popGesture
:
'
none
'
},
onMessage
:
(
message
)
=>
{
console
.
dir
(
message
)
const
event
=
message
.
event
if
(
event
===
'
created
'
)
{
this
.
_updatePicker
(
data
)
return
}
if
(
event
===
'
columnchange
'
)
{
delete
message
.
event
this
.
$trigger
(
event
,
{},
message
)
return
}
res
=
message
},
onClose
:
()
=>
{
this
.
page
=
null
const
event
=
res
.
event
delete
res
.
event
this
.
$trigger
(
event
,
{},
res
)
}
})
},
_showWebviewPicker
(
data
)
{
webview
.
showPicker
(
data
,
(
res
)
=>
{
console
.
dir
(
res
)
const
event
=
res
.
event
delete
res
.
event
this
.
$trigger
(
event
,
{},
res
)
})
},
_getFormData
()
{
return
{
value
:
this
.
valueSync
,
...
...
@@ -267,7 +292,13 @@ export default {
}
},
_updatePicker
(
data
)
{
this
.
page
&&
this
.
page
.
sendMessage
(
data
)
webview
.
exists
((
exists
)
=>
{
if
(
exists
)
{
webview
.
updatePicker
(
data
)
}
else
{
this
.
page
&&
this
.
page
.
sendMessage
(
data
)
}
})
}
}
}
...
...
src/platforms/app-plus/view/components/picker/webview.js
0 → 100644
浏览文件 @
2981847d
const
PICKER_ID
=
'
__UNIAPP_PICKER
'
export
const
PICKER_PATH
=
'
_www/__uniapppicker.html
'
let
pickerWebview
=
null
let
pickerWebviewCreated
=
false
let
_exists
=
null
let
callbacks
=
null
export
function
exists
(
callback
)
{
if
(
_exists
!==
null
)
{
callback
(
_exists
)
return
}
if
(
callbacks
)
{
callbacks
.
push
(
callback
)
return
}
callbacks
=
[
callback
]
function
success
(
exists
)
{
_exists
=
exists
callbacks
.
forEach
(
callback
=>
callback
(
exists
))
callbacks
=
null
}
plus
.
io
.
resolveLocalFileSystemURL
(
PICKER_PATH
,
()
=>
{
success
(
true
)
},
()
=>
{
success
(
false
)
})
}
let
_pickerHideCallback
export
function
initPicker
()
{
if
(
pickerWebview
)
{
return
}
pickerWebview
=
plus
.
webview
.
getWebviewById
(
PICKER_ID
)
if
(
pickerWebview
)
{
pickerWebviewCreated
=
true
}
else
{
pickerWebview
=
plus
.
webview
.
create
(
PICKER_PATH
,
PICKER_ID
,
{
popGesture
:
'
none
'
,
background
:
'
transparent
'
,
backButtonAutoControl
:
'
hide
'
,
render
:
'
always
'
,
kernel
:
'
WKWebview
'
,
bounce
:
'
none
'
,
cachemode
:
'
noCache
'
})
pickerWebview
.
addEventListener
(
'
hide
'
,
()
=>
{
_pickerHideCallback
&&
_pickerHideCallback
()
_pickerHideCallback
=
null
})
window
.
__pickerCallback
=
function
()
{
delete
window
.
__pickerCallback
pickerWebviewCreated
=
true
}
}
}
export
function
showPicker
(
data
=
{},
callback
)
{
data
.
id
=
plus
.
webview
.
currentWebview
().
id
pickerWebview
.
show
(
'
fade-in
'
)
let
res
_pickerHideCallback
=
function
()
{
callback
(
res
||
{
event
:
'
cancel
'
})
}
window
.
__pickerCallback
=
function
({
event
=
'
cancel
'
,
column
,
value
=
-
1
})
{
if
(
event
===
'
created
'
&&
pickerWebview
)
{
pickerWebviewCreated
=
true
pickerWebview
.
evalJS
(
`showPicker(
${
JSON
.
stringify
(
data
)}
)`
)
return
}
if
(
event
===
'
columnchange
'
&&
pickerWebview
)
{
callback
({
event
,
column
,
value
})
}
if
(
event
===
'
change
'
||
event
===
'
cancel
'
)
{
// 赋值为空函数避免 picker-webview 产生多余通讯报错
window
.
__pickerCallback
=
function
()
{
}
res
=
{
event
,
value
}
pickerWebview
.
hide
(
'
fade-out
'
,
100
)
}
}
if
(
pickerWebviewCreated
)
{
pickerWebview
.
evalJS
(
`showPicker(
${
JSON
.
stringify
(
data
)}
)`
)
}
}
export
function
updatePicker
(
data
)
{
if
(
pickerWebviewCreated
)
{
pickerWebview
.
evalJS
(
`showPicker(
${
JSON
.
stringify
(
data
)}
)`
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录