transmit.js 3.7 KB

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