video.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. currentTime:0
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. console.log(options)
  19. let time = options.time.split(':')
  20. this.setData({
  21. title: options.title,
  22. url: options.url,
  23. time: time[0]*60+time[1],
  24. id:options.id
  25. })
  26. },
  27. pause: function (event){
  28. console.log(event)
  29. },
  30. timeupdate: function (event){
  31. console.log(event)
  32. let cur = event.detail.currentTime
  33. if (cur - this.data.currentTime>=10){
  34. this.setData({
  35. currentTime:cur
  36. })
  37. wx.request({
  38. url: host+'/api/wx/savevtime',
  39. method:'post',
  40. data:{
  41. video_id: this.data.id,
  42. time: cur
  43. },
  44. success:function(res){
  45. }
  46. })
  47. }
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload: function () {
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh: function () {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom: function () {
  78. },
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage: function () {
  83. }
  84. })