list.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const WXAPI = require('apifm-wxapi')
  2. const AUTH = require('../../utils/auth')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. invoiceList: []
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. },
  15. onShow: function () {
  16. const _this = this
  17. AUTH.checkHasLogined().then(isLogined => {
  18. if (isLogined) {
  19. WXAPI.invoiceList({
  20. token: wx.getStorageSync('token')
  21. }).then(res => {
  22. if (res.code == 0) {
  23. _this.setData({
  24. invoiceList: res.data.result
  25. })
  26. } else {
  27. _this.setData({
  28. invoiceList: []
  29. })
  30. }
  31. })
  32. } else {
  33. wx.showModal({
  34. title: '提示',
  35. content: '本次操作需要您的登录授权',
  36. cancelText: '暂不登录',
  37. confirmText: '前往登录',
  38. success(res) {
  39. if (res.confirm) {
  40. wx.switchTab({
  41. url: "/pages/my/index"
  42. })
  43. } else {
  44. wx.navigateBack()
  45. }
  46. }
  47. })
  48. }
  49. })
  50. },
  51. download(e) {
  52. const _this = this
  53. const file = e.currentTarget.dataset.file
  54. wx.downloadFile({
  55. url: file,
  56. success (res) {
  57. const tempFilePath = res.tempFilePath
  58. console.log(tempFilePath);
  59. wx.openDocument({
  60. filePath: tempFilePath,
  61. showMenu: true,
  62. success: function (res) {
  63. console.log('打开文档成功')
  64. }
  65. })
  66. }
  67. })
  68. },
  69. })