index.js 1.7 KB

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