art.js 4.4 KB

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