art.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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('6').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('6').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. APIClient.getEachSchedule({
  142. uid: res.data.data.uid
  143. }, {
  144. "category": 6
  145. }).success((res) => {
  146. const lessonListLength = res.data.data.lessonPage.list.length;
  147. const previewLength = util.preview(res.data.data.lessonPage.list).length;
  148. console.log(res)
  149. if(lessonListLength > 4) {
  150. this.setData({
  151. lessonListHeight: 280
  152. })
  153. }
  154. if(previewLength > 4){
  155. this.setData({
  156. previewHeight: 280
  157. })
  158. }
  159. this.setData({
  160. courseData: res.data.data,
  161. list: util.studyPageTime(res.data.data.lessonPage.list),
  162. wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives)
  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=7&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. })