index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import behavior from '~/mixins/video'
  2. import share from '~/mixins/share'
  3. import {
  4. getreadInfo
  5. } from '~/api/video'
  6. import {
  7. getPkRecord
  8. } from '~/api/works'
  9. Page({
  10. behaviors: [behavior, share],
  11. data: {
  12. videoInfo: '',
  13. videoId: '',
  14. isShare: false,
  15. recordList: []
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad(options) {
  21. console.log(options, 'options');
  22. let videoId = options.videoId
  23. this.setData({
  24. videoId,
  25. isShare: options.isShare
  26. })
  27. this.getreadInfo(videoId)
  28. this.getPkRecord()
  29. },
  30. async getreadInfo(videoId) {
  31. let videoInfo = await getreadInfo(videoId)
  32. wx.setNavigationBarTitle({
  33. title: videoInfo.userRead.title
  34. })
  35. this.setData({
  36. videoInfo,
  37. currentId: videoId
  38. })
  39. },
  40. async getPkRecord() {
  41. let recordList = await getPkRecord({
  42. userReadId: this.data.videoId
  43. })
  44. this.setData({
  45. recordList
  46. })
  47. },
  48. jumpUserInfo({
  49. currentTarget
  50. }) {
  51. wx.navigateTo({
  52. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
  53. })
  54. },
  55. jumpIndex() {
  56. wx.switchTab({
  57. url: '/pages/index/index',
  58. })
  59. },
  60. addCommentNum() {
  61. this.setData({
  62. ['videoInfo.userRead.commentAmount']: ++this.data.videoInfo.userRead.commentAmount
  63. })
  64. },
  65. onUnload() {
  66. this.resetAudio()
  67. this.setData({
  68. currentId: ''
  69. })
  70. }
  71. })