index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. })
  38. },
  39. async getPkRecord() {
  40. let recordList = await getPkRecord({
  41. userReadId: this.data.videoId
  42. })
  43. this.setData({
  44. recordList
  45. })
  46. },
  47. jumpUserInfo({
  48. currentTarget
  49. }) {
  50. wx.navigateTo({
  51. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
  52. })
  53. },
  54. jumpIndex() {
  55. wx.switchTab({
  56. url: '/pages/index/index',
  57. })
  58. },
  59. addCommentNum() {
  60. this.setData({
  61. ['videoInfo.userRead.commentAmount']: ++this.data.videoInfo.userRead.commentAmount
  62. })
  63. },
  64. onUnload() {
  65. this.resetAudio()
  66. this.setData({
  67. currentId: ''
  68. })
  69. }
  70. })