test.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="rf-category" style="height: 100%">
  3. <!--搜索导航栏-->
  4. <view class="icoStyle">
  5. <u-navbar :back-text="i18n('Back')" :title="i18n('ResearchResources')+i18n('resourceDetails')" :background="barBackground"
  6. back-icon-color="white" title-color="white" :back-text-style="backStyle">
  7. </u-navbar>
  8. </view>
  9. <web-view :src="url" style="height: 100;top: 88upx;overflow-y:hidden"></web-view>
  10. </view>
  11. </template>
  12. <script>
  13. /**
  14. * option : url
  15. * */
  16. var wv;
  17. var currentWebview;
  18. const { windowWidth, windowHeight } = uni.getSystemInfoSync();
  19. export default {
  20. data() {
  21. return {
  22. ifShare:false,
  23. barBackground: {
  24. backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
  25. },
  26. backStyle: {
  27. color: '#fff'
  28. },
  29. barHeight:'',
  30. webViewHeight:'',
  31. url:null,
  32. }
  33. },
  34. async onShow() {
  35. },
  36. async onLoad(option) {
  37. this.url = option.url;
  38. // #ifdef APP-PLUS
  39. currentWebview = this.$scope.$getAppWebview();
  40. setTimeout(function() {
  41. wv = currentWebview.children()[0];
  42. wv.setStyle({height:0})
  43. }, 500);
  44. // #endif
  45. },
  46. watch:{
  47. },
  48. mounted(){
  49. this.getBarHeight()
  50. this.openWebView()
  51. },
  52. methods: {
  53. async getBarHeight(){
  54. const query = uni.createSelectorQuery().in(this);
  55. query.select('.icoStyle').boundingClientRect(data => {
  56. this.barHeight = data.height;
  57. this.webViewHeight = windowHeight-this.barHeight
  58. }).exec();
  59. },
  60. async openWebView(){
  61. const that = this
  62. // #ifdef APP-PLUS
  63. setTimeout(function() {
  64. wv.setStyle({top:that.barHeight,height:that .webViewHeight})
  65. // let commonrightd = document.getElementsByClassName("body-bg");
  66. // console.log(commonrightd)
  67. }, 500);
  68. let commonrightd = document.getElementsByClassName("body-bg");
  69. console.log(commonrightd)
  70. // #endif
  71. },
  72. back() {
  73. uni.navigateBack();
  74. },
  75. //中英文切换
  76. i18n (data) {
  77. return this.$t('common.'+data);
  78. },
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .icoStyle {
  84. display: flex;
  85. align-items:center;
  86. .leftArrow {
  87. width:36upx;
  88. height:36upx;
  89. position: fixed;
  90. z-index: 99;
  91. /* #ifdef APP-PLUS */
  92. padding-top: calc(20upx + var(--status-bar-height));
  93. /* #endif */
  94. }
  95. }
  96. </style>