谢杰标 2 lat temu
rodzic
commit
a18f00eef7
3 zmienionych plików z 48 dodań i 5 usunięć
  1. 39 1
      common/util.js
  2. 0 1
      components/course/handoutsTree.vue
  3. 9 3
      pages2/invoice/index.vue

+ 39 - 1
common/util.js

@@ -1,5 +1,6 @@
 import methods from "@/common/methodTool";
 export function download(url) {
+  url = methods.splitImgHost(url);
   // #ifdef H5
   window.location.href = url;
   // #endif
@@ -34,7 +35,10 @@ function saveImgToLoca(url) {
           uni.getFileSystemManager().saveFile({
             tempFilePath,
             success: function (res) {
-              console.log("🚀 ~ file: util.js:37 ~ uni.getFileSystemManager ~ res:", res)
+              console.log(
+                "🚀 ~ file: util.js:37 ~ uni.getFileSystemManager ~ res:",
+                res
+              );
               uni.showToast({
                 title: "保存成功",
                 icon: "none",
@@ -76,3 +80,37 @@ function saveImgToLoca(url) {
     },
   });
 }
+export function preview(url) {
+  url = methods.splitImgHost(url);
+  // #ifdef H5
+  uni.navigateTo({
+    url: `/pages/webview/sdlink?url=https://preview.xyyxt.net?src=${url}`,
+  });
+  // #endif
+  // #ifdef MP-WEIXIN
+  uni.downloadFile({
+    url: url,
+    success: ({ tempFilePath }) => {
+      uni.openDocument({
+        filePath: tempFilePath,
+        showMenu: true,
+        success: (res) => {},
+        fail: (err) => {
+          uni.showToast({
+            icon: "none",
+            title: "文档地址错误",
+          });
+        },
+      });
+    },
+    fail: (err) => {
+      this.downLoading = false;
+      uni.showModal({
+        title: "提示",
+        content: "文档错误," + err.errMsg,
+        showCancel: false,
+      });
+    },
+  });
+  // #endif
+}

+ 0 - 1
components/course/handoutsTree.vue

@@ -93,7 +93,6 @@ export default {
         url: url,
         success: (res) => {
           var filePath = res.tempFilePath;
-          // h5不支持
           uni.openDocument({
             filePath: filePath,
             showMenu: this.canDownload == 1 ? true : false,

+ 9 - 3
pages2/invoice/index.vue

@@ -644,6 +644,9 @@
                           >下载电子发票</view
                         >
                       </view> -->
+                      <view class="download-btn" @click="preview(invoiceDetail)"
+                        >预览电子发票</view
+                      >
                       <view
                         class="download-btn"
                         @click="download(invoiceDetail)"
@@ -733,7 +736,7 @@
 
 <script>
 import { mapGetters } from "vuex";
-import { download } from "../../common/util";
+import { download, preview } from "../../common/util";
 export default {
   components: {},
   data() {
@@ -1193,7 +1196,10 @@ export default {
     },
 
     download(item) {
-      download(this.$method.splitImgHost(item.invoiceImg));
+      download(item.invoiceImg);
+    },
+    preview(item) {
+      preview(item.invoiceImg);
     },
   },
   computed: {
@@ -1551,7 +1557,7 @@ page {
             }
 
             .download-btn {
-              margin: 10rpx 0 0;
+              margin: 10rpx 0 20rpx;
               text-align: center;
               line-height: 56rpx;
               color: #fff;