chat.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. import getWebBase from '@/utils/webBase'
  18. const webBase = getWebBase()
  19. const fileUrl = computed(() => `${Config.Host80}/iframe/livechat.html`)
  20. const statusBarHeight = computed(() => globalStore.statusBarHeight)
  21. const webviewStyles = computed(() => ({
  22. progress: {
  23. color: '#ea002a'
  24. },
  25. bounce: 'none',
  26. scrollIndicator: 'none',
  27. top: statusBarHeight.value + 'px',
  28. bottom: '0px'
  29. }))
  30. </script>
  31. <style scoped lang="scss">
  32. @import "@/uni.scss";
  33. .webview-page {
  34. :deep(.content-wrapper) {
  35. padding: 0 !important;
  36. }
  37. :deep(.page-content) {
  38. height: calc(100vh - 56px);
  39. }
  40. :deep(.fixed) {
  41. height: 56px;
  42. }
  43. }
  44. /* 页面根容器:弹性布局,完美分配导航栏和web-view高度 */
  45. .page-container {
  46. display: flex;
  47. flex-direction: column;
  48. width: 100%;
  49. height: 100vh;
  50. }
  51. /* 顶部导航栏:正确适配安全区,高度计算正确 */
  52. .web-view-container {
  53. flex: 1;
  54. width: 100%;
  55. overflow: hidden;
  56. }
  57. .web-view {
  58. width: 100%;
  59. height: 100%;
  60. }
  61. </style>