handleFile.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // pages/handleFile/handleFile.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. fileList: [
  8. {
  9. name: '测试用户',
  10. date: '1995/12',
  11. choseFlag: false
  12. },
  13. {
  14. name: '汪渊',
  15. date: '1993/02',
  16. choseFlag: false
  17. }
  18. ],
  19. delFileList: []
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad(options) {
  25. },
  26. /**
  27. * 生命周期函数--监听页面初次渲染完成
  28. */
  29. onReady() {
  30. },
  31. /**
  32. * 生命周期函数--监听页面显示
  33. */
  34. onShow() {
  35. this.initDelList()
  36. },
  37. /**
  38. * 生命周期函数--监听页面隐藏
  39. */
  40. onHide() {
  41. },
  42. /**
  43. * 生命周期函数--监听页面卸载
  44. */
  45. onUnload() {
  46. },
  47. /**
  48. * 删除文档
  49. */
  50. handleDelFile() {
  51. var that = this
  52. var flag = this.data.delFileList.find(item => {
  53. return item == true
  54. })
  55. if (!flag) {
  56. wx.showToast({
  57. title: '请选择删除的档案!',
  58. icon: 'error',
  59. mask: true,
  60. duration: 2000
  61. })
  62. } else {
  63. wx.showModal({
  64. content: '确定要删除档案信息吗相对应的体检报告也会相应删除哦!',
  65. cancelColor: '#666',
  66. confirmColor: '#333',
  67. success (res) {
  68. if (res.confirm) {
  69. that.handleConfirm()
  70. }
  71. }
  72. })
  73. }
  74. },
  75. /* 确定 */
  76. handleConfirm () {
  77. wx.showLoading({
  78. title: '加载中...',
  79. mask: true
  80. })
  81. setTimeout(() => {
  82. wx.hideLoading({
  83. success: (res) => {},
  84. })
  85. }, 2000);
  86. },
  87. /**
  88. * 用户点击 单选radio
  89. */
  90. handleRadio (e) {
  91. var choseIndex = e.currentTarget.dataset.index
  92. var currentList = this.data.fileList
  93. currentList[choseIndex].choseFlag = !currentList[choseIndex].choseFlag
  94. this.setData({
  95. fileList: currentList
  96. })
  97. this.initDelList()
  98. },
  99. /* 处理删除的数据 */
  100. initDelList () {
  101. var currentList = this.data.fileList
  102. var _a = []
  103. currentList.map(item => {
  104. _a.push(item.choseFlag)
  105. })
  106. this.setData({
  107. delFileList: _a
  108. })
  109. }
  110. })