tongjiaojiao

有个业务需求,需要在小程序查看客户已开的发票

发票地址:

https://www.chinaeinv.com/p.jspa?cxxxxxxxxxxxx

刚开始是想利用webview当作外链进行跳转访问的

但是存在一个问题,该网页是在公众号内展示的,要预览就要先静默登录

且不是该公众号的开发者,所以实现的可能性比较小

 

不过,微信中有下载预览的api,可以直接拿过来用,从而实现预览

对于我这样的懒汉来说,非常友好

我的文件是固定的pdf格式,所以我是直接将fielType的值,设置为了\'pdf\'

具体的用法见下方:




downloadFile(url) { let _this = this wx.downloadFile({ url: url, success: function(res) { var filePath = res.tempFilePath; console.log(filePath); wx.openDocument({ filePath: filePath, fileType: \'pdf\', success: function(res) { console.log(res); }, fail: function(res) { console.log(res); }, complete: function(res) { console.log(res); } }) }, fail: function(res) { console.log(\'文件下载失败\'); }, complete: function(res) {}, }) }

  

实现方法千千万,就看自己的选择,如果你觉得这种不适合你,还可以选别的鸭

 

 

 

分类:

技术点:

相关文章:

  • 2021-12-11
  • 2021-09-30
  • 2022-02-08
  • 2022-02-27
  • 2022-12-23
  • 2022-03-03
  • 2021-11-02
猜你喜欢
  • 2022-12-23
  • 2022-01-20
  • 2022-01-02
  • 2022-12-23
  • 2021-12-14
  • 2021-11-17
相关资源
相似解决方案