提交 55a3015c 编写于 作者: fxy060608's avatar fxy060608
上级 2a7d59c0
...@@ -90,10 +90,6 @@ export const showLoading = { ...@@ -90,10 +90,6 @@ export const showLoading = {
visible: { visible: {
type: Boolean, type: Boolean,
default: true default: true
},
isShowLoading: {
type: Boolean,
default: true
} }
} }
......
...@@ -22,7 +22,7 @@ export function hideToast () { ...@@ -22,7 +22,7 @@ export function hideToast () {
} }
export function showLoading (args) { export function showLoading (args) {
emit('onShowToast', args) emit('onShowLoading', args)
return {} return {}
} }
......
...@@ -7,28 +7,37 @@ export default { ...@@ -7,28 +7,37 @@ export default {
} }
}, },
created () { created () {
UniServiceJSBridge.on('onShowToast', args => { let showType = ''
setTimeout(() => { // 延迟一下 show 可解决窗口打开前调用 showToast 在 onHidePopup 之后触发
this.showToast = args const createOnShow = (type) => {
}, 10) return (args) => {
}) showType = type
setTimeout(() => { // 延迟一下 show 可解决窗口打开前调用 showToast 在 onHidePopup 之后触发
this.showToast = args
}, 10)
}
}
UniServiceJSBridge.on('onShowToast', createOnShow('onShowToast'))
UniServiceJSBridge.on('onShowLoading', createOnShow('onShowLoading'))
const createOnHide = (type) => { const createOnHide = (type) => {
return () => { return () => {
let warnMsg = '' let warnMsg = ''
if (type === 'onHideToast' && this.showToast.isShowLoading) { if (type === 'onHideToast' && showType !== 'onShowToast') {
warnMsg = '请注意 showToast 与 hideToast 必须配对使用' warnMsg = '请注意 showToast 与 hideToast 必须配对使用'
} else if (type === 'onHideLoading' && !this.showToast.isShowLoading) { } else if (type === 'onHideLoading' && showType !== 'onShowLoading') {
warnMsg = '请注意 showLoading 与 hideLoading 必须配对使用' warnMsg = '请注意 showLoading 与 hideLoading 必须配对使用'
} }
if (warnMsg) { if (warnMsg) {
return console.warn(warnMsg) return console.warn(warnMsg)
} }
showType = ''
setTimeout(() => { // 与 show 对应延迟10ms,避免快速调用 show,hide 导致无法关闭 setTimeout(() => { // 与 show 对应延迟10ms,避免快速调用 show,hide 导致无法关闭
this.showToast.visible = false this.showToast.visible = false
}, 10) }, 10)
} }
} }
UniServiceJSBridge.on('onHidePopup', createOnHide('onHidePopup')) UniServiceJSBridge.on('onHidePopup', createOnHide('onHidePopup'))
UniServiceJSBridge.on('onHideToast', createOnHide('onHideToast')) UniServiceJSBridge.on('onHideToast', createOnHide('onHideToast'))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册