index.js 2.2 KB

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