shopTour.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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,saveBase64ToAliOss } from '@/libs/tools.js'
  8. export default {
  9. data() {
  10. return {
  11. wv: null,
  12. isClose: false, // 是否关闭当前窗口
  13. isEditImg: false, // 是否正在编辑图片
  14. showPz: false, // 是否正在拍照
  15. types: 'scene', // 巡店类型,默认视频
  16. };
  17. },
  18. methods: {
  19. // 监听html页面事件
  20. onmessage(event) {
  21. let data = event.detail.data[0]
  22. // console.log(data)
  23. // webview 窗口传过来的页面状态
  24. if(data.action == 'getWinStatus'){
  25. let d = JSON.parse(data.msg)
  26. this[d.key] = d.val
  27. }
  28. // 保存编辑后的图片
  29. if(data.action == 'saveEditImg'){
  30. this.uploadImg(data.msg)
  31. }
  32. // 删除考评项
  33. if(data.action == 'delKpItem'){
  34. this.delKpItem(data.msg)
  35. }
  36. },
  37. // 删除考评项
  38. delKpItem(item){
  39. const _this = this;
  40. clzConfirm({
  41. title: '提示',
  42. content: '确定删除此考评项,删除后无法恢复?',
  43. success: function(res) {
  44. if (res.confirm || res.index == 0) {
  45. _this.wv.evalJS("vm.delKpItem("+item+")")
  46. }
  47. }
  48. });
  49. },
  50. // 上传编辑后的图片到阿里云
  51. uploadImg(formData) {
  52. const _this = this;
  53. saveBase64ToAliOss(formData,function(res){
  54. // console.log(res);
  55. // 关闭编辑图片
  56. _this.wv.evalJS("vm.closeImgsEdit()")
  57. // 更新编辑后的图片
  58. _this.wv.evalJS("vm.updateItemImg('"+res.data+"')")
  59. })
  60. }
  61. },
  62. onLoad(options) {
  63. // this.types = options.types
  64. },
  65. onReady() {
  66. let _this = this
  67. // #ifdef APP-PLUS
  68. //获取当前页面的webview对象
  69. var currentWebview = this.$mp.page.$getAppWebview()
  70. //如果是页面初始化调用时,需要延时一下
  71. setTimeout(function() {
  72. _this.wv = currentWebview.children()[0]
  73. _this.wv.evalJS("vm.setTyps('"+_this.types+"')")
  74. }, 500);
  75. // #endif
  76. },
  77. // 监听返回键
  78. onBackPress() {
  79. console.log(this.isEditImg,'onBackPress')
  80. let _this = this
  81. if(!_this.isClose){
  82. // 正在编辑图片
  83. if(this.isEditImg){
  84. // 关闭编辑图片
  85. _this.wv.evalJS("vm.closeImgsEdit()")
  86. }
  87. // 正在拍照
  88. else if(this.showPz){
  89. // 关闭拍照弹框
  90. _this.wv.evalJS("vm.onClosePz()")
  91. }else{
  92. clzConfirm({
  93. title: '提示',
  94. content: '巡店还未完成,确定退出吗?',
  95. success: function(res) {
  96. if (res.confirm || res.index == 0) {
  97. _this.isClose = true
  98. uni.navigateBack({
  99. delta: 1
  100. });
  101. }
  102. }
  103. });
  104. }
  105. return true
  106. }
  107. },
  108. // 添加考评模板
  109. onNavigationBarButtonTap(e) {
  110. // 且当前没编辑图片或抓拍图片
  111. if(e.index==0 && !this.isEditImg && !this.showPz){
  112. console.log(e.text)
  113. uni.navigateTo({
  114. url: '/pages/evaluatePlan/evaluatePlan'
  115. })
  116. }
  117. },
  118. }
  119. </script>
  120. <style>
  121. </style>