science.js 7.1 KB

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