diff --git a/src/core/helpers/protocol/popup.js b/src/core/helpers/protocol/popup.js index a2838be960df944eb30f54593fe63dfbc8bbb602..c2b5ae6890f3fed816ac68448fecf0690c23a2a1 100644 --- a/src/core/helpers/protocol/popup.js +++ b/src/core/helpers/protocol/popup.js @@ -90,10 +90,6 @@ export const showLoading = { visible: { type: Boolean, default: true - }, - isShowLoading: { - type: Boolean, - default: true } } diff --git a/src/core/service/api/popup.js b/src/core/service/api/popup.js index f07488fcc7347849aa29e19f0c3d927409ee9e1c..320c68fe55097393d346c29404af9dfd14a1b9c7 100644 --- a/src/core/service/api/popup.js +++ b/src/core/service/api/popup.js @@ -22,7 +22,7 @@ export function hideToast () { } export function showLoading (args) { - emit('onShowToast', args) + emit('onShowLoading', args) return {} } diff --git a/src/platforms/h5/components/app/popup/mixins/toast.js b/src/platforms/h5/components/app/popup/mixins/toast.js index b27f9e4d23d9c9298f24126f80bba2e9dcfe9185..3dd0be026fd88eb0aa3878738f0b6a5d61088d7b 100644 --- a/src/platforms/h5/components/app/popup/mixins/toast.js +++ b/src/platforms/h5/components/app/popup/mixins/toast.js @@ -7,28 +7,37 @@ export default { } }, created () { - UniServiceJSBridge.on('onShowToast', args => { - setTimeout(() => { // 延迟一下 show 可解决窗口打开前调用 showToast 在 onHidePopup 之后触发 - this.showToast = args - }, 10) - }) + let showType = '' + + const createOnShow = (type) => { + 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) => { return () => { let warnMsg = '' - if (type === 'onHideToast' && this.showToast.isShowLoading) { + if (type === 'onHideToast' && showType !== 'onShowToast') { warnMsg = '请注意 showToast 与 hideToast 必须配对使用' - } else if (type === 'onHideLoading' && !this.showToast.isShowLoading) { + } else if (type === 'onHideLoading' && showType !== 'onShowLoading') { warnMsg = '请注意 showLoading 与 hideLoading 必须配对使用' } if (warnMsg) { return console.warn(warnMsg) - } + } + showType = '' setTimeout(() => { // 与 show 对应延迟10ms,避免快速调用 show,hide 导致无法关闭 this.showToast.visible = false }, 10) } - } + } UniServiceJSBridge.on('onHidePopup', createOnHide('onHidePopup')) UniServiceJSBridge.on('onHideToast', createOnHide('onHideToast')) diff --git a/src/platforms/mp-baidu/service/api/protocols.js b/src/platforms/mp-baidu/service/api/protocols.js index 43ee0a267a039b75dd9ba4a8878272871f13faa9..d44cca231bd9add329c26e62f6111024d429f190 100644 --- a/src/platforms/mp-baidu/service/api/protocols.js +++ b/src/platforms/mp-baidu/service/api/protocols.js @@ -1,4 +1,4 @@ -import previewImage from '../../../mp-weixin/helpers/normalize-preview-image' +import previewImage from '../../../mp-weixin/helpers/normalize-preview-image' // 不支持的 API 列表 const todos = [ 'hideKeyboard', @@ -48,9 +48,14 @@ const protocols = { // TODO // data 不支持 ArrayBuffer // method 不支持 TRACE, CONNECT - // dataType 可取值为 string/json return { - method: 'method' + method: 'method', + dataType (type) { + return { + name: 'dataType', + value: type === 'json' ? type : 'string' + } + } } } }, @@ -96,4 +101,4 @@ export { protocols, todos, canIUses -} +}