index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import {
  2. getSelfRead
  3. } from '~/api/user'
  4. let videoContext = null
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. list: [],
  11. currentVideo: '',
  12. videoState: true
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad(options) {
  18. },
  19. /**
  20. * 生命周期函数--监听页面初次渲染完成
  21. */
  22. onReady() {
  23. this.getSelfRead()
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow() {
  29. },
  30. //获取自己作品列表
  31. async getSelfRead() {
  32. let params = {
  33. uid: wx.getStorageSync('uid'),
  34. pageNo: 1,
  35. pageSize: 99
  36. }
  37. let list = await getSelfRead(params)
  38. this.setData({
  39. list
  40. })
  41. console.log(list[0]);
  42. },
  43. // 开始播放
  44. playVideo({
  45. currentTarget
  46. }) {
  47. this.setData({
  48. videoState: true,
  49. currentId: currentTarget.dataset.id
  50. })
  51. },
  52. changeVideoState() {
  53. this.videoContext = wx.createVideoContext('myVideo')
  54. console.log(this.data.videoState);
  55. let videoState = this.data.videoState
  56. if (videoState) {
  57. this.videoContext.pause()
  58. } else {
  59. this.videoContext.play()
  60. }
  61. this.setData({
  62. videoState: !videoState
  63. })
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom() {
  69. },
  70. /**
  71. * 用户点击右上角分享
  72. */
  73. onShareAppMessage() {
  74. }
  75. })