123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- import {
- icommunity
- } from '../../../api/api.js'
- const app = getApp()
- Page({
- data: {
- showInfo: true,
- pagination: {
- page: 1,
- pagesize: 100
- },
- imgUrl: app.globalData.imgUrl,
- allowComments: false
- },
- clickFavor() {
- icommunity.loadArticleFavorToggle({
- reqdata: {
- id: this.data.article.id
- }
- }, r => {
- this.loadArticledetails()
- })
- },
- clickCollection() {
- icommunity.loadArticleCollectionToggle({
- reqdata: {
- id: this.data.article.id
- }
- }, r => {
- this.loadArticledetails()
- })
- },
- clickCommentconfirm() {
- console.log(1234)
- if (!this.data.comment) {
- return wx.showToast({
- icon: 'loading',
- title: '请输入内容',
- })
- }
- icommunity.loadAddArticlecomment({
- reqdata: {
- id: this.data.article.id,
- content: this.data.comment
- }
- }, r => {
- wx.showToast({
- icon: 'success',
- title: '提交成功',
- })
- this.setData({
- comment: '',
- isFocused: false
- })
- this.loadArticlecomments(true)
- })
- },
- inputComment(e) {
- this.setData({
- comment: e.detail.value,
- })
- },
- blurComment() {
- this.setData({
- isFocused: false,
- commentFocus: false
- })
- },
- focusComment() {
- this.setData({
- isFocused: true
- })
- },
- loadArticlecomments(hideLoading) {
- icommunity.loadArticlecomments(this.data.pagination, r => {
- this.setData({
- comments: r.list,
- ['article.num_comment']: r.list.length
- })
- }, hideLoading)
- },
- clickComments() {
- if (!this.data.showComments) {
- this.loadArticlecomments()
- }
- this.setData({
- showComments: !this.data.showComments
- })
- },
- clickCommemntInput() {
- this.setData({
- commentFocus: true
- })
- },
- clickVideo() {
- this.setData({
- showInfo: !this.data.showInfo,
- showComments: false
- })
- },
- loadArticledetails() {
- icommunity.loadArticledetails({
- reqdata: {
- id: this.data.article.id
- }
- }, r => {
- this.setData({
- article: r.object
- })
- })
- },
- onLoad(args) {
- this.setData({
- allowComments: app.config.open_comment == 1,
- article: app.data.nav.communityArticle,
- ['pagination.reqdata.id']: app.data.nav.communityArticle.id
- })
- this.loadArticledetails()
- }
- })
|