index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import {
  2. ApiModel
  3. } from "../../../utils/api";
  4. const _Http = new ApiModel();
  5. Page({
  6. options: {
  7. addGlobalClass: true,
  8. },
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. tiveList: [], //直播列表
  14. pageNumber: 1,
  15. pageTotal: 1,
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad(options) {
  21. this.getHomeLive();
  22. },
  23. //获取直播列表
  24. getHomeLive() {
  25. if (this.data.pageNumber > this.data.pageTotal) return;
  26. _Http.basic({
  27. "classname": "publicmethod.live.live",
  28. "method": "getHomeLive",
  29. "content": {
  30. "getdatafromdbanyway": true,
  31. "livestatus": "",
  32. 'pageNumber': this.data.pageNumber
  33. }
  34. }).then(res => {
  35. console.log("直播列表", res)
  36. if (res.msg != '成功') {
  37. wx.showToast({
  38. title: res.data,
  39. icon: "none"
  40. });
  41. } else {
  42. let tiveList=(res.pageNumber == 1) ? res.data : this.data.tiveList.concat(res.data);
  43. this.setData({
  44. tiveList,
  45. pageTotal: res.data
  46. })
  47. }
  48. })
  49. },
  50. /**
  51. * 生命周期函数--监听页面初次渲染完成
  52. */
  53. onReady() {
  54. },
  55. /**
  56. * 生命周期函数--监听页面显示
  57. */
  58. onShow() {
  59. this.getTabBar().init();
  60. },
  61. /**
  62. * 生命周期函数--监听页面隐藏
  63. */
  64. onHide() {
  65. },
  66. /**
  67. * 生命周期函数--监听页面卸载
  68. */
  69. onUnload() {
  70. },
  71. /**
  72. * 页面相关事件处理函数--监听用户下拉动作
  73. */
  74. onPullDownRefresh() {
  75. },
  76. /**
  77. * 页面上拉触底事件的处理函数
  78. */
  79. onReachBottom() {
  80. this.setData({
  81. pageNumber: this.data.pageNumber + 1
  82. })
  83. this.getHomeLive();
  84. },
  85. /**
  86. * 用户点击右上角分享
  87. */
  88. onShareAppMessage() {
  89. }
  90. })