science.js 3.3 KB

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