replay.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. var app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. replayInfo: '',
  8. roominfo: ''
  9. },
  10. room_id: '',
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. let room_id = options.room_id || 0;
  16. this.room_id = room_id;
  17. this.getData(room_id);
  18. let showBackBtn = false;
  19. let pages_all = getCurrentPages();
  20. if (pages_all.length > 1) {
  21. showBackBtn = true;
  22. }
  23. this.setData({ showBackBtn })
  24. },
  25. getData: function(room_id){
  26. let that = this;
  27. wx.showLoading();
  28. app.util.request({
  29. url: 'entry/wxapp/user',
  30. data: {
  31. controller: 'livevideo.get_replay',
  32. room_id
  33. },
  34. dataType: 'json',
  35. success: function(res) {
  36. wx.hideLoading();
  37. if (res.data.code == 0) {
  38. let replayInfo = res.data.data || '';
  39. let roominfo = res.data.roominfo || '';
  40. that.setData({ replayInfo, roominfo });
  41. } else {
  42. app.util.message('回放内容不存在', 'redirect:/lionfish_comshop/moduleB/live/index', 'error', '知道了');
  43. }
  44. }
  45. })
  46. },
  47. goDetails: function(e) {
  48. let url = e.currentTarget.dataset.link;
  49. url = url.replace(".html", "");
  50. if(!url) return;
  51. var pages_all = getCurrentPages();
  52. if (pages_all.length > 3) {
  53. wx.redirectTo({ url })
  54. } else {
  55. wx.navigateTo({ url })
  56. }
  57. },
  58. clickStore: function() {
  59. this.setData({ showStore: !this.data.showStore })
  60. },
  61. _backhome: function() {
  62. wx.switchTab({
  63. url: '/lionfish_comshop/pages/index/index',
  64. })
  65. },
  66. /**
  67. * 用户点击右上角分享
  68. */
  69. onShareAppMessage: function () {
  70. let roominfo = this.data.roominfo;
  71. let share_title = roominfo.name;
  72. let imageUrl = roominfo.share_img;
  73. let room_id = this.room_id;
  74. var share_path = `lionfish_comshop/moduleB/live/replay?room_id=${room_id}`;
  75. console.log('回放分享地址:', share_path);
  76. return {
  77. title: share_title,
  78. path: share_path,
  79. imageUrl,
  80. success: function (res) {
  81. // 转发成功
  82. },
  83. fail: function (res) {
  84. // 转发失败
  85. }
  86. }
  87. }
  88. })