testResultImg.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_test = require("../api/test.js");
  4. require("../common/request.js");
  5. const _sfc_main = {
  6. name: "Poster",
  7. components: {},
  8. props: {},
  9. data: function() {
  10. return {
  11. url: null
  12. };
  13. },
  14. mounted: function() {
  15. this.getTestReportImg();
  16. },
  17. methods: {
  18. shareImg: function() {
  19. wx.downloadFile({
  20. url: this.url,
  21. success: (res) => {
  22. wx.showShareImageMenu({
  23. path: res.tempFilePath
  24. });
  25. }
  26. });
  27. },
  28. getTestReportImg: function() {
  29. let that = this;
  30. var data = {
  31. reportId: this.reportId
  32. };
  33. api_test.getTestReportImg(data).then((res) => {
  34. that.url = res.url;
  35. }, (err) => {
  36. common_vendor.index.showToast({
  37. title: err.msg,
  38. icon: "none",
  39. duration: 2e3
  40. });
  41. });
  42. },
  43. downloadIamge(imgsrc, name) {
  44. var that = this;
  45. this.isDown = true;
  46. var downloadUrl = imgsrc;
  47. that.downloadFile(downloadUrl);
  48. },
  49. saveImg: function() {
  50. this.downloadIamge(this.url, "poster");
  51. },
  52. downloadFile(url) {
  53. console.log(url);
  54. common_vendor.index.showLoading({
  55. title: "\u56FE\u7247\u4FDD\u5B58\u4E2D..."
  56. });
  57. common_vendor.index.downloadFile({
  58. url,
  59. fail: function(res) {
  60. common_vendor.index.showModal({
  61. title: "\u63D0\u793A",
  62. content: "\u4FDD\u5B58\u5931\u8D25"
  63. });
  64. },
  65. success: function(res) {
  66. console.log(res);
  67. var tempFilePath = res.tempFilePath;
  68. common_vendor.index.saveImageToPhotosAlbum({
  69. filePath: tempFilePath,
  70. success: () => {
  71. common_vendor.index.showToast({
  72. title: "\u4FDD\u5B58\u6210\u529F",
  73. duration: 2e3
  74. });
  75. },
  76. fail: () => {
  77. console.log("saveImageToPhotosAlbum \u5931\u8D25");
  78. common_vendor.index.hideLoading();
  79. },
  80. complete: function() {
  81. common_vendor.index.hideLoading();
  82. }
  83. });
  84. }
  85. });
  86. }
  87. }
  88. };
  89. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  90. return {
  91. a: _ctx.url,
  92. b: common_vendor.o(($event) => $options.shareImg())
  93. };
  94. }
  95. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_index/testResultImg.vue"]]);
  96. wx.createPage(MiniProgramPage);