art.js 4.0 KB

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