art.js 3.7 KB

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