language.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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('1').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. if(5*this.data.num1 > res.data.data.totalSize) {
  64. this.setData({
  65. questionsMore: ''
  66. })
  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. console.log(options)
  83. if(options.type == "noTv") {
  84. this.setData({
  85. loginType: ""
  86. })
  87. }
  88. let scene = decodeURIComponent(options.scene);
  89. if (scene && scene !== 'undefined') {
  90. let idParam = scene.split('&')[0];
  91. let showIdParam = scene.split('&')[1];
  92. let idKey = idParam.split('=')[0];
  93. let idvalue = idParam.split('=')[1];
  94. this.setData({
  95. userKey: idvalue
  96. })
  97. }
  98. if(wx.getStorageSync('user')) {
  99. this.setData({
  100. teacher: wx.getStorageSync('user').data.data.isTeacher
  101. })
  102. }
  103. },
  104. onShow: function () {
  105. const columnId = util.column('1').columnId;
  106. /* 答疑 */
  107. this.distinction(1, columnId, 1, 2, res => {
  108. if(res.data.success) {
  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": 1
  135. }).success((res) => {
  136. const lessonListLength = util.studyPageTime(res.data.data.lessonPage.list).length;
  137. const previewLength = util.filter(res.data.data.lessonPage.list).length;
  138. console.log(res)
  139. if(lessonListLength > 4) {
  140. this.setData({
  141. lessonListHeight: 144
  142. })
  143. }
  144. if(previewLength > 4){
  145. this.setData({
  146. previewHeight: 144
  147. })
  148. }
  149. this.setData({
  150. courseData: res.data.data,
  151. materialData: util.filter(res.data.data.lessonPage.list),
  152. list: util.studyPageTime(res.data.data.lessonPage.list),
  153. wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives)
  154. })
  155. })
  156. }, () => {
  157. this.setData({
  158. flag: !this.data.flag
  159. })
  160. }, this.data.loginType, this.data.userKey);
  161. },
  162. /*获取个人信息弹框*/
  163. jurisdiction: function () {
  164. this.setData({
  165. flag: !this.data.flag
  166. })
  167. this.onShow();
  168. }
  169. })