art.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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('6').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('6').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. APIClient.getEachSchedule({
  141. uid: res.data.data.uid
  142. }, {
  143. "category": 6
  144. }).success((res) => {
  145. const lessonListLength = res.data.data.lessonPage.list.length;
  146. const previewLength = util.preview(res.data.data.lessonPage.list).length;
  147. console.log(res)
  148. if(lessonListLength > 4) {
  149. this.setData({
  150. lessonListHeight: 280
  151. })
  152. }
  153. if(previewLength > 4){
  154. this.setData({
  155. previewHeight: 280
  156. })
  157. }
  158. this.setData({
  159. courseData: res.data.data,
  160. list: util.studyPageTime(res.data.data.lessonPage.list)
  161. })
  162. })
  163. }, function() {
  164. wx.showModal({
  165. title: '提示',
  166. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  167. showCancel: false,
  168. success: function (res) {
  169. if (res.confirm) {
  170. console.log('用户点击确定')
  171. } else if (res.cancel) {
  172. console.log('用户点击取消')
  173. }
  174. }
  175. })
  176. });
  177. },
  178. /* 转发*/
  179. onShareAppMessage: function (ops) {
  180. if (ops.from === 'button') {
  181. // 来自页面内转发按钮
  182. console.log(ops.target)
  183. }
  184. const postId = ops.target.dataset.postid;
  185. return {
  186. title: '小学王者班',
  187. path: `pages/transmit/transmit?ind=7&postId=${postId}`,
  188. success: function (res) {
  189. // 转发成功
  190. console.log("转发成功:" + JSON.stringify(res));
  191. },
  192. fail: function (res) {
  193. // 转发失败
  194. console.log("转发失败:" + JSON.stringify(res));
  195. }
  196. }
  197. },
  198. })