science.js 4.1 KB

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