science.js 2.4 KB

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