science.js 5.4 KB

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