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