access.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // pages/access/access.js
  2. import httpRequestApi from '../../utils/APIRequest';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. PhotoBoxInfo: {},
  9. likeStatus: false,
  10. avatar: "",
  11. id: ""
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. console.log(options)
  18. if(options.share && !wx.getStorageSync('uid')) {
  19. wx.reLaunch({
  20. url: '/pages/index/index?ind=0'
  21. })
  22. return false;
  23. }
  24. this.setData({
  25. id: options.id
  26. })
  27. this.getPhoneBoxInfo(options.id);
  28. },
  29. getPhoneBoxInfo(uid){
  30. httpRequestApi.getPhotoBoxInfoById({ uid }).success((res) => {
  31. this.setData({
  32. PhotoBoxInfo: res.data.data,
  33. avatar: res.data.data.user.avatar
  34. })
  35. })
  36. },
  37. //预览图片
  38. preview: function ({ currentTarget }) {
  39. console.log(currentTarget)
  40. const imageUrl = [currentTarget.id];
  41. wx.previewImage({
  42. urls: imageUrl
  43. })
  44. },
  45. userLike: function ({ currentTarget }) {
  46. console.log(currentTarget)
  47. console.log(this.data.PhotoBoxInfo.isLike)
  48. if(!this.data.PhotoBoxInfo.isLike) {
  49. httpRequestApi.setPhotoBoxLike({ target: currentTarget.id }).success((res) => {
  50. this.setData({
  51. likeStatus: res.data.data
  52. })
  53. this.getPhoneBoxInfo(currentTarget.id);
  54. })
  55. }
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面显示
  64. */
  65. onShow: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面隐藏
  69. */
  70. onHide: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面卸载
  74. */
  75. onUnload: function () {
  76. },
  77. /**
  78. * 页面相关事件处理函数--监听用户下拉动作
  79. */
  80. onPullDownRefresh: function () {
  81. },
  82. /**
  83. * 页面上拉触底事件的处理函数
  84. */
  85. onReachBottom: function () {
  86. },
  87. /**
  88. * 用户点击右上角分享
  89. */
  90. onShareAppMessage: function () {
  91. const id = this.data.id;
  92. return {
  93. title: '七彩童年',
  94. path: `pages/access/access?share=true&id=${id}`,
  95. success: function (res) {
  96. // 转发成功
  97. console.log("转发成功:" + JSON.stringify(res));
  98. // var shareTickets = res.shareTickets;
  99. // if (shareTickets.length == 0) {
  100. // return false;
  101. // }
  102. // //可以获取群组信息
  103. // wx.getShareInfo({
  104. // shareTicket: shareTickets[0],
  105. // success: function (res) {
  106. // console.log(res)
  107. // }
  108. // })
  109. },
  110. fail: function (res) {
  111. // 转发失败
  112. console.log("转发失败:" + JSON.stringify(res));
  113. }
  114. }
  115. }
  116. })