使用uni-app怎么實(shí)現(xiàn)一個點(diǎn)贊評論功能

這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)使用uni-app怎么實(shí)現(xiàn)一個點(diǎn)贊評論功能,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

遼陽網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站等網(wǎng)站項目制作,到程序開發(fā),運(yùn)營維護(hù)。成都創(chuàng)新互聯(lián)公司成立于2013年到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)公司

html

<view class="toolbar">
  <view class="timestamp">{{item.timetype}}</view>
  <!-- 點(diǎn)贊 如果islove==1,圖片變?yōu)辄c(diǎn)贊的圖片-->
  <view class="like" @tap="like(index,item.id)">
    <image :src="item.islove==1?'../../static/images/lllllike.png':'../../static/images/llike.png'"></image>
  </view>
  <!-- 評論 -->
  <view class="comment" @tap="comment(index,item.id)">
    <image src="../../static/images/pinglun.png"></image>
  </view>
</view>
<!-- 贊/評論區(qū) -->
<view class="post-footer">
  <!-- 點(diǎn)贊區(qū) -->
  <view class="footer_content" v-if="item.lovelist.length>0">
    <image class="liked" src="../../static/images/likelike.png"></image>
    <text class="nickname" v-for="(love,love_index) of item.lovelist" :key="love_index">{{love.name}},</text>
  </view>
  <!-- 評論區(qū) -->
  <view class="footer_content" v-if="item.community_on.length>0" v-for="(comment,comment_index) in item.community_on" :key="comment_index">
    <text class="comment-nickname">{{comment.nickname}}: <text class="comment-content">{{comment.content}}</text></text>
  </view>
   <!-- 當(dāng)評論發(fā)送成功之后實(shí)時渲染出來評論列表-->
  <view class="footer_content" v-if="commentStatus && index==commentIndex">
    <text class="comment-nickname">{{realtimename}}: <text class="comment-content">{{realtimecontent}}</text></text>
  </view>
</view>
// 點(diǎn)贊
like(index,communityId) {
  if (this.community[index].islove == 0) {
    this.community[index].islove = 1;
    this.community[index].lovelist.push(
      {name:this.userinfo.nickname,vipid:this.userinfo.id}
    )
    this.likeImport(communityId)
  } else {
    this.community[index].islove = 0;
    this.community[index].lovelist.splice(this.community[index].lovelist.indexOf(this.userinfo.nickname), 1)
    this.likeImport(communityId)
  }
},
// 點(diǎn)贊接口
likeImport(id) {
  app.vipidRequest({
    url: 'Vip/community_love',
    data: {
      id: id
    },
    header: {
      'content-type': 'application/x-www-form-urlencoded', 
    },
    method: 'POST',
    success:(res) => {
      if(res.data.status) {

      } else {
        console.log(res.data)
      }
    }
  })
},
// 點(diǎn)擊評論
comment(index,communityId) {
  this.showInput = true; //調(diào)起input框
  this.focus = true; // 對焦
  this.communityId = communityId
},
// 點(diǎn)擊發(fā)送
send_comment: function(message) {
  this.commentStatus = true 
  this.commentIndex = index
  this.realtimecontent = message.content
  this.realtimename = this.userinfo.nickname
  app.vipidRequest({
    url: 'Vip/community_on',
    data: {
      id: this.communityId,
      content: message.content,
      type: 1
    },
    header: {
      'content-type': 'application/x-www-form-urlencoded', 
    },
    method: 'POST',
    success:(res) => {
      if(res.data.status) {
        this.getCommunity() // 整個頁面數(shù)據(jù)刷新
        this.init_input()
        this.commentStatus = false // 臨時渲染評論的列表隱藏
        this.realtimecontent = ''
        this.realtimename = ''
        this.input_placeholder = '評論';
      } else {
        console.log(res.data)
      }
    }
  })
}
// 取消評論/評論完成輸入框狀態(tài)值
init_input() {
  this.showInput = false;
  this.focus = false;
  this.input_placeholder = '評論';
  this.is_reply = false;
},

上述就是小編為大家分享的使用uni-app怎么實(shí)現(xiàn)一個點(diǎn)贊評論功能了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)站名稱:使用uni-app怎么實(shí)現(xiàn)一個點(diǎn)贊評論功能
URL網(wǎng)址:http://bm7419.com/article12/igsgdc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序企業(yè)網(wǎng)站制作、Google、ChatGPT、小程序開發(fā)、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)