art.js 5.0 KB

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