science.js 5.1 KB

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