transmit.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. const postsId = options.postId || '';
  79. //判断分享过来的参数是否有postId查询单挑显示
  80. if(postsId) {
  81. login.getOpenidSessionKey(res => {
  82. APIClient.getOneSchedule({
  83. uid: res.data.data.uid
  84. }, {
  85. postsId,
  86. }).success(res => {
  87. console.log(res.data)
  88. if(res.data.success) {
  89. this.setData({
  90. productionData: res.data.data,
  91. favors:res.data.data.postsAttributeInfo.favors
  92. })
  93. }
  94. })
  95. }, function() {
  96. wx.showModal({
  97. title: '提示',
  98. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  99. showCancel: false,
  100. success: function (res) {
  101. if (res.confirm) {
  102. console.log('用户点击确定')
  103. } else if (res.cancel) {
  104. console.log('用户点击取消')
  105. }
  106. }
  107. })
  108. });
  109. };
  110. },
  111. /**
  112. * 生命周期函数--监听页面初次渲染完成
  113. */
  114. onReady: function () {
  115. },
  116. })