science.js 5.3 KB

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