live.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. type: '简介',
  14. userInfo: {}
  15. },
  16. activity: "",
  17. id: "",
  18. getDate() {
  19. const _this = this;
  20. httpCloud({
  21. name: "server",
  22. type: "getLiveData",
  23. data: {
  24. activityName: _this.activity,
  25. id: _this.id
  26. },
  27. call(res) {
  28. const obj = res || {};
  29. _this.setData({
  30. liveData: obj
  31. })
  32. wx.setNavigationBarTitle({
  33. title: decodeURIComponent(obj.title)
  34. })
  35. }
  36. })
  37. },
  38. getUser(e) {
  39. wx.setStorage({
  40. key: "userInfo",
  41. data: e.detail.rawData,
  42. encrypt: true // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true
  43. })
  44. },
  45. select(e) {
  46. this.setData({
  47. type: e.currentTarget.dataset.type
  48. })
  49. },
  50. liveing(e) {
  51. this.setData({
  52. isLive: true
  53. })
  54. },
  55. liveerr() {
  56. this.setData({
  57. isLive: false
  58. })
  59. },
  60. /**
  61. * 生命周期函数--监听页面加载
  62. */
  63. onLoad(options) {
  64. this.activity = decodeURIComponent(options.activityName);
  65. this.id = options.id;
  66. this.getDate();
  67. const _this = this;
  68. wx.getStorage({
  69. key: "userInfo",
  70. encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true
  71. success(res) {
  72. _this.setData({
  73. userInfo: JSON.parse(res.data || "{}")
  74. })
  75. }
  76. })
  77. },
  78. /**
  79. * 生命周期函数--监听页面初次渲染完成
  80. */
  81. onReady() {
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide() {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload() {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh() {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom() {
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. return {
  113. title: "", // 分享名称
  114. path: 'pages/home/index', // 点击分享后的链接要来到的页面的路径已经对应需要的参数
  115. }
  116. }
  117. })