index.vue 906 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template></template>
  2. <script>
  3. export default {
  4. onLoad: function (options) {
  5. console.log(options);
  6. //小程序主动返回到上一个页面。即从wxpay page到index page。此时index page的webview已经重新加载了url 了
  7. //微信小程序的page 也有栈的概念navigateBack 相当于页面出栈的操作
  8. // debugger
  9. let file = decodeURIComponent(options.url);
  10. wx.downloadFile({
  11. url: options.url,
  12. // filePath: file,
  13. success(res) {
  14. console.log(res);
  15. var rr = res.tempFilePath;
  16. console.log("成功");
  17. wx.openDocument({
  18. filePath: rr,
  19. success() {
  20. wx.navigateBack();
  21. },
  22. fail(e) {
  23. console.log(e);
  24. },
  25. });
  26. },
  27. fail(res) {
  28. console.log(res);
  29. console.log("失败");
  30. },
  31. });
  32. },
  33. };
  34. </script>
  35. <style>
  36. </style>