info.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. frameStyle: { useTop: true, name: '学员课程详细信息', leftArrow: true, useBar: false },
  8. id: '',
  9. // 选中
  10. tabs: {
  11. active: '0',
  12. menu: [
  13. { title: '学生信息', active: '0' },
  14. { title: '课程信息', active: '1' },
  15. ]
  16. },
  17. // 学员信息
  18. stuInfo: {},
  19. // 课程信息
  20. lesInfo: {},
  21. // 学生id
  22. student_id: '',
  23. // 课程id
  24. lesson_id: '',
  25. // 学员等级
  26. levelList: [],
  27. // 学员性别
  28. genderList: [],
  29. // 状态列表
  30. statusList: [],
  31. // 类型列表
  32. typeList: [],
  33. },
  34. // 返回
  35. back: function () {
  36. wx.navigateBack({ delta: 1 })
  37. },
  38. // 选项卡选择
  39. tabsChange: function (e) {
  40. const that = this;
  41. let data = e.detail;
  42. that.setData({ 'tabs.active': data.active })
  43. },
  44. /**
  45. * 生命周期函数--监听页面加载
  46. */
  47. onLoad: function (options) {
  48. const that = this;
  49. that.setData({ id: options.id || '' })
  50. // 监听用户是否登录
  51. that.watchLogin();
  52. },
  53. // 监听用户是否登录
  54. watchLogin: async function () {
  55. const that = this;
  56. wx.getStorage({
  57. key: 'user',
  58. success: async res => {
  59. that.setData({ school_id: res.data.info.id })
  60. // 学员等级
  61. const aee = await app.$get(`/dict`, { code: "student_grade" });
  62. if (aee.errcode == '0' && aee.total > 0) that.setData({ levelList: aee.data[0].list });
  63. // 学员性别
  64. const ree = await app.$get(`/dict`, { code: "gender" });
  65. if (ree.errcode == '0' && ree.total > 0) that.setData({ genderList: ree.data[0].list });
  66. // 课程状态
  67. const aff = await app.$get(`/dict`, { code: "lesson_status" });
  68. if (aff.errcode == '0' && aff.total > 0) that.setData({ statusList: aff.data[0].list });
  69. // 课程列表
  70. const acc = await app.$get(`/dict`, { code: "lesson_type" });
  71. if (acc.errcode == '0' && aee.total > 0) that.setData({ typeList: acc.data[0].list });
  72. if (that.data.id) {
  73. const aee = await app.$get(`/tempLessonApply/${that.data.id}`);
  74. if (aee.errcode == '0') {
  75. that.setData({ student_id: aee.data.student_id })
  76. that.setData({ lesson_id: aee.data.lesson_id })
  77. }
  78. // 学员信息
  79. const arr = await app.$get(`/student/${that.data.student_id}`);
  80. if (arr.errcode == '0') {
  81. let gender = that.data.genderList.find(i => i.value == arr.data.gender)
  82. if (gender) arr.data.zhGender = gender.label;
  83. let level = that.data.levelList.find(i => i.value == arr.data.level)
  84. if (level) arr.data.zhLevel = level.label;
  85. that.setData({ stuInfo: arr.data });
  86. }
  87. // 课程信息
  88. const abb = await app.$get(`/lesson/${that.data.lesson_id}`);
  89. if (abb.errcode == '0') {
  90. let status = that.data.statusList.find(i => i.value == abb.data.status)
  91. if (status) abb.data.zhstatus = status.label;
  92. let type = that.data.typeList.find(i => i.value == abb.data.type)
  93. if (type) abb.data.zhtype = type.label;
  94. that.setData({ lesInfo: abb.data });
  95. }
  96. }
  97. },
  98. fail: res => {
  99. wx.redirectTo({ url: '/pages/index/index', })
  100. }
  101. })
  102. },
  103. /**
  104. * 生命周期函数--监听页面初次渲染完成
  105. */
  106. onReady: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面显示
  110. */
  111. onShow: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面隐藏
  115. */
  116. onHide: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面卸载
  120. */
  121. onUnload: function () {
  122. },
  123. /**
  124. * 页面相关事件处理函数--监听用户下拉动作
  125. */
  126. onPullDownRefresh: function () {
  127. },
  128. /**
  129. * 页面上拉触底事件的处理函数
  130. */
  131. onReachBottom: function () {
  132. },
  133. /**
  134. * 用户点击右上角分享
  135. */
  136. onShareAppMessage: function () {
  137. }
  138. })