shopTour.vue 2.8 KB

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