language.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. },
  21. /* 区分答疑和分享 */
  22. distinction: function(type, columnId, pageNo, pageSize, success) {
  23. login.getOpenidSessionKey(function(res) {
  24. //console.log(res.data.data.uid);
  25. APIClient.getProductionSchedule({
  26. uid: res.data.data.uid
  27. }, {
  28. "type": type,
  29. "category": columnId,
  30. "pageNo": pageNo,
  31. "pageSize": pageSize
  32. }).success(success)
  33. }, function() {
  34. });
  35. },
  36. /*加载更多点击*/
  37. onMyEvent: function(e){
  38. let type = e.currentTarget.dataset.type;
  39. const columnId = util.column('1').columnId;
  40. if(type == 1) {
  41. this.data.num1++
  42. this.setData({
  43. num1: this.data.num1
  44. })
  45. this.distinction(type, columnId, 1, 5*this.data.num1, res => {
  46. if(res.data.success) {
  47. console.log(res.data.data)
  48. this.setData({
  49. questionsData: res.data.data,
  50. })
  51. if(res.data.data) {
  52. this.setData({
  53. questionsdian: util.replyNo(res.data.data.list)
  54. })
  55. if(5*this.data.num1 > res.data.data.totalSize) {
  56. this.setData({
  57. questionsMore: ''
  58. })
  59. }
  60. }
  61. }
  62. });
  63. }
  64. },
  65. /*点击定位*/
  66. location: function (e) {
  67. const position = e.currentTarget.dataset.id;
  68. console.log(position)
  69. this.setData({
  70. position: position
  71. })
  72. },
  73. onLoad: function (options) {
  74. },
  75. onShow: function () {
  76. const columnId = util.column('1').columnId;
  77. /* 答疑 */
  78. this.distinction(1, columnId, 1, 2, res => {
  79. if(res.data.success) {
  80. this.setData({
  81. questionsData: res.data.data,
  82. })
  83. if(res.data.data) {
  84. this.setData({
  85. questionsdian: util.replyNo(res.data.data.list)
  86. })
  87. if(res.data.data.totalSize > 2) {
  88. this.setData({
  89. questionsMore: true
  90. })
  91. }
  92. }
  93. }
  94. });
  95. /*科目信息*/
  96. login.getOpenidSessionKey((res) => {
  97. //console.log(res.data.data.uid);
  98. APIClient.getEachSchedule({
  99. uid: res.data.data.uid
  100. }, {
  101. "category": 1
  102. }).success((res) => {
  103. const lessonListLength = res.data.data.lessonPage.list.length;
  104. const previewLength = res.data.data.lessonPage.list.length;
  105. console.log(res)
  106. if(lessonListLength > 4) {
  107. this.setData({
  108. lessonListHeight: 280
  109. })
  110. }
  111. if(previewLength > 4){
  112. this.setData({
  113. previewHeight: 280
  114. })
  115. }
  116. this.setData({
  117. courseData: res.data.data,
  118. list: util.studyPageTime(res.data.data.lessonPage.list),
  119. wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives)
  120. })
  121. })
  122. }, () => {
  123. this.setData({
  124. flag: !this.data.flag
  125. })
  126. });
  127. },
  128. /*获取个人信息弹框*/
  129. jurisdiction: function () {
  130. this.setData({
  131. flag: !this.data.flag
  132. })
  133. this.onShow();
  134. }
  135. })