science.js 5.6 KB

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