webview.nvue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class="webview-page">
  3. <view class="status-bar" :style="{height: statusBarHeight + 'px'}"></view>
  4. <view class="custom-head">
  5. <text class="back-btn" @click="goBack">← 返回</text>
  6. <text class="head-title">{{ title }}</text>
  7. <view class="placeholder"></view>
  8. </view>
  9. <web-view :src="url" class="web-content"></web-view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. id: '',
  17. title: '',
  18. url: '',
  19. statusBarHeight: 44
  20. }
  21. },
  22. created() {
  23. const sysInfo = uni.getSystemInfoSync()
  24. this.statusBarHeight = sysInfo.statusBarHeight || 44
  25. },
  26. onLoad(options) {
  27. this.id = options.id || ''
  28. if (this.id === '1') {
  29. this.title = '用户协议'
  30. this.url = 'http://8.155.56.12:8081/profile/upload/userAgreement.html'
  31. } else if (this.id === '2') {
  32. this.title = '隐私政策'
  33. this.url = 'http://8.155.56.12:8081/profile/upload/privatery.html'
  34. }
  35. },
  36. methods: {
  37. goBack() {
  38. uni.navigateBack()
  39. }
  40. }
  41. }
  42. </script>
  43. <style>
  44. .webview-page {
  45. flex: 1;
  46. background-color: #ffffff;
  47. }
  48. .status-bar {
  49. background-color: #ffffff;
  50. }
  51. .custom-head {
  52. flex-direction: row;
  53. align-items: center;
  54. justify-content: space-between;
  55. height: 100rpx;
  56. padding-left: 30rpx;
  57. padding-right: 30rpx;
  58. background-color: #ffffff;
  59. border-bottom-width: 1px;
  60. border-bottom-color: #eeeeee;
  61. border-bottom-style: solid;
  62. }
  63. .back-btn {
  64. font-size: 34rpx;
  65. color: #333333;
  66. }
  67. .head-title {
  68. font-size: 36rpx;
  69. font-weight: bold;
  70. color: #333333;
  71. }
  72. .placeholder {
  73. width: 80rpx;
  74. }
  75. .web-content {
  76. flex: 1;
  77. }
  78. </style>