mathematics.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // pages/art/art.js
  2. const app = getApp()
  3. const util = require('../../utils/util.js');
  4. const APIClient = require('../../utils/APIClient.js');
  5. const login = require('../../utils/loginSchedule.js');
  6. Page({
  7. data: {
  8. flag: false,
  9. questionsData: {},
  10. courseData: {},
  11. num1: 0,
  12. position: '',
  13. questionsdian: '',
  14. list: [],
  15. lessonListHeight: '',
  16. previewHeight: '',
  17. questionsMore: '',
  18. wxObjectives: [],
  19. flag: true,
  20. materialData: [],
  21. loginType: 1,
  22. timeList: []
  23. },
  24. /* 区分答疑和分享 */
  25. distinction: function(type, columnId, pageNo, pageSize, success) {
  26. login.getOpenidSessionKey(function(res) {
  27. //console.log(res.data.data.uid);
  28. APIClient.getProductionSchedule({
  29. uid: res.data.data.uid
  30. }, {
  31. "type": type,
  32. "category": columnId,
  33. "pageNo": pageNo,
  34. "pageSize": pageSize
  35. }).success(success)
  36. }, function() {
  37. });
  38. },
  39. /*加载更多点击*/
  40. onMyEvent: function(e){
  41. let type = e.currentTarget.dataset.type;
  42. const columnId = util.column('2').columnId;
  43. if(type == 1) {
  44. this.data.num1++
  45. this.setData({
  46. num1: this.data.num1
  47. })
  48. this.distinction(type, columnId, 1, 5*this.data.num1, res => {
  49. if(res.data.success) {
  50. console.log(res.data.data)
  51. this.setData({
  52. questionsData: res.data.data,
  53. })
  54. if(res.data.data) {
  55. res.data.data.list.forEach(item => {
  56. this.data.timeList.push(util.formatDate(item.gmtCreated,4));
  57. });
  58. this.setData({
  59. timeList: this.data.timeList,
  60. questionsdian: util.replyNo(res.data.data.list)
  61. })
  62. if(5*this.data.num1 > res.data.data.totalSize) {
  63. this.setData({
  64. questionsMore: ''
  65. })
  66. }
  67. }
  68. }
  69. });
  70. }
  71. },
  72. onLoad: function (options) {
  73. if(options.type == "noTv") {
  74. this.setData({
  75. loginType: ""
  76. })
  77. }
  78. if(wx.getStorageSync('user')) {
  79. this.setData({
  80. teacher: wx.getStorageSync('user').data.data.isTeacher
  81. })
  82. }
  83. },
  84. /*点击定位*/
  85. location: function (e) {
  86. const position = e.currentTarget.dataset.id;
  87. console.log(position)
  88. this.setData({
  89. position: position
  90. })
  91. },
  92. onShow: function () {
  93. const columnId = util.column('2').columnId;
  94. /* 答疑 */
  95. this.distinction(1, columnId, 1, 2, res => {
  96. if(res.data.success) {
  97. console.log(res.data.data)
  98. this.setData({
  99. questionsData: res.data.data,
  100. })
  101. if(res.data.data) {
  102. res.data.data.list.forEach(item => {
  103. this.data.timeList.push(util.formatDate(item.gmtCreated,4));
  104. });
  105. this.setData({
  106. timeList: this.data.timeList,
  107. questionsdian: util.replyNo(res.data.data.list)
  108. })
  109. if(res.data.data.totalSize > 2) {
  110. this.setData({
  111. questionsMore: true
  112. })
  113. }
  114. }
  115. }
  116. });
  117. /*科目信息*/
  118. login.getOpenidSessionKey((res) => {
  119. //console.log(res.data.data.uid);
  120. APIClient.getEachSchedule({
  121. uid: res.data.data.uid
  122. }, {
  123. "category": 2
  124. }).success((res) => {
  125. //console.log('科目信息' + JSON.stringify(res));
  126. const lessonListLength = util.studyPageTime(res.data.data.lessonPage.list).length;
  127. const previewLength = util.filter(res.data.data.lessonPage.list).length;
  128. console.log(res)
  129. if(lessonListLength > 4) {
  130. this.setData({
  131. lessonListHeight: 144
  132. })
  133. }
  134. if(previewLength > 4){
  135. this.setData({
  136. previewHeight: 144
  137. })
  138. }
  139. this.setData({
  140. courseData: res.data.data,
  141. materialData: util.filter(res.data.data.lessonPage.list),
  142. list: util.studyPageTime(res.data.data.lessonPage.list),
  143. wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives)
  144. })
  145. })
  146. }, () => {
  147. this.setData({
  148. flag: !this.data.flag
  149. })
  150. }, this.data.loginType);
  151. },
  152. /*获取个人信息弹框*/
  153. jurisdiction: function () {
  154. this.setData({
  155. flag: !this.data.flag
  156. })
  157. this.onShow();
  158. }
  159. })