index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // pages/videoDetail/index.js
  2. import {
  3. httpCloud
  4. } from "../../utils/httpFunc";
  5. const app = getApp()
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. media: {},
  12. indexItem: {},
  13. videoWidth: 0,
  14. videoHeight: 0,
  15. },
  16. activityName: "",
  17. toNext(e) {
  18. const item = this.data.media.child[e.currentTarget.dataset.index];
  19. console.log(item);
  20. wx.redirectTo({
  21. url: "/pages/videoDetail/index?id=" + item.id + '&group=' + this.data.media.location + '&type=' + item.type + '&activityName=' + this.activityName
  22. })
  23. },
  24. loadedmetadata(e) {
  25. const {
  26. width,
  27. height
  28. } = e.detail || {};
  29. this.setData({
  30. videoWidth: app.globalData.client.windowWidth,
  31. videoHeight: app.globalData.client.windowWidth / width * height
  32. })
  33. },
  34. /**
  35. * 生命周期函数--监听页面加载
  36. */
  37. onLoad(options) {
  38. const _this = this;
  39. this.activityName = options.activityName;
  40. httpCloud({
  41. name: "server",
  42. type: "getMediaOnceController",
  43. data: {
  44. typeMedia: options.type,
  45. id: options.id,
  46. group: options.group,
  47. activityName: options.activityName
  48. },
  49. call(res) {
  50. const ori = res[0] || {
  51. child: []
  52. };
  53. let indexItem = {};
  54. for (let i = 0; i < ori.child.length; i++) {
  55. const v = ori.child[i];
  56. if (v.id === options.id) {
  57. indexItem = v
  58. break
  59. } else continue
  60. }
  61. _this.setData({
  62. media: ori,
  63. indexItem
  64. })
  65. wx.setNavigationBarTitle({
  66. title: indexItem.title
  67. })
  68. }
  69. })
  70. },
  71. /**
  72. * 生命周期函数--监听页面初次渲染完成
  73. */
  74. onReady() {
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow() {
  80. },
  81. /**
  82. * 生命周期函数--监听页面隐藏
  83. */
  84. onHide() {
  85. },
  86. /**
  87. * 生命周期函数--监听页面卸载
  88. */
  89. onUnload() {
  90. },
  91. /**
  92. * 页面相关事件处理函数--监听用户下拉动作
  93. */
  94. onPullDownRefresh() {
  95. },
  96. /**
  97. * 页面上拉触底事件的处理函数
  98. */
  99. onReachBottom() {
  100. },
  101. /**
  102. * 用户点击右上角分享
  103. */
  104. onShareAppMessage() {
  105. }
  106. })