live.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // pages/live/live.js
  2. import {
  3. httpCloud
  4. } from "../../utils/httpFunc";
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isLive: false,
  11. liveData: {},
  12. list: []
  13. },
  14. getDate() {
  15. const _this = this;
  16. httpCloud({
  17. name: "server",
  18. type: "getLiveData",
  19. data: {},
  20. call(res) {
  21. const obj = res || {};
  22. _this.setData({
  23. liveData: obj
  24. })
  25. }
  26. })
  27. },
  28. liveing() {
  29. this.setData({
  30. isLive: true
  31. })
  32. },
  33. liveerr() {
  34. this.setData({
  35. isLive: false
  36. })
  37. },
  38. showBack() {
  39. const _this = this;
  40. httpCloud({
  41. name: "server",
  42. type: "getLiveListData",
  43. data: {},
  44. call(res) {
  45. const r = res || [];
  46. for (let i = 0; i < r.length; i++) {
  47. const v = r[i];
  48. v.titleShow = v.live_type === 'back' ? '回看-' + v.title : '直播-' + v.title;
  49. }
  50. _this.setData({
  51. list: r,
  52. })
  53. }
  54. })
  55. },
  56. bindPickerChange(e) {
  57. const d = this.data.list[e.detail.value] || {}
  58. this.setData({
  59. liveData: d,
  60. isLive : d.backUrl ? true : false
  61. })
  62. },
  63. /**
  64. * 生命周期函数--监听页面加载
  65. */
  66. onLoad(options) {
  67. wx.setNavigationBarTitle({
  68. title: decodeURIComponent(options.title || "盛世中华 何以中国")
  69. })
  70. this.getDate();
  71. this.showBack();
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady() {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow() {
  82. },
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面卸载
  90. */
  91. onUnload() {
  92. },
  93. /**
  94. * 页面相关事件处理函数--监听用户下拉动作
  95. */
  96. onPullDownRefresh() {
  97. },
  98. /**
  99. * 页面上拉触底事件的处理函数
  100. */
  101. onReachBottom() {
  102. },
  103. /**
  104. * 用户点击右上角分享
  105. */
  106. onShareAppMessage() {
  107. }
  108. })