transmit.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // pages/transmit/transmit.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. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. productionData: {},
  12. favors: '',
  13. like: false,
  14. flag: true
  15. },
  16. //跳转详情页
  17. particulars: function (e) {
  18. const postId = e.currentTarget.dataset.postsid;
  19. wx.navigateTo({
  20. url: '../../pages/particulars/particulars?postId=' + postId + '&type=2'
  21. })
  22. },
  23. /*预览图片*/
  24. listenerButtonPreviewImage: function(e) {
  25. let imgUrl = [];
  26. imgUrl.push(e.target.dataset.img);
  27. wx.previewImage({
  28. current: '', // 当前显示图片的http链接
  29. urls: imgUrl, // 需要预览的图片http链接列表
  30. //这根本就不走
  31. success: function(res) {
  32. //console.log(res);
  33. },
  34. //也根本不走
  35. fail: function() {
  36. //console.log('fail')
  37. }
  38. })
  39. },
  40. /*点赞接口*/
  41. like: function () {
  42. const postsId = util.getUrl().postId;
  43. //判断分享过来的参数是否有postId查询单挑显示
  44. if(postsId) {
  45. login.getOpenidSessionKey(res => {
  46. APIClient.getLikeSchedule({
  47. uid: res.data.data.uid
  48. }, {
  49. postsId,
  50. }).success(res => {
  51. console.log(res.data)
  52. if(res.data.success) {
  53. this.setData({
  54. favors: res.data.data.favors,
  55. like: true
  56. })
  57. }
  58. })
  59. }, function() {
  60. wx.showModal({
  61. title: '提示',
  62. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  63. showCancel: false,
  64. success: function (res) {
  65. if (res.confirm) {
  66. console.log('用户点击确定')
  67. } else if (res.cancel) {
  68. console.log('用户点击取消')
  69. }
  70. }
  71. })
  72. });
  73. };
  74. },
  75. /**
  76. * 生命周期函数--监听页面加载
  77. */
  78. onLoad: function (options) {
  79. // wx.showModal({
  80. // title: '提示',
  81. // content: 'aaa' + JSON.stringify(options),
  82. // showCancel: false,
  83. // success: function (res) {
  84. // if (res.confirm) {
  85. // console.log('用户点击确定')
  86. // } else if (res.cancel) {
  87. // console.log('用户点击取消')
  88. // }
  89. // }
  90. // })
  91. const postsId = options.postId || '';
  92. const shareKey = util.convertObject(unescape(options.scene)).shareKey || '';
  93. console.log('shareKey:' + util.convertObject(unescape(options.scene)).shareKey);
  94. //判断分享过来的参数是否有postId查询单挑显示
  95. if(postsId || shareKey) {
  96. login.getOpenidSessionKey(res => {
  97. APIClient.getOneSchedule({
  98. uid: res.data.data.uid
  99. }, {
  100. postsId,
  101. shareKey
  102. }).success(res => {
  103. console.log(res.data)
  104. if(res.data.success) {
  105. this.setData({
  106. productionData: res.data.data,
  107. favors:res.data.data.postsAttributeInfo.favors
  108. })
  109. }
  110. })
  111. }, () => {
  112. this.setData({
  113. flag: !this.data.flag
  114. })
  115. });
  116. };
  117. },
  118. /**
  119. * 生命周期函数--监听页面初次渲染完成
  120. */
  121. onReady: function () {
  122. },
  123. /*获取个人信息弹框*/
  124. jurisdiction: function () {
  125. this.setData({
  126. flag: !this.data.flag
  127. })
  128. this.onLoad();
  129. }
  130. })