index.vue 953 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. showMenu: true,
  13. // filePath: file,
  14. success(res) {
  15. console.log(res);
  16. var rr = res.tempFilePath;
  17. console.log("成功");
  18. wx.openDocument({
  19. filePath: rr,
  20. showMenu: true,
  21. success() {
  22. wx.navigateBack();
  23. },
  24. fail(e) {
  25. console.log(e);
  26. },
  27. });
  28. },
  29. fail(res) {
  30. console.log(res);
  31. console.log("失败");
  32. },
  33. });
  34. },
  35. };
  36. </script>
  37. <style></style>