myFile.js 2.4 KB

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