livelist.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. var _request = require('../../utils/request.js')
  2. Page({
  3. data: {
  4. projects_page: 1,
  5. projects_per_page: 8,
  6. projects_more: true,
  7. projects_change: false,
  8. projects: [],
  9. vershow: true,
  10. navData:[],
  11. currentTab: 0,
  12. navScrollLeft: 0,
  13. balance: 0,
  14. todaysend: Date.parse(new Date()) / 1000
  15. },
  16. onLoad: function () {
  17. // this.getLive()
  18. },
  19. onShow: function () {
  20. this.setData({
  21. projects_more: true,
  22. projects_page: 1,
  23. projects_change: true,
  24. projects:[]
  25. })
  26. this.getLive()
  27. },
  28. onUnload: function () {
  29. },
  30. onHide: function () {
  31. },
  32. onPullDownRefresh: function () {
  33. this.setData({
  34. projects_more: true,
  35. projects_page: 1,
  36. projects_change: true,
  37. projects:[]
  38. })
  39. this.getLive('refresh')
  40. wx.stopPullDownRefresh()
  41. },
  42. onReachBottom: function () {
  43. if (this.data.projects_more) {
  44. var page = this.data.projects_page + 1
  45. this.setData({
  46. projects_page: page
  47. })
  48. this.getLive()
  49. }
  50. },
  51. getLive: function (type) {
  52. var that = this
  53. var url = 'v1/live_broad/list'
  54. var params = {
  55. page: this.data.projects_page,
  56. per_page: this.data.projects_per_page
  57. }
  58. var success = function (res) {
  59. console.log('res',res);
  60. if(type != 'refresh'){
  61. var result = that.data.projects.concat(res.data.list || [])
  62. that.setData({
  63. projects:result
  64. })
  65. }else{
  66. that.setData({
  67. projects:res.data.list
  68. })
  69. }
  70. var listMore = res.data.list_count > that.data.projects.length
  71. that.setData({
  72. projects_more: listMore
  73. })
  74. }
  75. _request.$get(url, params, success)
  76. },
  77. toLiveRoom: function (val) {
  78. var id = val.currentTarget.dataset.val
  79. let roomId = [id] // 填写具体的房间号,可通过下面【获取直播房间列表】 API 获取
  80. let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 })) // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断)
  81. wx.navigateTo({
  82. url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}&custom_params=${customParams}`
  83. })
  84. },
  85. onShareAppMessage: function (val) {
  86. return _request.share({
  87. // path: '/pages/start/start?url=pages/projects/projects',
  88. sc: 'xcx_products'
  89. })
  90. }
  91. })