art.js 4.5 KB

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