myFile.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { documentList, createQRcode } from "../../api/document";
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. qrcodeDialog: false,
  8. currentPage: 1,
  9. hasNext: false,
  10. fileList: [],
  11. baseStr: 'data:image/jpg;base64,',
  12. QRCodeBase64: ''
  13. },
  14. /**
  15. * 生命周期函数--监听页面显示
  16. */
  17. onShow() {
  18. this.getDocumentList()
  19. },
  20. // 获取档案列表
  21. getDocumentList () {
  22. var data = {
  23. currentPage: this.data.currentPage
  24. }
  25. wx.showLoading({
  26. title: '加载中...',
  27. mask: true
  28. })
  29. documentList(data).then(res => {
  30. wx.hideLoading()
  31. var response = res.data.vos
  32. response.map(item => {
  33. item.birthDay = item.birthday.split(' ')[0]
  34. })
  35. this.setData({
  36. hasNext: res.data.hasNext,
  37. fileList: response
  38. })
  39. }).catch(e => {
  40. wx.hideLoading()
  41. wx.showModal({
  42. content: e,
  43. confirmColor: '#333',
  44. showCancel: false
  45. })
  46. })
  47. },
  48. onReachBottom () {
  49. if (this.data.hasNext) {
  50. var _currentPag = this.data.currentPage + 1
  51. this.setData({
  52. currentPage: _currentPag
  53. })
  54. this.getDocumentList()
  55. }
  56. },
  57. handleReportDetail (e) {
  58. var reportid = e.currentTarget.dataset.reportid
  59. wx.navigateTo({
  60. url: '/pages/reportDetail/reportDetail?reportid=' + reportid
  61. })
  62. },
  63. /**
  64. * 新建档案
  65. */
  66. handleAddFile() {
  67. wx.navigateTo({
  68. url: '/pages/createFile/createFile?from=myFile'
  69. })
  70. },
  71. /**
  72. * 管理档案
  73. */
  74. handleFile() {
  75. if (this.data.fileList.length !== 0) {
  76. wx.navigateTo({
  77. url: '/pages/handleFile/handleFile',
  78. })
  79. } else {
  80. wx.showToast({
  81. title: '暂无档案',
  82. icon: 'error'
  83. })
  84. }
  85. },
  86. handleShowQRCode (e) {
  87. var that = this
  88. var id = e.currentTarget.dataset.id
  89. wx.showLoading({
  90. title: '生成中...'
  91. })
  92. createQRcode({ documentId: id }).then(res => {
  93. wx.hideLoading()
  94. that.setData({
  95. QRCodeBase64: that.data.baseStr + res.data,
  96. qrcodeDialog: true
  97. })
  98. }).catch(e => {
  99. wx.hideLoading()
  100. wx.showModal({
  101. content: e,
  102. confirmColor: '#333',
  103. showCancel: false
  104. })
  105. })
  106. },
  107. handleCloseQRCode () {
  108. this.setData({
  109. qrcodeDialog: false,
  110. QRCodeBase64: ''
  111. })
  112. }
  113. })