index.js 2.2 KB

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