science.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. },
  24. /* 区分答疑和分享 */
  25. distinction: function(type, columnId, pageNo, pageSize, success) {
  26. login.getOpenidSessionKey(function(res) {
  27. //console.log(res.data.data.uid);
  28. APIClient.getProductionSchedule({
  29. uid: res.data.data.uid
  30. }, {
  31. "type": type,
  32. "category": columnId,
  33. "pageNo": pageNo,
  34. "pageSize": pageSize
  35. }).success(success)
  36. }, function() {
  37. wx.showModal({
  38. title: '提示',
  39. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  40. showCancel: false,
  41. success: function (res) {
  42. if (res.confirm) {
  43. console.log('用户点击确定')
  44. } else if (res.cancel) {
  45. console.log('用户点击取消')
  46. }
  47. }
  48. })
  49. });
  50. },
  51. /*点击获取canvas高度*/
  52. onGetHeight: function (e) {
  53. const canvasHeight = this.selectComponent("#chat").data.canvasHeight;
  54. console.log(canvasHeight)
  55. this.setData({
  56. canvasHeight,
  57. })
  58. },
  59. /*点击查看更多*/
  60. onMyEvent: function(e){
  61. let type = e.currentTarget.dataset.type;
  62. const columnId = util.column('5').columnId;
  63. if(type == 1) {
  64. this.data.num1++
  65. this.setData({
  66. num1: this.data.num1
  67. })
  68. this.distinction(type, columnId, 1, 5*this.data.num1, res => {
  69. if(res.data.success) {
  70. console.log(res.data.data)
  71. this.setData({
  72. questionsData: res.data.data,
  73. })
  74. if(res.data.data) {
  75. this.setData({
  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. })
  92. this.distinction(type, columnId, 1, 5*this.data.num2, res => {
  93. if(res.data.success) {
  94. console.log(res.data.data)
  95. this.setData({
  96. productionData: res.data.data,
  97. })
  98. if(5*this.data.num2 > res.data.data.totalSize) {
  99. this.setData({
  100. productionMore: ''
  101. })
  102. }
  103. }
  104. });
  105. }
  106. },
  107. /*点击定位*/
  108. location: function (e) {
  109. const position = e.currentTarget.dataset.id;
  110. console.log(position)
  111. this.setData({
  112. position: position
  113. })
  114. },
  115. onLoad: function (options) {
  116. const columnId = util.column('5').columnId;
  117. /* 分享 */
  118. this.distinction(2, columnId, 1, 2, res => {
  119. if(res.data.success) {
  120. console.log(res.data.data)
  121. this.setData({
  122. productionData: res.data.data,
  123. })
  124. if(res.data.data) {
  125. if(res.data.data.totalSize > 2) {
  126. this.setData({
  127. productionMore: true
  128. })
  129. }
  130. }
  131. }
  132. });
  133. /* 答疑 */
  134. this.distinction(1, columnId, 1, 2, res => {
  135. if(res.data.success) {
  136. console.log(res.data.data)
  137. this.setData({
  138. questionsData: res.data.data,
  139. })
  140. if(res.data.data) {
  141. this.setData({
  142. questionsdian: util.replyNo(res.data.data.list)
  143. })
  144. if(res.data.data.totalSize > 2) {
  145. this.setData({
  146. questionsMore: true
  147. })
  148. }
  149. }
  150. }
  151. });
  152. /*科目信息*/
  153. login.getOpenidSessionKey((res) => {
  154. //console.log(res.data.data.uid);
  155. APIClient.getEachSchedule({
  156. uid: res.data.data.uid
  157. }, {
  158. "category": 5
  159. }).success((res) => {
  160. //console.log('科目信息' + JSON.stringify(res));
  161. const lessonListLength = res.data.data.lessonPage.list.length;
  162. const previewLength = res.data.data.lessonPage.list.length;
  163. if(lessonListLength > 4) {
  164. this.setData({
  165. lessonListHeight: 280
  166. })
  167. }
  168. if(previewLength > 4){
  169. this.setData({
  170. previewHeight: 280
  171. })
  172. }
  173. this.setData({
  174. courseData: res.data.data,
  175. list: util.studyPageTime(res.data.data.lessonPage.list),
  176. wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives)
  177. })
  178. })
  179. }, function() {
  180. wx.showModal({
  181. title: '提示',
  182. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  183. showCancel: false,
  184. success: function (res) {
  185. if (res.confirm) {
  186. console.log('用户点击确定')
  187. } else if (res.cancel) {
  188. console.log('用户点击取消')
  189. }
  190. }
  191. })
  192. });
  193. },
  194. onShow: function () {
  195. },
  196. /* 转发*/
  197. onShareAppMessage: function (ops) {
  198. if (ops.from === 'button') {
  199. // 来自页面内转发按钮
  200. console.log(ops.target)
  201. }
  202. const postId = ops.target.dataset.postid;
  203. return {
  204. title: '小学王者班',
  205. path: `pages/transmit/transmit?ind=6&postId=${postId}`,
  206. success: function (res) {
  207. // 转发成功
  208. console.log("转发成功:" + JSON.stringify(res));
  209. },
  210. fail: function (res) {
  211. // 转发失败
  212. console.log("转发失败:" + JSON.stringify(res));
  213. }
  214. }
  215. },
  216. })