wudebin 7 сар өмнө
parent
commit
dea3b24a6a

+ 28 - 0
WebApp-Lite/api/apiCharge.js

@@ -68,5 +68,33 @@ export default {
       url: base_api + "charging/receipts/" + chargingPk,
       data: {}
     })
+  },
+  /**
+   * 下载收据
+   */
+  downloadRecript(chargingPk) {
+    //#ifdef H5
+    const a = document.createElement('a');
+    a.href = base_api + "charging/download-receipts/" + chargingPk;
+    a.download = 'receipt-' + chargingPk + '.pdf';
+    document.body.appendChild(a);
+    a.click();
+    document.body.removeChild(a);
+    //#endif
+    
+    //#ifndef H5
+    uni.showLoading({
+      title: "Loading..."
+    })
+    uni.downloadFile({
+      url: base_api + "charging/download-receipts/" + chargingPk,
+      success: (res) => {
+        uni.hideLoading();
+      },
+      fail: (err) => {
+        uni.hideLoading();
+      }
+    })
+    //#endif
   }
 }