修改用电查询电表选择问题

This commit is contained in:
2024-05-07 13:50:33 +08:00
parent 19ba67134f
commit 1e92bb8bcf
5 changed files with 55 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
import { getInvoiceInfoDetail, downloadInvoice } from "../../service/invoice";
import { alertInfo } from "../../utils/index";
import { alertInfo, loadingFunc } from "../../utils/index";
import request from '../../utils/request'
const { OK } = request;
// pages/invoiceInfo/index.js
@@ -33,34 +33,34 @@ Page({
})
},
download() {
// console.log('---------')
const that = this;
wx.showActionSheet({
itemList: ['发票XML文件下载', '发票PDF文件下载'],
async success(res) {
console.log('res', res.tapIndex)
const { code, message, data } = await downloadInvoice(that.data.id, res.tapIndex);
if (code !== OK) {
alertInfo(message)
return;
}
wx.downloadFile({
url: data,
success(res) {
if (res.statusCode === 200) {
wx.openDocument({
filePath: res.tempFilePath,
fileType: [res.tapIndex === 0 ? 'xml' : "pdf"], // 3. 这个必须写合法类型,不然下载不了
success: function (res) {
console.log('打开文档成功')
},
fail: function (e) {
console.log(e.errMsg);
}
})
}
loadingFunc(async () => {
const { code, message, data } = await downloadInvoice(that.data.id, res.tapIndex);
if (code !== OK) {
alertInfo(message)
return;
}
wx.downloadFile({
url: data,
success(res) {
if (res.statusCode === 200) {
wx.openDocument({
filePath: res.tempFilePath,
fileType: [res.tapIndex === 0 ? 'xml' : "pdf"], // 3. 这个必须写合法类型,不然下载不了
success: function (res) {
},
fail: function (e) {
}
})
}
}
})
})