livelist.js 2.2 KB

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