science.js 5.8 KB

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