facephoto.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. arrayDept: [],
  76. listDept: '',
  77. list: ''
  78. })
  79. }
  80. })
  81. },
  82. getDeptInfo: function(e) {
  83. const that = this;
  84. util.httpRequest(api.getDeptInfo, {
  85. companyId: that.data.userInfo.companyId,
  86. parentId: that.data.listCollege[that.data.indexCollege].deptId
  87. }, 'post').then(res => {
  88. let arrayDept = [];
  89. if (res.data.length >= 1) {
  90. for (let i = 0; i < res.data.length; i++) {
  91. arrayDept.push(res.data[i].deptName)
  92. if (i == res.data.length - 1) {
  93. that.setData({
  94. arrayDept: arrayDept,
  95. listDept: res.data
  96. })
  97. that.getRegisterInfo();
  98. }
  99. }
  100. } else {
  101. that.setData({
  102. arrayClass: [],
  103. arrayDept: [],
  104. listDept: '',
  105. registerCount: 0,
  106. unRegisterCount: 0,
  107. list: ''
  108. })
  109. }
  110. })
  111. },
  112. getRegisterInfo: function(status = 0) {
  113. const that = this;
  114. util.httpRequest(api.getRegisterInfo, {
  115. deptId: that.data.listDept[that.data.indexDept].deptId,
  116. register: status
  117. }, 'post').then(res => {
  118. that.setData({
  119. registerCount: res.data.data.registerCount,
  120. unRegisterCount: res.data.data.unEegisterCount,
  121. list: res.data.data.data
  122. })
  123. })
  124. },
  125. /**
  126. * 生命周期函数--监听页面加载
  127. */
  128. onLoad: function(options) {
  129. const that = this;
  130. that.setData({
  131. apiTotal: api.total.substring(0, api.total.length - 4)
  132. })
  133. that.data.userInfo = wx.getStorageSync('user');
  134. that.getCollegeInfo();
  135. },
  136. /**
  137. * 生命周期函数--监听页面初次渲染完成
  138. */
  139. onReady: function() {
  140. },
  141. /**
  142. * 生命周期函数--监听页面显示
  143. */
  144. onShow: function() {
  145. },
  146. /**
  147. * 生命周期函数--监听页面隐藏
  148. */
  149. onHide: function() {
  150. },
  151. /**
  152. * 生命周期函数--监听页面卸载
  153. */
  154. onUnload: function() {
  155. },
  156. /**
  157. * 页面相关事件处理函数--监听用户下拉动作
  158. */
  159. onPullDownRefresh: function() {
  160. },
  161. /**
  162. * 页面上拉触底事件的处理函数
  163. */
  164. onReachBottom: function() {
  165. }
  166. })