wudebin 7 месяцев назад
Родитель
Сommit
dea3b24a6a
1 измененных файлов с 28 добавлено и 0 удалено
  1. 28 0
      WebApp-Lite/api/apiCharge.js

+ 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
   }
 }