index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. let videoId = options.videoId
  22. this.setData({
  23. videoId,
  24. isShare: options.isShare
  25. })
  26. this.getreadInfo(videoId)
  27. this.getPkRecord()
  28. },
  29. async getreadInfo(videoId) {
  30. let videoInfo = await getreadInfo(videoId)
  31. wx.setNavigationBarTitle({
  32. title: videoInfo.userRead.title
  33. })
  34. this.setData({
  35. videoInfo
  36. })
  37. },
  38. async getPkRecord() {
  39. let recordList = await getPkRecord({
  40. userReadId: this.data.videoId
  41. })
  42. this.setData({
  43. recordList
  44. })
  45. },
  46. jumpUserInfo({
  47. currentTarget
  48. }) {
  49. wx.navigateTo({
  50. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
  51. })
  52. },
  53. jumpIndex() {
  54. wx.switchTab({
  55. url: '/pages/index/index',
  56. })
  57. },
  58. addCommentNum() {
  59. this.setData({
  60. ['videoInfo.userRead.commentAmount']: ++this.data.videoInfo.userRead.commentAmount
  61. })
  62. },
  63. onUnload() {
  64. this.resetAudio()
  65. this.setData({
  66. currentId: ''
  67. })
  68. }
  69. })