english.js 4.6 KB

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