webview.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view class="webview">
  3. <web-view :src="url" id="webcon" @message="handleMessage">
  4. </web-view>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. url: '',
  12. device_id: '',
  13. accessToken: '',
  14. type:''
  15. }
  16. },
  17. onLoad(options) {
  18. this.device_id = options.device_id
  19. this.accessToken = options.accessToken
  20. this.type = options.type
  21. // this.url = "http://8.136.98.49/#/recognition"
  22. this.url = "/static/h52.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken + "&type="+ this.type
  23. // uni.setStorage({
  24. // key: 'obj',
  25. // data: JSON.stringify({
  26. // device_id: this.device_id,
  27. // accessToken: this.accessToken
  28. // })
  29. // })
  30. //设置 webview 界面的状态栏的 title
  31. uni.setNavigationBarTitle({
  32. title: '监控详情'
  33. });
  34. // this.getWebviewPage()
  35. },
  36. methods: {
  37. getWebviewPage(id) {
  38. this.url = "/static/h5.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken
  39. // uni.setStorage({
  40. // key: 'obj',
  41. // data: JSON.stringify({
  42. // device_id: this.device_id,
  43. // accessToken: this.accessToken
  44. // })
  45. // })
  46. //设置 webview 界面的状态栏的 title
  47. uni.setNavigationBarTitle({
  48. title: '监控详情'
  49. });
  50. },
  51. handleMessage(evt) {
  52. console.log('接收到的消息:' + JSON.stringify(evt.detail.data));
  53. }
  54. }
  55. }
  56. </script>
  57. <style>
  58. .webview {
  59. width: 100vw;
  60. height: 100vh;
  61. }
  62. </style>