webview.nvue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view>
  3. <view class="uni-navbar">
  4. <view :class="{ 'uni-navbar--fixed': fixed}" :style="{ 'background-color': backgroundColor }"
  5. class="uni-navbar__content">
  6. <view :style="{ height: statusBarHeight }" class="uni-status-bar"></view>
  7. <view :style="{ color: color,backgroundColor: backgroundColor }" class="uni-navbar__header uni-navbar__content_view">
  8. <view class="uni-navbar__header-container " @click="BackPage">
  9. <view class="uni-navbar__header-btns uni-navbar__header-btns-left ">
  10. <view class="uni-navbar-btn-text uni-navbar__content_view">
  11. <text :style="{ color: color, fontSize: '16px' }"><返回</text>
  12. </view>
  13. </view>
  14. <view class="uni-navbar__header-container-inner " >
  15. <text class="uni-nav-bar-text" :style="{color: color }">{{ title }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view>
  22. <web-view :src="url" :style="'width:'+screenWidth+';height:' +screenHeight+';'" :webview-styles="webviewStyles"></web-view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. const app = getApp();
  28. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'
  29. var screenHeight = (uni.getSystemInfoSync().screenHeight-80) + 'px'
  30. var screenWidth = uni.getSystemInfoSync().screenWidth + 'px'
  31. export default {
  32. data() {
  33. return {
  34. globalData: app.globalData,
  35. url:"",
  36. title:'浏览',
  37. fixed: false,
  38. color: "#000000",
  39. backgroundColor: "#FFFFFF",
  40. statusBarHeight: statusBarHeight,
  41. screenHeight: screenHeight,
  42. screenWidth: screenWidth,
  43. webviewStyles: {
  44. progress: {
  45. color: '#FF3333'
  46. }
  47. }
  48. }
  49. },
  50. onLoad: function(option) {
  51. this.url = option.url;
  52. if(option.title){
  53. this.title = option.title;
  54. uni.setNavigationBarTitle({
  55. title:option.title,
  56. })
  57. }
  58. },
  59. onShow() {
  60. },
  61. methods: {
  62. BackPage() {
  63. uni.navigateBack();
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .uni-status-bar {
  70. width: 750rpx;
  71. height: 20px;
  72. // height: var(--status-bar-height);
  73. }
  74. $nav-height: 44px;
  75. .uni-nav-bar-text {
  76. /* #ifdef APP-PLUS */
  77. font-size: 34rpx;
  78. /* #endif */
  79. /* #ifndef APP-PLUS */
  80. font-size: $uni-font-size-lg;
  81. /* #endif */
  82. }
  83. .uni-nav-bar-right-text {
  84. font-size: $uni-font-size-base;
  85. }
  86. .uni-navbar {
  87. width: 750rpx;
  88. }
  89. .uni-navbar__content {
  90. position: relative;
  91. width: 750rpx;
  92. background-color: $uni-bg-color;
  93. overflow: hidden;
  94. }
  95. .uni-navbar__content_view {
  96. /* #ifndef APP-NVUE */
  97. display: flex;
  98. /* #endif */
  99. align-items: center;
  100. flex-direction: row;
  101. // background-color: #FFFFFF;
  102. }
  103. .uni-navbar__header {
  104. /* #ifndef APP-NVUE */
  105. display: flex;
  106. /* #endif */
  107. flex-direction: row;
  108. width: 750rpx;
  109. height: $nav-height;
  110. line-height: $nav-height;
  111. font-size: 16px;
  112. // background-color: #ffffff;
  113. }
  114. .uni-navbar__header-btns {
  115. /* #ifndef APP-NVUE */
  116. display: flex;
  117. /* #endif */
  118. flex-wrap: nowrap;
  119. width: 120rpx;
  120. padding: 0 6px;
  121. justify-content: center;
  122. align-items: center;
  123. }
  124. .uni-navbar__header-btns-left {
  125. /* #ifndef APP-NVUE */
  126. display: flex;
  127. /* #endif */
  128. width: 150rpx;
  129. justify-content: flex-start;
  130. }
  131. .uni-navbar__header-btns-right {
  132. /* #ifndef APP-NVUE */
  133. display: flex;
  134. /* #endif */
  135. width: 150rpx;
  136. padding-right: 30rpx;
  137. justify-content: flex-end;
  138. }
  139. .uni-navbar__header-container {
  140. flex: 1;
  141. }
  142. .uni-navbar__header-container-inner {
  143. /* #ifndef APP-NVUE */
  144. display: flex;
  145. /* #endif */
  146. flex: 1;
  147. align-items: center;
  148. justify-content: center;
  149. font-size: $uni-font-size-base;
  150. margin-top: -40rpx;
  151. }
  152. .uni-navbar__placeholder-view {
  153. height: $nav-height;
  154. }
  155. .uni-navbar--fixed {
  156. position: fixed;
  157. z-index: 998;
  158. }
  159. .uni-navbar--shadow {
  160. /* #ifndef APP-NVUE */
  161. box-shadow: 0 1px 6px #ccc;
  162. /* #endif */
  163. }
  164. .uni-navbar--border {
  165. border-bottom-width: 1rpx;
  166. border-bottom-style: solid;
  167. border-bottom-color: $uni-border-color;
  168. }
  169. </style>