science.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. productionData: {},
  10. questionsData: {},
  11. courseData: {},
  12. num1: 0,
  13. num2: 0,
  14. position: '',
  15. questionsdian: '',
  16. list: [],
  17. lessonListHeight: '',
  18. previewHeight: '',
  19. productionMore: '',
  20. questionsMore: '',
  21. wxObjectives: [],
  22. canvasHeight: '',
  23. flag: true,
  24. materialData: []
  25. },
  26. /* 区分答疑和分享 */
  27. distinction: function(type, columnId, pageNo, pageSize, success) {
  28. login.getOpenidSessionKey(function(res) {
  29. //console.log(res.data.data.uid);
  30. APIClient.getProductionSchedule({
  31. uid: res.data.data.uid
  32. }, {
  33. "type": type,
  34. "category": columnId,
  35. "pageNo": pageNo,
  36. "pageSize": pageSize
  37. }).success(success)
  38. }, function() {
  39. });
  40. },
  41. /*点击获取canvas高度*/
  42. onGetHeight: function (e) {
  43. const canvasHeight = this.selectComponent("#chat").data.canvasHeight;
  44. console.log(canvasHeight)
  45. this.setData({
  46. canvasHeight,
  47. })
  48. },
  49. /*点击查看更多*/
  50. onMyEvent: function(e){
  51. let type = e.currentTarget.dataset.type;
  52. const columnId = util.column('5').columnId;
  53. if(type == 1) {
  54. this.data.num1++
  55. this.setData({
  56. num1: this.data.num1
  57. })
  58. this.distinction(type, columnId, 1, 5*this.data.num1, res => {
  59. if(res.data.success) {
  60. console.log(res.data.data)
  61. this.setData({
  62. questionsData: res.data.data,
  63. })
  64. if(res.data.data) {
  65. this.setData({
  66. questionsdian: util.replyNo(res.data.data.list)
  67. })
  68. if(5*this.data.num1 > res.data.data.totalSize) {
  69. this.setData({
  70. questionsMore: ''
  71. })
  72. }
  73. }
  74. }
  75. });
  76. }
  77. if(type == 2) {
  78. this.data.num2++
  79. this.setData({
  80. num: this.data.num2
  81. })
  82. this.distinction(type, columnId, 1, 5*this.data.num2, res => {
  83. if(res.data.success) {
  84. console.log(res.data.data)
  85. this.setData({
  86. productionData: res.data.data,
  87. })
  88. if(5*this.data.num2 > res.data.data.totalSize) {
  89. this.setData({
  90. productionMore: ''
  91. })
  92. }
  93. }
  94. });
  95. }
  96. },
  97. /*点击定位*/
  98. location: function (e) {
  99. const position = e.currentTarget.dataset.id;
  100. console.log(position)
  101. this.setData({
  102. position: position
  103. })
  104. },
  105. onLoad: function (options) {
  106. const columnId = util.column('5').columnId;
  107. /* 分享 */
  108. this.distinction(2, columnId, 1, 2, res => {
  109. if(res.data.success) {
  110. console.log(res.data.data)
  111. this.setData({
  112. productionData: res.data.data,
  113. })
  114. if(res.data.data) {
  115. if(res.data.data.totalSize > 2) {
  116. this.setData({
  117. productionMore: true
  118. })
  119. }
  120. }
  121. }
  122. });
  123. /* 答疑 */
  124. this.distinction(1, columnId, 1, 2, res => {
  125. if(res.data.success) {
  126. console.log(res.data.data)
  127. this.setData({
  128. questionsData: res.data.data,
  129. })
  130. if(res.data.data) {
  131. this.setData({
  132. questionsdian: util.replyNo(res.data.data.list)
  133. })
  134. if(res.data.data.totalSize > 2) {
  135. this.setData({
  136. questionsMore: true
  137. })
  138. }
  139. }
  140. }
  141. });
  142. /*科目信息*/
  143. login.getOpenidSessionKey((res) => {
  144. //console.log(res.data.data.uid);
  145. APIClient.getEachSchedule({
  146. uid: res.data.data.uid
  147. }, {
  148. "category": 5
  149. }).success((res) => {
  150. //console.log('科目信息' + JSON.stringify(res));
  151. const lessonListLength = util.studyPageTime(res.data.data.lessonPage.list).length;
  152. const previewLength = util.filter(res.data.data.lessonPage.list).length;
  153. if(lessonListLength > 4) {
  154. this.setData({
  155. lessonListHeight: 280
  156. })
  157. }
  158. if(previewLength > 4){
  159. this.setData({
  160. previewHeight: 280
  161. })
  162. }
  163. this.setData({
  164. courseData: res.data.data,
  165. materialData: util.filter(res.data.data.lessonPage.list),
  166. list: util.studyPageTime(res.data.data.lessonPage.list),
  167. wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives)
  168. })
  169. })
  170. }, () => {
  171. this.setData({
  172. flag: !this.data.flag
  173. })
  174. });
  175. },
  176. onShow: function () {
  177. },
  178. /* 转发*/
  179. onShareAppMessage: function (ops) {
  180. if (ops.from === 'button') {
  181. // 来自页面内转发按钮
  182. console.log(ops.target)
  183. }
  184. const postId = ops.target.dataset.postid;
  185. const imageUrl= ops.target.dataset.imageurl[0];
  186. return {
  187. title: '小学王者班',
  188. path: `pages/transmit/transmit?ind=6&postId=${postId}`,
  189. imageUrl,
  190. success: function (res) {
  191. // 转发成功
  192. console.log("转发成功:" + JSON.stringify(res));
  193. },
  194. fail: function (res) {
  195. // 转发失败
  196. console.log("转发失败:" + JSON.stringify(res));
  197. }
  198. }
  199. },
  200. /*获取个人信息弹框*/
  201. jurisdiction: function () {
  202. this.setData({
  203. flag: !this.data.flag
  204. })
  205. this.onLoad();
  206. }
  207. })