transmit.js 3.8 KB

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