videoDetails.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import {
  2. icommunity
  3. } from '../../../api/api.js'
  4. const app = getApp()
  5. Page({
  6. data: {
  7. showInfo: true,
  8. pagination: {
  9. page: 1,
  10. pagesize: 100
  11. },
  12. imgUrl: app.globalData.imgUrl,
  13. allowComments: false
  14. },
  15. clickFavor() {
  16. icommunity.loadArticleFavorToggle({
  17. reqdata: {
  18. id: this.data.article.id
  19. }
  20. }, r => {
  21. this.loadArticledetails()
  22. })
  23. },
  24. clickCollection() {
  25. icommunity.loadArticleCollectionToggle({
  26. reqdata: {
  27. id: this.data.article.id
  28. }
  29. }, r => {
  30. this.loadArticledetails()
  31. })
  32. },
  33. clickCommentconfirm() {
  34. console.log(1234)
  35. if (!this.data.comment) {
  36. return wx.showToast({
  37. icon: 'loading',
  38. title: '请输入内容',
  39. })
  40. }
  41. icommunity.loadAddArticlecomment({
  42. reqdata: {
  43. id: this.data.article.id,
  44. content: this.data.comment
  45. }
  46. }, r => {
  47. wx.showToast({
  48. icon: 'success',
  49. title: '提交成功',
  50. })
  51. this.setData({
  52. comment: '',
  53. isFocused: false
  54. })
  55. this.loadArticlecomments(true)
  56. })
  57. },
  58. inputComment(e) {
  59. this.setData({
  60. comment: e.detail.value,
  61. })
  62. },
  63. blurComment() {
  64. this.setData({
  65. isFocused: false,
  66. commentFocus: false
  67. })
  68. },
  69. focusComment() {
  70. this.setData({
  71. isFocused: true
  72. })
  73. },
  74. loadArticlecomments(hideLoading) {
  75. icommunity.loadArticlecomments(this.data.pagination, r => {
  76. this.setData({
  77. comments: r.list,
  78. ['article.num_comment']: r.list.length
  79. })
  80. }, hideLoading)
  81. },
  82. clickComments() {
  83. if (!this.data.showComments) {
  84. this.loadArticlecomments()
  85. }
  86. this.setData({
  87. showComments: !this.data.showComments
  88. })
  89. },
  90. clickCommemntInput() {
  91. this.setData({
  92. commentFocus: true
  93. })
  94. },
  95. clickVideo() {
  96. this.setData({
  97. showInfo: !this.data.showInfo,
  98. showComments: false
  99. })
  100. },
  101. loadArticledetails() {
  102. icommunity.loadArticledetails({
  103. reqdata: {
  104. id: this.data.article.id
  105. }
  106. }, r => {
  107. this.setData({
  108. article: r.info
  109. })
  110. })
  111. },
  112. onLoad(args) {
  113. this.setData({
  114. allowComments: app.config.open_comment == 1,
  115. article: app.data.nav.communityArticle,
  116. ['pagination.reqdata.id']: app.data.nav.communityArticle.id
  117. })
  118. this.loadArticledetails()
  119. }
  120. })