science.js 5.5 KB

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