chat.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view class="webview-page" type="chat">
  3. <view class="page-container">
  4. <!-- WebView 内容区(自动占满剩余空间,不遮挡导航栏) -->
  5. <view class="web-view-container">
  6. <web-view :src="fileUrl" class="web-view" :webview-styles="webviewStyles" />
  7. </view>
  8. </view>
  9. </view>
  10. </template>
  11. <script setup>
  12. import { ref, computed } from 'vue'
  13. import { onLoad } from '@dcloudio/uni-app'
  14. import useGlobalStore from '@/stores/use-global-store'
  15. const globalStore = useGlobalStore()
  16. import Config from '@/config/index'
  17. const { Host80 } = Config
  18. import getWebBase from '@/utils/webBase'
  19. const webBase = getWebBase()
  20. const fileUrl = `${Host80}/iframe/livechat.html`
  21. const statusBarHeight = computed(() => globalStore.statusBarHeight)
  22. const webviewStyles = computed(() => ({
  23. progress: {
  24. color: '#ea002a'
  25. },
  26. bounce: 'none',
  27. scrollIndicator: 'none',
  28. top: statusBarHeight.value + 'px',
  29. bottom: '0px'
  30. }))
  31. </script>
  32. <style scoped lang="scss">
  33. @import "@/uni.scss";
  34. .webview-page {
  35. :deep(.content-wrapper) {
  36. padding: 0 !important;
  37. }
  38. :deep(.page-content) {
  39. height: calc(100vh - 56px);
  40. }
  41. :deep(.fixed) {
  42. height: 56px;
  43. }
  44. }
  45. /* 页面根容器:弹性布局,完美分配导航栏和web-view高度 */
  46. .page-container {
  47. display: flex;
  48. flex-direction: column;
  49. width: 100%;
  50. height: 100vh;
  51. }
  52. /* 顶部导航栏:正确适配安全区,高度计算正确 */
  53. .web-view-container {
  54. flex: 1;
  55. width: 100%;
  56. overflow: hidden;
  57. }
  58. .web-view {
  59. width: 100%;
  60. height: 100%;
  61. }
  62. </style>