webviewPlayback.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <view class="webview">
  3. <web-view
  4. :src="url"
  5. id="webcon"
  6. @message="handleMessage"
  7. :update-title="false"
  8. >
  9. </web-view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. url: '',
  17. device_id: '',
  18. accessToken: '',
  19. };
  20. },
  21. onLoad(options) {
  22. this.device_id = options.device_id;
  23. this.accessToken = options.accessToken;
  24. // this.url = "http://8.136.98.49/#/recognition"
  25. // this.url =
  26. // '/iotPages/static/h52.html?device_id=' +
  27. // this.device_id +
  28. // '&accessToken=' +
  29. // this.accessToken;
  30. //设置 webview 界面的状态栏的 title
  31. // uni.setNavigationBarTitle({
  32. // title: '监控详情'
  33. // });
  34. this.getWebviewPage();
  35. },
  36. methods: {
  37. getWebviewPage() {
  38. this.$myRequest({
  39. url: '/api/api_gateway?method=camera.camera_manage.get_camera_playback_addr',
  40. data: {
  41. device_id: this.device_id,
  42. },
  43. }).then((res) => {
  44. this.url = `https://open.ys7.com/console/jssdk/mobile.html?accessToken=${res.token}&url=${res.ezopen}&themeId=mobileRec&env=`;
  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>