shopTour.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view>
  3. <web-view @message="onmessage" src="/hybrid/html/video.html"></web-view>
  4. </view>
  5. </template>
  6. <script>
  7. import { clzConfirm } from '@/libs/tools.js'
  8. export default {
  9. data() {
  10. return {
  11. wv: null,
  12. isClose: false, // 是否关闭当前窗口
  13. isEditImg: false, // 是否正在编辑图片
  14. showPz: false, // 是否正在拍照
  15. };
  16. },
  17. methods: {
  18. onmessage(event) {
  19. let data = event.detail.data[0]
  20. console.log(data)
  21. // webview 窗口传过来的页面状态
  22. if(data.action == 'getWinStatus'){
  23. let d = JSON.parse(data.msg)
  24. this[d.key] = d.val
  25. }
  26. }
  27. },
  28. onReady() {
  29. let _this = this
  30. // #ifdef APP-PLUS
  31. //获取当前页面的webview对象
  32. var currentWebview = this.$mp.page.$getAppWebview()
  33. //如果是页面初始化调用时,需要延时一下
  34. setTimeout(function() {
  35. _this.wv = currentWebview.children()[0]
  36. }, 500);
  37. // #endif
  38. },
  39. // 监听返回键
  40. onBackPress() {
  41. console.log(this.isEditImg,'onBackPress')
  42. let _this = this
  43. if(!_this.isClose){
  44. // 正在编辑图片
  45. if(this.isEditImg){
  46. // 关闭编辑图片
  47. _this.wv.evalJS("vm.closeImgsEdit()")
  48. }
  49. // 正在拍照
  50. else if(this.showPz){
  51. // 关闭拍照弹框
  52. _this.wv.evalJS("vm.onClosePz()")
  53. }else{
  54. clzConfirm({
  55. title: '提示',
  56. content: '巡店还未完成,确定退出吗?',
  57. success: function(res) {
  58. if (res.confirm || res.index == 0) {
  59. _this.isClose = true
  60. uni.navigateBack({
  61. delta: 1
  62. });
  63. }
  64. }
  65. });
  66. }
  67. return true
  68. }
  69. },
  70. onNavigationBarButtonTap(e) {
  71. if(e.index==0){
  72. console.log(e.text)
  73. }
  74. }
  75. }
  76. </script>
  77. <style>
  78. </style>