detail.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. id:0,
  8. info:{},
  9. content: '',
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. let id = options.id;
  16. this.setData({id:id});
  17. this.getInfo();
  18. },
  19. /**
  20. * 用户点击右上角分享
  21. */
  22. onShareAppMessage: function () {
  23. let info = this.data.info
  24. return {
  25. title: info.title,
  26. path: "/pages/activity/detail/detail?id="+info.id,
  27. imageUrl: info.main_image,
  28. };
  29. },
  30. //详情
  31. getInfo() {
  32. let self = this;
  33. app.post('activity/activity/detail',{id:this.data.id},function(res){
  34. self.setData({info:res});
  35. self.setData({ content: res.content.replace(/\<img/gi, '<img style="max-width:100%;display:block;" ') });
  36. });
  37. },
  38. copyUrl(e) {
  39. let url = e.currentTarget.dataset.url;
  40. wx.setClipboardData({
  41. data: url,
  42. success (res) {
  43. app.msg('复制成功,请用手机浏览器或电脑打开链接下载附件','',5000);
  44. }
  45. });
  46. },
  47. toReview() {
  48. wx.navigateTo({
  49. url: '/pages/activity/reviewdetail/reviewdetail?id='+this.data.info.review.id,
  50. })
  51. },
  52. joinActivity() {
  53. app.post('activity/activity/join',{id:this.data.id},function(res){
  54. if (res.code == 1001) {
  55. app.msg('请完善信息','/pages/my/info/info');
  56. } else {
  57. app.msg(res.msg);
  58. }
  59. });
  60. }
  61. })