myFile.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. /**
  58. * 新建档案
  59. */
  60. handleAddFile() {
  61. wx.showModal({
  62. content: '建档人数已达上限',
  63. confirmColor: '#333',
  64. showCancel: false
  65. })
  66. },
  67. /**
  68. * 管理档案
  69. */
  70. handleFile() {
  71. wx.navigateTo({
  72. url: '/pages/handleFile/handleFile',
  73. })
  74. },
  75. handleShowQRCode (e) {
  76. var that = this
  77. var id = e.currentTarget.dataset.id
  78. wx.showLoading({
  79. title: '生成中...'
  80. })
  81. createQRcode({ documentId: id }).then(res => {
  82. wx.hideLoading()
  83. that.setData({
  84. QRCodeBase64: that.data.baseStr + res.data,
  85. qrcodeDialog: true
  86. })
  87. }).catch(e => {
  88. wx.hideLoading()
  89. wx.showModal({
  90. content: e,
  91. confirmColor: '#333',
  92. showCancel: false
  93. })
  94. })
  95. },
  96. handleCloseQRCode () {
  97. this.setData({
  98. qrcodeDialog: false,
  99. QRCodeBase64: ''
  100. })
  101. }
  102. })