webview.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 = uni.getStorageSync('session_key')
  20. console.log('监控',typeof this.accessToken)
  21. this.type = options.type
  22. // this.url = "http://8.136.98.49/#/recognition"
  23. this.url = "/static/h52.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken + "&type="+ this.type
  24. // uni.setStorage({
  25. // key: 'obj',
  26. // data: JSON.stringify({
  27. // device_id: this.device_id,
  28. // accessToken: this.accessToken
  29. // })
  30. // })
  31. //设置 webview 界面的状态栏的 title
  32. uni.setNavigationBarTitle({
  33. title: '监控详情'
  34. });
  35. // this.getWebviewPage()
  36. },
  37. methods: {
  38. getWebviewPage(id) {
  39. this.url = "/static/h5.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken
  40. // uni.setStorage({
  41. // key: 'obj',
  42. // data: JSON.stringify({
  43. // device_id: this.device_id,
  44. // accessToken: this.accessToken
  45. // })
  46. // })
  47. //设置 webview 界面的状态栏的 title
  48. uni.setNavigationBarTitle({
  49. title: '监控详情'
  50. });
  51. },
  52. handleMessage(evt) {
  53. console.log('接收到的消息:' + JSON.stringify(evt.detail.data));
  54. }
  55. }
  56. }
  57. </script>
  58. <style>
  59. .webview {
  60. width: 100vw;
  61. height: 100vh;
  62. }
  63. </style>