facephoto.js 3.9 KB

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