diff --git a/src/core/helpers/protocol/popup.js b/src/core/helpers/protocol/popup.js index c2b5ae6890f3fed816ac68448fecf0690c23a2a1..a2838be960df944eb30f54593fe63dfbc8bbb602 100644 --- a/src/core/helpers/protocol/popup.js +++ b/src/core/helpers/protocol/popup.js @@ -90,6 +90,10 @@ 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 13db31a000d27f2793495c3d250e986bce1d4115..f07488fcc7347849aa29e19f0c3d927409ee9e1c 100644 --- a/src/core/service/api/popup.js +++ b/src/core/service/api/popup.js @@ -27,7 +27,7 @@ export function showLoading (args) { } export function hideLoading () { - emit('onHideToast') + emit('onHideLoading') return {} } diff --git a/src/core/service/plugins/util.js b/src/core/service/plugins/util.js index f4df38b735b9cd09cdc0bc52b115bd52ce2f304d..ed93c3bafa41759dba473cba9571851e3da7582f 100644 --- a/src/core/service/plugins/util.js +++ b/src/core/service/plugins/util.js @@ -6,7 +6,7 @@ export function callAppHook (vm, hook, params) { if (hook !== 'onError') { console.debug(`App:${hook} have been invoked` + (params ? ` ${JSON.stringify(params)}` : '')) } - return callHook(vm, hook, params) + return vm.__call_hook(hook, params) } export function callPageHook (vm, hook, params) { diff --git a/src/platforms/h5/components/app/index.vue b/src/platforms/h5/components/app/index.vue index 1718eeedfff1b2f5e54de470d1f325cd0ec471f5..9b1b17ac79e9c07c7241955afa7d1d3233692d70 100644 --- a/src/platforms/h5/components/app/index.vue +++ b/src/platforms/h5/components/app/index.vue @@ -11,8 +11,7 @@ v-show="showTabBar" v-bind="tabBar" /> + v-bind="showToast"/> diff --git a/src/platforms/h5/components/app/popup/mixins/toast.js b/src/platforms/h5/components/app/popup/mixins/toast.js index 4b193c60e50b1454f578395ca826474cf053d1bf..b27f9e4d23d9c9298f24126f80bba2e9dcfe9185 100644 --- a/src/platforms/h5/components/app/popup/mixins/toast.js +++ b/src/platforms/h5/components/app/popup/mixins/toast.js @@ -8,14 +8,30 @@ export default { }, created () { UniServiceJSBridge.on('onShowToast', args => { - setTimeout(() => { // 延迟一下 show 可解决窗口打开前调用 showToast,showLoading 在 onHidePopup 之后触发 + setTimeout(() => { // 延迟一下 show 可解决窗口打开前调用 showToast 在 onHidePopup 之后触发 this.showToast = args }, 10) }) - UniServiceJSBridge.on(['onHidePopup', 'onHideToast'], args => { - setTimeout(() => { // 与 show 对应延迟10ms,避免快速调用 show,hide 导致无法关闭 - this.showToast.visible = false - }, 10) - }) + + const createOnHide = (type) => { + return () => { + let warnMsg = '' + if (type === 'onHideToast' && this.showToast.isShowLoading) { + warnMsg = '请注意 showToast 与 hideToast 必须配对使用' + } else if (type === 'onHideLoading' && !this.showToast.isShowLoading) { + warnMsg = '请注意 showLoading 与 hideLoading 必须配对使用' + } + if (warnMsg) { + return console.warn(warnMsg) + } + setTimeout(() => { // 与 show 对应延迟10ms,避免快速调用 show,hide 导致无法关闭 + this.showToast.visible = false + }, 10) + } + } + + UniServiceJSBridge.on('onHidePopup', createOnHide('onHidePopup')) + UniServiceJSBridge.on('onHideToast', createOnHide('onHideToast')) + UniServiceJSBridge.on('onHideLoading', createOnHide('onHideLoading')) } } diff --git a/src/platforms/h5/components/app/popup/modal.vue b/src/platforms/h5/components/app/popup/modal.vue index 9c54ede7b60943d388a032e0afa865d7bddf6124..c53e5153662f7a9822384eb8b027c2ba7d47c094 100644 --- a/src/platforms/h5/components/app/popup/modal.vue +++ b/src/platforms/h5/components/app/popup/modal.vue @@ -113,7 +113,7 @@ export default { font-size: 18px; word-wrap:break-word; word-break:break-all; - white-space: pre; + white-space: pre-wrap; overflow : hidden; text-overflow: ellipsis; display: -webkit-box; @@ -128,7 +128,7 @@ export default { line-height: 1.4; word-wrap: break-word; word-break: break-all; - white-space: pre; + white-space: pre-wrap; color: #999999; max-height: 400px; overflow-y: auto;