live.js 2.4 KB

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