videoDetails.js 2.3 KB

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