丝袜av在线观看|日本美女三级片在线播放|性欧美一区二区三区|小骚热免费国产视频|黑人va在线观看|女同国产91视频|五月丁香色播Av|国产凸凹视频一区二区|伊人电影久久99|国产成人无码一区二区观看

評(píng)論標(biāo)列表簽

說明:用于獲取文檔的評(píng)論列表、評(píng)論分頁列表

使用方法:{% commentList 變量名稱 with archiveId="1" type="page|list" %} 如將變量定義為 comments {% commentList comments with archiveId="1" type="page" %}...{% endcommentList %}

commentList 支持的參數(shù)有:

  • 評(píng)論文檔ID archiveId archiveId 為指定的文檔ID;
  • 評(píng)論排序 order order 可以指定顯示的排序規(guī)則,支持依據(jù) id正序排序 order="id desc"、按id倒敘排序 order="id desc";
  • 顯示數(shù)量 limit數(shù)量的列表,比如limit="10"則只會(huì)顯示10條,limit 在不是分頁列表的時(shí)候,支持offset模式,也就是 ,分隔模式,如想從第2條開始,獲取10條數(shù)據(jù),可以設(shè)置成 limit="2,10";
  • 列表類型 type type 支持按 page、list 方式列出。默認(rèn)值為list,如果type="page" 后續(xù)可用 分頁標(biāo)簽 pagination 來組織分頁顯示 {% pagination pages with show="5" %}
  • 站點(diǎn)ID siteId siteId 一般不需要填寫,如果你使用后臺(tái)的多站點(diǎn)管理創(chuàng)建了多個(gè)站點(diǎn),并且想調(diào)用其他站點(diǎn)的數(shù)據(jù),則可以通過指定 siteId 來實(shí)現(xiàn)調(diào)用指定站點(diǎn)的數(shù)據(jù)。

comments 是一個(gè)數(shù)組對(duì)象,因此需要使用 for 循環(huán)來輸出

item 為 for循環(huán)體內(nèi)的變量,可用的字段有:

  • 評(píng)論ID Id
  • 類型內(nèi)容ID ArchiveId
  • 用戶名 UserName
  • 用戶ID UserId
  • 用戶IP Ip
  • 點(diǎn)贊數(shù)量 VoteCount
  • 評(píng)論內(nèi)容 Content
  • 上級(jí)評(píng)論ID ParentId
  • 審核狀態(tài) Status Status = 1 表示審核通過, status = 0 時(shí)審核中,不要顯示出來
  • 上級(jí)評(píng)論的對(duì)象數(shù)據(jù) Parent Parent 包含上級(jí)評(píng)論的完整 item,字段和評(píng)論item相同
  • 添加時(shí)間 CreatedTime 時(shí)間戳,需要使用格式化時(shí)間戳為日期格式 {{stampToDate(item.CreatedTime, "2006-01-02")}}

常規(guī)評(píng)論列表

{# list 列表展示 #}
<div>
{% commentList comments with archiveId=archive.Id type="list" limit="6" %}
    {% for item in comments %}
    <div>
      <div>
        <span>
          {% if item.Status != 1 %}
          審核中:{{item.UserName|truncatechars:6}}
          {% else %}
          {{item.UserName}}
          {% endif %}
        </span>
        {% if item.Parent %}
        <span>回復(fù)</span>
        <span>
          {% if item.Status != 1 %}
          審核中:{{item.Parent.UserName|truncatechars:6}}
          {% else %}
          {{item.Parent.UserName}}
          {% endif %}
        </span>
        {% endif %}
        <span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
      </div>
      <div>
        {% if item.Parent %}
        <blockquote>
          {% if item.Parent.Status != 1 %}
          該內(nèi)容正在審核中:{{item.Parent.Content|truncatechars:9}}
          {% else %}
          {{item.Parent.Content|truncatechars:100}}
          {% endif %}
        </blockquote>
        {% endif %}
        {% if item.Status != 1 %}
          該內(nèi)容正在審核中:{{item.Content|truncatechars:9}}
        {% else %}
        {{item.Content}}
        {% endif %}
      </div>
      <div class="comment-control" data-id="{{item.Id}}" data-user="{{item.UserName}}">
        <a class="item" data-id="praise">贊(<span class="vote-count">{{item.VoteCount}}</span>)</a>
        <a class="item" data-id=reply>回復(fù)</a>
      </div>
    </div>
    {% endfor %}
{% endcommentList %}
</div>

分頁展示評(píng)論列表

{# page 分頁列表展示 #}
<div>
{% commentList comments with archiveId=archive.Id type="page" limit="10" %}
    {% for item in comments %}
    <div>
      <div>
        <span>
          {% if item.Status != 1 %}
          審核中:{{item.UserName|truncatechars:6}}
          {% else %}
          {{item.UserName}}
          {% endif %}
        </span>
        {% if item.Parent %}
        <span>回復(fù)</span>
        <span>
          {% if item.Status != 1 %}
          審核中:{{item.Parent.UserName|truncatechars:6}}
          {% else %}
          {{item.Parent.UserName}}
          {% endif %}
        </span>
        {% endif %}
        <span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
      </div>
      <div>
        {% if item.Parent %}
        <blockquote>
          {% if item.Parent.Status != 1 %}
          該內(nèi)容正在審核中:{{item.Parent.Content|truncatechars:9}}
          {% else %}
          {{item.Parent.Content|truncatechars:100}}
          {% endif %}
        </blockquote>
        {% endif %}
        {% if item.Status != 1 %}
          該內(nèi)容正在審核中:{{item.Content|truncatechars:9}}
        {% else %}
        {{item.Content}}
        {% endif %}
      </div>
      <div class="comment-control" data-id="{{item.Id}}" data-user="{{item.UserName}}">
        <a class="item" data-id="praise">贊(<span class="vote-count">{{item.VoteCount}}</span>)</a>
        <a class="item" data-id=reply>回復(fù)</a>
      </div>
    </div>
    {% endfor %}
{% endcommentList %}
</div>

<div>
    {% pagination pages with show="5" %}
    <ul>
        <li>總數(shù):{{pages.TotalItems}}條,總共:{{pages.TotalPages}}頁,當(dāng)前第{{pages.CurrentPage}}頁</li>
        <li class="{% if pages.FirstPage.IsCurrent %}active{% endif %}"><a href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a></li>
        {% if pages.PrevPage %}
            <li><a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a></li>
        {% endif %}
        {% for item in pages.Pages %}
            <li class="{% if item.IsCurrent %}active{% endif %}"><a href="{{item.Link}}">{{item.Name}}</a></li>
        {% endfor %}
        {% if pages.NextPage %}
            <li><a href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a></li>
        {% endif %}
        <li class="{% if pages.LastPage.IsCurrent %}active{% endif %}"><a href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a></li>
    </ul>
    {% endpagination %}
</div>

評(píng)論表單提交

評(píng)論使用form表單提交,提交后臺(tái)接收的地址為:/comment/publish 。需要提交的字段有

字段是否必填說明
archive_id對(duì)應(yīng)的文檔ID
user_name評(píng)論的用戶名
content評(píng)論內(nèi)容
parent_id上級(jí)評(píng)論ID,當(dāng)回復(fù),某條評(píng)論的時(shí)候,要帶上才會(huì)產(chǎn)生關(guān)聯(lián)
return提交后,指定后端返回的格式,可選的值有:`html`、`json`,默認(rèn)為 html

表單代碼示例

<form method="post" action="/comment/publish">
  <input type="hidden" name="return" value="html">
  <input type="hidden" name="archive_id" value="{% archiveDetail with name="Id" %}">
  <div>
    <label>用戶名</label>
    <div>
      <input type="text" name="user_name" required lay-verify="required" placeholder="請(qǐng)?zhí)顚懩年欠Q" autocomplete="off">
    </div>
  </div>
  <div>
    <label>評(píng)論內(nèi)容</label>
    <div>
      <textarea name="content" placeholder="" id="comment-content-field" rows="5"></textarea>
    </div>
  </div>
  <div>
    <div>
      <button type="submit">提交評(píng)論</button>
      <button type="reset">重置</button>
    </div>
  </div>
</form>

評(píng)論內(nèi)容點(diǎn)贊

可以給某條評(píng)論的內(nèi)容點(diǎn)贊,點(diǎn)贊使用form表單提交,點(diǎn)贊提交后臺(tái)接收地址為:/comment/praise 。點(diǎn)贊需要提交的字段有:

字段是否必填說明
id評(píng)論內(nèi)容ID

評(píng)論點(diǎn)贊只支持返回 json 格式的數(shù)據(jù),因此需要用 js post 來提交。

示例代碼

<div class="comment-control">
  <a class="item vote-comment" data-id="praise" data-id="{{item.Id}}">贊(<span class="vote-count">{{item.VoteCount}}</span>)</a>
</div>
$('.vote-comment').click(function(e) {
        let that = $(this);
        let commentId = $(this).data('id');

        //贊
        $.ajax({
            url: '/comment/praise',
            method: "post",
            data: {id: commentId},
            dataType: "json",
            success: function (res) {
                if(res.code === 0) {
                  alert(res.msg);
                  that.find('.vote-count').text(res.data.vote_count)
                } else {
                    alert(res.msg);
                }
            },
            error: function (err) {
                alert(res.msg);
            }
        });
    });
問題反饋可加技術(shù)微信:tsrz001
目錄