拓恒河湖长制全民护河平台WEB端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.5KB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { updateProgress , getVideoProgress } from '../../../api/learining.js'
  2. Page({
  3. data:{
  4. videoInfo:{},
  5. videoProgress: 0,
  6. openid: null,
  7. initialTime: 0,
  8. control:false,
  9. statusList:{
  10. 0: '待学习',
  11. // 1: '学习中',
  12. 2: '已学习',
  13. },
  14. classList:{
  15. 0: 'no--study',
  16. // 1: 'is--study',
  17. 2: 'is--finish',
  18. },
  19. detail: {}
  20. },
  21. onLoad(options){
  22. let data = JSON.parse(decodeURIComponent(options.data))
  23. data.status = data.status === 0 ? 0 : data.status
  24. const openid = wx.getStorageSync('openid')
  25. this.setData({
  26. detail:data,
  27. openid,
  28. control : data.status === 2 ? true : false,
  29. })
  30. },
  31. saveTime(e){
  32. let time = e.detail.currentTime
  33. this.setData({
  34. videoProgress:time
  35. })
  36. },
  37. getProgress(){
  38. const data = {
  39. videoId: this.data.detail.id,
  40. openid: this.data.openid,
  41. }
  42. getVideoProgress(data).then(res=>{
  43. this.setData({
  44. initialTime:res.data.videoProgress,
  45. })
  46. })
  47. },
  48. handleEnded(){
  49. const isNumber = typeof(status) === 'number'
  50. const params = {
  51. status: 2,
  52. videoId: this.data.detail.id,
  53. openid: this.data.openid,
  54. videoProgress: isNumber ? this.data.videoProgress : 0
  55. }
  56. updateProgress(params)
  57. .then(res=>{
  58. let initialTime = null
  59. if(res.code == 0){
  60. initialTime = res.data==null?0:res.data
  61. }
  62. this.setData({
  63. 'detail.status': params.status,
  64. control
  65. })
  66. })
  67. }
  68. })