const _Http = getApp().globalData.http; Component({ properties: { disabled: { type: Boolean }, apiId: { type: Number, value: 20221223153403 } }, data: { show: false, "content": { nocache: true, pageNumber: 1, pageTotal: 1, total: null, }, actions: null }, lifetimes: { attached: function () { getApp().globalData.Language.getLanguagePackage(this) } }, methods: { /* 获取发票列表 */ getList(id, init) { let content = this.data.content; content.sa_invoiceapplyid = id; content.sa_orderid = id; if (init) content.pageNumber = 1; _Http.basic({ id: this.data.apiId, content }).then(res => { console.log("发票列表", res) if (res.code != '1') return wx.showToast({ title: res.msg, icon: "none" }); /* res.data[0].paperpdfurl = "https://yostest2.obs.cn-east-2.myhuaweicloud.com:443/202302211676966719291B15c18260.pdf"; res.data[0].pdfurl = "https://yostest2.obs.cn-east-2.myhuaweicloud.com:443/202302211676966719291B15c18260.pdf"; */ this.setData({ list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data), "content.pageNumber": res.pageNumber + 1, "content.pageSize": res.pageSize, "content.pageTotal": res.pageTotal, "content.total": res.total, sa_invoiceapplyid: id, sa_orderid: id }) }) }, previewpdf(e) { let { pdfurl, paperpdfurl } = e.currentTarget.dataset.item; if (!pdfurl && !paperpdfurl) { getApp().globalData.Language.showToast('暂无可预览文件') } else if (pdfurl && paperpdfurl) { this.setData({ actions: [{ name: getApp().globalData.Language.getMapText('查看发票'), value: '查看发票', url: pdfurl }, { name: getApp().globalData.Language.getMapText('查看纸质发票'), value: '查看纸质发票', url: paperpdfurl } ], show: true }) } else { this.handleOpen(pdfurl || paperpdfurl) } }, onClose() { this.setData({ show: false }); }, onSelect(event) { this.handleOpen(event.detail.url) }, handleOpen(url) { wx.showLoading({ title: getApp().globalData.Language.getMapText('加载中...'), mask: true }) wx.downloadFile({ url, success: function (res) { const filePath = res.tempFilePath wx.openDocument({ filePath: filePath, showMenu: true, complete(res) { console.log("打开文档", res) wx.hideLoading() if (res.errMsg != 'openDocument:ok') getApp().globalData.Language.showToast('打开失败') } }) }, fail(err) { wx.hideLoading() getApp().globalData.Language.showToast('打开失败') } }) }, } })