info.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. frameStyle: { useTop: true, name: '审核入学', leftArrow: true, useBar: false },
  8. id: '',
  9. form: {},
  10. student_id: '',
  11. },
  12. // 返回
  13. back: function () {
  14. wx.navigateBack({ delta: 1 })
  15. },
  16. // 审核
  17. toEdit: function (e) {
  18. const that = this;
  19. let params = {};
  20. const { try_status } = e.currentTarget.dataset;
  21. wx.showModal({
  22. title: '提示',
  23. content: '是否审核该条数据',
  24. async success(res) {
  25. if (res.confirm) {
  26. params.try_status = try_status
  27. if (that.data.id) {
  28. const arr = await app.$post(`/lessonStudent/${that.data.id}`, params);
  29. if (arr.errcode == '0') {
  30. wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back();
  31. }
  32. else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
  33. }
  34. } else if (res.cancel) {
  35. }
  36. }
  37. })
  38. },
  39. /**
  40. * 生命周期函数--监听页面加载
  41. */
  42. onLoad: function (options) {
  43. const that = this;
  44. that.setData({ id: options.id || '' })
  45. // 监听用户是否登录
  46. that.watchLogin();
  47. },
  48. // 监听用户是否登录
  49. watchLogin: async function () {
  50. const that = this;
  51. wx.getStorage({
  52. key: 'user',
  53. success: async res => {
  54. that.setData({ school_id: res.data.info.id })
  55. const aee = await app.$get(`/dict`, { code: "student_grade" });
  56. if (aee.errcode == '0' && aee.total > 0) that.setData({ levelList: aee.data[0].list });
  57. const ree = await app.$get(`/dict`, { code: "gender" });
  58. if (ree.errcode == '0' && ree.total > 0) that.setData({ genderList: ree.data[0].list });
  59. if (that.data.id) {
  60. const aee = await app.$get(`/lessonStudent/${that.data.id}`);
  61. if (aee.errcode == '0') {
  62. that.setData({ student_id: aee.data.student_id })
  63. }
  64. const arr = await app.$get(`/student/${that.data.student_id}`);
  65. if (arr.errcode == '0') {
  66. let gender = that.data.genderList.find(i => i.value == arr.data.gender)
  67. if (gender) arr.data.zhGender = gender.label;
  68. let level = that.data.levelList.find(i => i.value == arr.data.level)
  69. if (level) arr.data.zhLevel = level.label;
  70. that.setData({ form: arr.data });
  71. }
  72. }
  73. },
  74. fail: res => {
  75. wx.redirectTo({ url: '/pages/index/index', })
  76. }
  77. })
  78. },
  79. /**
  80. * 生命周期函数--监听页面初次渲染完成
  81. */
  82. onReady: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面显示
  86. */
  87. onShow: function () {
  88. },
  89. /**
  90. * 生命周期函数--监听页面隐藏
  91. */
  92. onHide: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面卸载
  96. */
  97. onUnload: function () {
  98. },
  99. /**
  100. * 页面相关事件处理函数--监听用户下拉动作
  101. */
  102. onPullDownRefresh: function () {
  103. },
  104. /**
  105. * 页面上拉触底事件的处理函数
  106. */
  107. onReachBottom: function () {
  108. },
  109. /**
  110. * 用户点击右上角分享
  111. */
  112. onShareAppMessage: function () {
  113. }
  114. })