index.js 2.3 KB

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