index.js 2.0 KB

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