index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // pages/stroke/index.js
  2. import {
  3. toNavigatePage
  4. } from "../../utils/util"
  5. import api from "../../api/index";
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. meetingList: [],
  12. active: ""
  13. },
  14. tabChange() {},
  15. toPage(e) {
  16. const {
  17. agendavideo,
  18. cover,
  19. url,
  20. id
  21. } = e.currentTarget.dataset;
  22. console.log(encodeURI(cover), agendavideo)
  23. toNavigatePage(url + '?id=' + id + '&agendavideo=' + agendavideo + '&cover=' + encodeURI(cover))
  24. },
  25. async getChannelsLive(finderUserName) {
  26. const info = await new Promise((resolve, reject) => {
  27. wx.getChannelsLiveInfo({
  28. finderUserName,
  29. success: res => {
  30. const {
  31. status
  32. } = res;
  33. resolve(status);
  34. // status -> 2 直播中
  35. },
  36. fail: err => {
  37. console.log(err)
  38. }
  39. })
  40. })
  41. return info
  42. },
  43. openChannels(e) {
  44. const finderUserName = e.currentTarget.dataset.channelsid || "";
  45. wx.openChannelsLive({
  46. finderUserName
  47. })
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad(options) {
  53. api.getStroke().then(strokeList => {
  54. const sl = {};
  55. for (let i = 0; i < strokeList.length; i++) {
  56. const v = strokeList[i];
  57. const time = v.agendaTime.split(" ") || [];
  58. if (!time || !time.length) continue
  59. let t0 = time[0].split("-");
  60. if (!sl[t0[1] + '-' + t0[2]]) sl[t0[1] + '-' + t0[2]] = [];
  61. v.localTime = time[1];
  62. if (v.wxVideoUid) {
  63. // 判断是否正在直播
  64. const status = this.getChannelsLive(v.wxVideoUid);
  65. v.liveing = status === 2;
  66. }
  67. sl[t0[1] + '-' + t0[2]].push(v);
  68. }
  69. this.setData({
  70. meetingList: sl
  71. })
  72. })
  73. },
  74. /**
  75. * 生命周期函数--监听页面初次渲染完成
  76. */
  77. onReady() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面显示
  81. */
  82. onShow() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide() {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload() {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh() {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom() {
  103. },
  104. /**
  105. * 用户点击右上角分享
  106. */
  107. onShareAppMessage() {
  108. },
  109. onShareTimeline() {}
  110. })