facephoto.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. const util = require('../../../utils/util.js');
  2. const api = require('../../../utils/api.js');
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. apiTotal: '',
  10. userInfo: '',
  11. isregiste: true,
  12. arrayCollege: [],
  13. listCollege: '',
  14. indexCollege: 0,
  15. arrayDept: [],
  16. listDept: '',
  17. indexDept: 0,
  18. arrayClass: [],
  19. indexClass: 0,
  20. listClass: '',
  21. registerCount: '',
  22. unRegisterCount: '',
  23. list: []
  24. },
  25. checkTab: function(e) {
  26. const that = this;
  27. that.setData({
  28. isregiste: !that.data.isregiste
  29. })
  30. if (that.data.isregiste) {
  31. that.getRegisterInfo(0)
  32. } else {
  33. that.getRegisterInfo(1)
  34. }
  35. },
  36. pickerChangeCollege: function(e) {
  37. this.setData({
  38. indexCollege: e.detail.value
  39. })
  40. this.getDeptInfo();
  41. },
  42. pickerChangeDept: function(e) {
  43. this.setData({
  44. indexDept: e.detail.value
  45. })
  46. this.getDeptInfo();
  47. },
  48. pickerChangeClass: function(e) {
  49. this.setData({
  50. indexClass: e.detail.value
  51. })
  52. this.getDeptInfo();
  53. },
  54. getCollegeInfo: function(e) {
  55. const that = this;
  56. util.httpRequest(api.getDeptInfo, {
  57. companyId: that.data.userInfo.companyId,
  58. level: 1
  59. }, 'post').then(res => {
  60. let arrayCollege = [];
  61. if (res.data.length > 1) {
  62. for (let i = 0; i < res.data.length; i++) {
  63. arrayCollege.push(res.data[i].deptName)
  64. if (i == res.data.length - 1) {
  65. that.setData({
  66. arrayCollege: arrayCollege,
  67. listCollege: res.data
  68. })
  69. that.getDeptInfo();
  70. }
  71. }
  72. } else {
  73. that.setData({
  74. arrayCollege: arrayCollege
  75. })
  76. }
  77. })
  78. },
  79. getDeptInfo: function(e) {
  80. const that = this;
  81. util.httpRequest(api.getDeptInfo, {
  82. companyId: that.data.userInfo.companyId,
  83. parentId: that.data.listCollege[that.data.indexCollege].deptId
  84. }, 'post').then(res => {
  85. let arrayDept = [];
  86. if (res.data.length > 1) {
  87. for (let i = 0; i < res.data.length; i++) {
  88. arrayDept.push(res.data[i].deptName)
  89. if (i == res.data.length - 1) {
  90. that.setData({
  91. arrayDept: arrayDept,
  92. listDept: res.data
  93. })
  94. that.getRegisterInfo();
  95. }
  96. }
  97. } else {
  98. that.setData({
  99. arrayDept: arrayDept
  100. })
  101. that.getRegisterInfo();
  102. }
  103. })
  104. },
  105. getRegisterInfo: function(status = 0) {
  106. const that = this;
  107. util.httpRequest(api.getRegisterInfo, {
  108. deptId: that.data.listDept[that.data.indexDept].deptId,
  109. register: status
  110. }, 'post').then(res => {
  111. that.setData({
  112. registerCount: res.data.data.registerCount,
  113. unRegisterCount: res.data.data.unEegisterCount,
  114. list: res.data.data.data
  115. })
  116. })
  117. },
  118. /**
  119. * 生命周期函数--监听页面加载
  120. */
  121. onLoad: function(options) {
  122. const that = this;
  123. that.setData({
  124. apiTotal: api.total
  125. })
  126. that.data.userInfo = wx.getStorageSync('user');
  127. that.getCollegeInfo();
  128. },
  129. /**
  130. * 生命周期函数--监听页面初次渲染完成
  131. */
  132. onReady: function() {
  133. },
  134. /**
  135. * 生命周期函数--监听页面显示
  136. */
  137. onShow: function() {
  138. },
  139. /**
  140. * 生命周期函数--监听页面隐藏
  141. */
  142. onHide: function() {
  143. },
  144. /**
  145. * 生命周期函数--监听页面卸载
  146. */
  147. onUnload: function() {
  148. },
  149. /**
  150. * 页面相关事件处理函数--监听用户下拉动作
  151. */
  152. onPullDownRefresh: function() {
  153. },
  154. /**
  155. * 页面上拉触底事件的处理函数
  156. */
  157. onReachBottom: function() {
  158. }
  159. })