video.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // pages/video/video.js
  2. const app = getApp()
  3. const host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. title:'',
  10. url:'',
  11. time:0,
  12. duration:0,
  13. recommend:[],
  14. currentTime:0,
  15. marTime:0
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. let time = options.time.split(':')
  22. this.setData({
  23. title: options.title,
  24. url: options.url,
  25. time: time[0]*60+time[1],
  26. id:options.id
  27. })
  28. let _this = this;
  29. wx.request({
  30. url: host + '/api/wx/video/info',
  31. method: 'get',
  32. header: {
  33. openid: app.globalData.openid
  34. },
  35. data: {
  36. video_id: this.data.id,
  37. time: this.data.duration
  38. },
  39. success: function (res) {
  40. _this.setData({
  41. recommend: res.data.data.recommends
  42. })
  43. }
  44. })
  45. },
  46. end: function (event){
  47. wx.request({
  48. url: host + '/api/wx/savevtime',
  49. method: 'post',
  50. header: {
  51. openid: app.globalData.openid
  52. },
  53. data: {
  54. video_id: this.data.id,
  55. time: this.data.duration
  56. },
  57. success: function (res) {
  58. }
  59. })
  60. },
  61. timeupdate: function (event){
  62. let currentTime = parseInt(event.detail.currentTime)
  63. if (!this.data.duration||true){
  64. this.setData({
  65. duration: currentTime
  66. })
  67. }
  68. if( currentTime/10>=1 && currentTime % 10 == 0){
  69. this.end();
  70. }
  71. },
  72. /**
  73. * 生命周期函数--监听页面初次渲染完成
  74. */
  75. onReady: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面显示
  79. */
  80. onShow: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面隐藏
  84. */
  85. onHide: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面卸载
  89. */
  90. onUnload: function () {
  91. },
  92. /**
  93. * 页面相关事件处理函数--监听用户下拉动作
  94. */
  95. onPullDownRefresh: function () {
  96. },
  97. /**
  98. * 页面上拉触底事件的处理函数
  99. */
  100. onReachBottom: function () {
  101. },
  102. /**
  103. * 用户点击右上角分享
  104. */
  105. onShareAppMessage: function () {
  106. }
  107. })