webviewdgp.vue 1.7 KB

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