日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)百度小程序教程:comment-list 評(píng)論列表組件
  • comment-list 評(píng)論列表組件
    • 屬性說(shuō)明
      • comment-param 服務(wù)參數(shù)說(shuō)明
      • toolbar-config 參數(shù)說(shuō)明
      • view-more-style 參數(shù)說(shuō)明
      • 代碼示例 1:列表組件放入頁(yè)面
      • 代碼示例 2:列表支持折疊
    • 調(diào)起評(píng)論發(fā)布功能
      • 代碼示例:列表組件放入浮層且自定義底部 toolbar
    • Bug & Tip

    comment-list 評(píng)論列表組件

    解釋:評(píng)論列表,評(píng)論的相關(guān)數(shù)據(jù)為托管數(shù)據(jù)。
    Web 態(tài)說(shuō)明:由于瀏覽器的限制,在 Web 態(tài)內(nèi)暫不支持發(fā)布評(píng)論、收藏、分享等功能。

    屬性說(shuō)明

    屬性名類型必填默認(rèn)值說(shuō)明
    comment-paramObject評(píng)論核心參數(shù)
    toolbar-configObject底部 toolbar 的相關(guān)配置
    is-page-scrollBooleantrue滾動(dòng)方式為頁(yè)面滾動(dòng),若組件作為浮層使用,該參數(shù)需設(shè)為 false
    need-toolbarBooleantrue是否需要底部 toolbar ,若使用開(kāi)發(fā)者自定義的底部 toolbar ,該參數(shù)需設(shè)為 false
    add-commentBooleanfalse用于調(diào)起評(píng)論發(fā)布器發(fā)布評(píng)論
    detail-pathString點(diǎn)擊單條評(píng)論跳轉(zhuǎn)的詳情頁(yè)頁(yè)面 path ,若沒(méi)有配置則不會(huì)發(fā)生跳轉(zhuǎn);配置的前提是列表與詳情均是頁(yè)面級(jí)
    is-foldedBooleanfalse是否折疊列表,默認(rèn)全展示
    fold-numNumber3折疊后列表展示最大條數(shù),默認(rèn) 3 條,最多 10 條
    view-more-pathString傳入放置評(píng)論組件的頁(yè)面路徑,如‘/pages/list/index’,組件內(nèi)部會(huì)觸發(fā)跳轉(zhuǎn)邏輯
    view-more-styleObject『全部 xx 條』的樣式,目前只支持開(kāi)發(fā)者自定義字體顏色
    bindclickcommentEventHandler綁定點(diǎn)擊單條評(píng)論的事件,點(diǎn)擊單條評(píng)論時(shí)觸發(fā),返回?cái)?shù)據(jù)為{status, data:{srid}}
    bindviewmoreEventHandle綁定點(diǎn)擊更多事件,若除了頁(yè)面跳轉(zhuǎn)還需要其他操作,可通過(guò)該回調(diào)執(zhí)行;若為浮層,也可使用該回調(diào)自定義交互邏輯

    comment-param 服務(wù)參數(shù)說(shuō)明

    屬性名類型必填默認(rèn)值說(shuō)明示例值
    snidString文章的唯一標(biāo)識(shí),與 path 參數(shù)一一對(duì)應(yīng)‘20200101’
    titleString文章標(biāo)題
    pathString智能小程序內(nèi)頁(yè)鏈接,最長(zhǎng)不能超過(guò) 194 字符。如該文章需要入信息流投放,需保證該參數(shù)與信息流投放提交的 path 一致,否則將會(huì)影響流量“path”:”/pages/index/index”
    imagesArray數(shù)組第一項(xiàng)用于收藏功能的展示圖片[‘https://b.bdstatic.com/miniapp/images/demo-dog.png‘]

    toolbar-config 參數(shù)說(shuō)明

    屬性名類型必填默認(rèn)值說(shuō)明
    placeholderString輸入框提示文字
    moduleListArray[‘comment’, ‘like’, ‘favor’, ‘share’]顯示的互動(dòng)模塊,對(duì)應(yīng)默認(rèn)值分別是:評(píng)論數(shù)、點(diǎn)贊、收藏、分享
    shareObject若 moduleList 里配置了 share 模塊,該參數(shù)為必填
    share.titleString分享標(biāo)題
    share.contentString分享內(nèi)容
    share.imageUrlString分享圖標(biāo)
    share.pathString頁(yè)面 path ,必須是以 / 開(kāi)頭的完整路徑,如果 path 中參數(shù)包含中文字符,需對(duì)中文字符進(jìn)行編碼

    view-more-style 參數(shù)說(shuō)明

    屬性名類型必填默認(rèn)值說(shuō)明
    colorString‘#3388ff’『全部 xx 條』的字體顏色,默認(rèn)為視覺(jué)提供色號(hào),開(kāi)發(fā)者可傳入自定義色號(hào)

    代碼示例 1:列表組件放入頁(yè)面

    頁(yè)面中引用動(dòng)態(tài)庫(kù)組件的方式是:在頁(yè)面的 json 配置的 usingSwanComponents 字段中聲明組件引用。

    • JSON
     
     
     
    1. {
    2. "navigationBarTitleText": "評(píng)論列表",
    3. "usingSwanComponents": {
    4. "comment-list": "dynamicLib://myDynamicLib/comment-list"
    5. }
    6. }

    在頁(yè)面中放入列表組件,傳入必要的參數(shù)。

    • SWAN
    • JS
     
     
     
    1. comment-param="{{commentParam}}"
    2. detail-path="{{detailPath}}"
    3. toolbar-config="{{toolbarConfig}}"
    4. bindclickcomment="clickComment">
     
     
     
    1. Page({
    2. data: {
    3. commentParam: {},
    4. detailPath: '/pages/detail/index?params1=abd',
    5. // 底部互動(dòng) bar 的配置
    6. toolbarConfig: {
    7. // 若 moduleList 中配置有 share 模塊,默認(rèn)是有,則該屬性為必填,title 必傳
    8. share: {
    9. title: '測(cè)試文章標(biāo)題'
    10. }
    11. }
    12. },
    13. onLoad(query) {
    14. this.setData({
    15. commentParam: {
    16. snid: '10070000311753961',
    17. path: '/pages/comment/index?snid=test_snid57',
    18. title: '測(cè)試文章標(biāo)題',
    19. content: '測(cè)試文章內(nèi)容'
    20. }
    21. });
    22. },
    23. onReady() {
    24. requireDynamicLib('myDynamicLib').listenEvent();
    25. },
    26. clickComment(e) {
    27. }
    28. });

    代碼示例 2:列表支持折疊

    • SWAN
    • JS
    • JSON
    • CSS
     
     
     
    1. {{header.title}}
    2. {{header.author}}
    3. {{header.time}}
    4. {{item.data}}
    5. class="content-img"
    6. src="{{item.data.src}}"
    7. original-src="{{item.data.src}}"
    8. mode="widthFix"
    9. preview="true"
    10. lazy-load="true"/>
    11. comment-param="{{commentParam}}"
    12. is-folded="{{true}}"
    13. fold-num="{{foldNum}}"
    14. toolbar-config="{{toolbarConfig}}"
    15. bindclickcomment="clickComment"
    16. bindviewmore="viewMore">
    17. 歡迎使用智能小程序動(dòng)態(tài)庫(kù)
    18. 歡迎使用智能小程序動(dòng)態(tài)庫(kù)
    19. 歡迎使用智能小程序動(dòng)態(tài)庫(kù)
    20. class="img">
    21. 歡迎使用智能小程序動(dòng)態(tài)庫(kù)
    22. 歡迎使用智能小程序動(dòng)態(tài)庫(kù)
    23. 歡迎使用智能小程序動(dòng)態(tài)庫(kù)
     
     
     
    1. Page({
    2. data: {
    3. commentParam: {},
    4. header: {
    5. title: '心疼!中國(guó)自行車女將卷入摔車事故 腹部扎入3厘米木刺堅(jiān)持完賽',
    6. avatar: 'https://b.bdstatic.com/miniapp/images/demo-dog.png',
    7. author: '百度智能小程序',
    8. time: '2020年04月14日'
    9. },
    10. content: {
    11. items: [
    12. {
    13. type: 'image',
    14. data: {
    15. src: 'https://b.bdstatic.com/miniapp/images/demo-dog.png'
    16. }
    17. },
    18. {
    19. type: 'text',
    20. data: '測(cè)試文字'
    21. }
    22. ]
    23. },
    24. // 折疊展示最大評(píng)論條數(shù)
    25. foldNum: 5,
    26. // 底部互動(dòng) bar 的配置
    27. toolbarConfig: {
    28. // 若 moduleList 中配置有 share 模塊,默認(rèn)是有,則該屬性為必填,title 必傳
    29. share: {
    30. title: '心疼!中國(guó)自行車女將卷入摔車事故 腹部扎入3厘米木刺堅(jiān)持完賽'
    31. }
    32. }
    33. },
    34. onLoad(query) {
    35. this.setData({
    36. commentParam: {
    37. snid: '10070000311753961',
    38. path: '/pages/comment/index?snid=test_snid57',
    39. title: '測(cè)試文章標(biāo)題',
    40. content: '測(cè)試文章內(nèi)容'
    41. }
    42. });
    43. },
    44. onReady() {
    45. requireDynamicLib('myDynamicLib').listenEvent();
    46. },
    47. clickComment(e) {
    48. swan.showToast({
    49. title: 'click comment success'
    50. });
    51. },
    52. viewMore() {
    53. // swan.showToast({
    54. // title: 'click viewmore success'
    55. // });
    56. }
    57. });
     
     
     
    1. {
    2. "navigationBarTitleText": "折疊列表頁(yè)",
    3. "usingSwanComponents": {
    4. "comment-list": "dynamicLib://myDynamicLib/comment-list"
    5. }
    6. }
     
     
     
    1. .article-header {
    2. padding: 0 39.8rpx;
    3. }
    4. .article-header .title {
    5. display: block;
    6. font-size: 56rpx;
    7. line-height: 1.5;
    8. font-weight: 700;
    9. }
    10. .article-header .source {
    11. margin-top: 56rpx;
    12. display: flex;
    13. align-items: flex-start;
    14. }
    15. .article-header .source image {
    16. width: 82rpx;
    17. height: 82rpx;
    18. border-radius: 100%;
    19. margin-right: 18.7rpx;
    20. background-color: #eef1f4;
    21. background-size: 37.4rpx 37.4rpx;
    22. background-repeat: no-repeat;
    23. background-position: center center;
    24. background-image: url(../common/assets/logo-default.png);
    25. }
    26. .article-header .info {
    27. display: flex;
    28. flex-direction: column;
    29. justify-content: center;
    30. height: 82rpx;
    31. }
    32. .article-header .info .author {
    33. font-size: 37.4rpx;
    34. line-height: 1;
    35. display: block;
    36. color: #000;
    37. margin-bottom: 16.4rpx;
    38. }
    39. .article-header .info .time {
    40. display: block;
    41. color: #999;
    42. font-size: 28rpx;
    43. line-height: 1;
    44. }
    45. .article-content {
    46. color: #000;
    47. font-size: 44.5rpx;
    48. line-height: 1.58;
    49. letter-spacing: 2.84;
    50. margin-bottom: 70.2rpx;
    51. }
    52. .article-content .content-img {
    53. width: 100%;
    54. margin-top: 70.2rpx;
    55. vertical-align: bottom;
    56. background-color: #eef1f4;
    57. background-size: 74.9rpx 74.9rpx;
    58. background-repeat: no-repeat;
    59. background-position: center center;
    60. background-image: url(../common/assets/logo-default.png);
    61. }
    62. .article-content .content-p {
    63. margin: 57.3rpx 39.8rpx -12.9rpx 39.8rpx;
    64. text-align: justify;
    65. word-break: break-all;
    66. }
    67. .list-after {
    68. padding: 30rpx 18rpx 90rpx;
    69. }
    70. .comment-list-folded-bottom-margin {
    71. height: 14.4rpx;
    72. background-color: #f5f5f5;
    73. }

    調(diào)起評(píng)論發(fā)布功能

    若開(kāi)發(fā)者希望調(diào)起評(píng)論發(fā)布器,且與組件內(nèi)的評(píng)論發(fā)布邏輯保持一致(發(fā)布成功插入列表第一條,且滾動(dòng)到列表頂部),可使用如下方法:
    在 js 文件中,將 add-comment 屬性設(shè)為 true ,即可調(diào)起評(píng)論發(fā)布器。

    前提是評(píng)論列表組件已渲染。

    代碼示例:列表組件放入浮層且自定義底部 toolbar

    • SWAN
    • JS
    • JSON
    • CSS
     
     
     
    1. class="img">
    2. 這是背景
    3. 全部評(píng)論
    4. class="float-list-component"
    5. add-comment="{{addComment}}"
    6. is-page-scroll="{{false}}"
    7. comment-param="{{commentParam}}"
    8. need-toolbar="{{false}}"
    9. bindclickcomment="clickComment">
    10. 關(guān)閉
    11. 評(píng)論詳情
    12. class="float-detail-component"
    13. add-comment="{{publishComment}}"
    14. srid="{{srid}}"
    15. is-page-scroll="{{false}}"
    16. comment-param="{{commentParam}}"
    17. need-toolbar="{{false}}"
    18. back-list-after-delete="{{false}}"
    19. binddelete="detailDelete">
     
     
     
    1. Page({
    2. data: {
    3. commentParam: {},
    4. addComment: {},
    5. showList: false,
    6. showDetail: false,
    7. srid: ''
    8. },
    9. onLoad() {
    10. this.setData({
    11. commentParam: {
    12. snid: '10070000311753961',
    13. path: '/pages/comment/index',
    14. title: '測(cè)試文章標(biāo)題',
    15. 'snid_type': ''
    16. }
    17. });
    18. },
    19. clickComment(e) {
    20. this.setData({
    21. srid: e.data.srid,
    22. showDetail: true,
    23. showList: false
    24. });
    25. },
    26. addComment() {
    27. const showDetail = this.data.showDetail;
    28. if (!showDetail) {
    29. this.setData({
    30. showList: true,
    31. addComment: true
    32. }, () => {
    33. // 需要設(shè)為 false 的原因:因?yàn)檎{(diào)起發(fā)布監(jiān)聽(tīng) addComment 的變化,如果一直為 true,無(wú)法再次調(diào)起
    34. this.setData({
    35. 'addComment': false
    36. });
    37. });
    38. }
    39. else {
    40. this.setData({
    41. showList: false,
    42. publishComment: true
    43. }, () => {
    44. // 需要設(shè)為 false 的原因:因?yàn)檎{(diào)起發(fā)布監(jiān)聽(tīng) addComment 的變化,如果一直為 true,無(wú)法再次調(diào)起
    45. this.setData({
    46. 'publishComment': false
    47. });
    48. });
    49. }
    50. },
    51. /**
    52. * 詳情刪除后的回調(diào)
    53. *
    54. * @param {Object} options 返回的相關(guān)數(shù)據(jù),{status, data}
    55. * @property {string} srid 評(píng)論 id
    56. */
    57. detailDelete(options) {
    58. if (options.data.srid) {
    59. this.setData({
    60. showDetail: false,
    61. showList: true
    62. });
    63. }
    64. },
    65. closeDetail() {
    66. this.setData({
    67. showDetail: false,
    68. showList: true
    69. });
    70. }
    71. });
     
     
     
    1. {
    2. "navigationBarTitleText": "智能小程序示例",
    3. "usingSwanComponents": {
    4. "comment-list": "dynamicLib://myDynamicLib/comment-list",
    5. "comment-detail": "dynamicLib://myDynamicLib/comment-detail"
    6. }
    7. }
     
     
     
    1. page {
    2. height: 100%;
    3. }
    4. .container {
    5. display: flex;
    6. flex-direction: column;
    7. min-height: 100%;
    8. }
    9. .img {
    10. width: 100%;
    11. position: relative;
    12. z-index: -1;
    13. -webkit-overflow: visible;
    14. }
    15. .bg {
    16. flex: 1;
    17. }
    18. .float-list-wrap,
    19. .float-detail-wrap {
    20. background-color: #fff;
    21. position: fixed;
    22. bottom: 0;
    23. left: 0;
    24. display: block;
    25. height: 900rpx;
    26. animation: climbup .5s;
    27. width: 100%;
    28. z-index: 99;
    29. border-top: 1px solid #666;
    30. border-radius: 10rpx;
    31. }
    32. .float-title {
    33. text-align: center;
    34. padding: 20rpx 0;
    35. }
    36. .float-list-component,
    37. .float-detail-component {
    38. height: 100%;
    39. }
    40. .float-list,
    41. .float-detail {
    42. overflow-y: scroll;
    43. height: 700rpx;
    44. /* my-toolbar 有多高,這里就設(shè)多少 */
    45. margin-bottom: 90rpx;
    46. }
    47. .float-detail-close {
    48. float: right;
    49. padding: 20rpx;
    50. }
    51. .my-toolbar {
    52. position: fixed;
    53. bottom: 0;
    54. width: 100%;
    55. height: 90rpx;
    56. background-color: #fff;
    57. z-index: 999;
    58. font-size: 28.99rpx;
    59. }
    60. @keyframes climbup {
    61. /* 因?yàn)楦訅K高度為800rpx */
    62. 0% {
    63. height: 0;
    64. }
    65. 25% {
    66. height: 200rpx;
    67. }
    68. 50% {
    69. height: 400rpx;
    70. }
    71. 75% {
    72. height: 600rpx;
    73. }
    74. 100% {
    75. height: 900rpx;
    76. }
    77. }

    Bug & Tip

    • Tip:評(píng)論列表數(shù)據(jù)開(kāi)發(fā)者無(wú)法單獨(dú)獲取,也無(wú)需配置,評(píng)論列表會(huì)托管給組件,開(kāi)發(fā)者接入組件之后,用戶評(píng)論發(fā)布后會(huì)展現(xiàn)在評(píng)論列表上(自己可見(jiàn)),審核通過(guò)后會(huì)全體用戶可見(jiàn)。
    • Tip:openid 和百度 App 登錄狀態(tài)(合稱登錄狀態(tài))會(huì)影響用戶的發(fā)布評(píng)論、舉報(bào)、刪除、消息提醒、跳轉(zhuǎn)個(gè)人主頁(yè)和頁(yè)面收藏(合稱互動(dòng)行為),未登錄用戶僅可以瀏覽評(píng)論和點(diǎn)贊。
    • Tip:收藏功能在基礎(chǔ)庫(kù) 3.190.1 以上可用。
    • Tip:由于 swan.login API 的非兼容改造,一站式互動(dòng)組件統(tǒng)一改為在組件內(nèi)強(qiáng)登錄。

    網(wǎng)頁(yè)名稱:創(chuàng)新互聯(lián)百度小程序教程:comment-list 評(píng)論列表組件
    網(wǎng)頁(yè)網(wǎng)址:http://www.dlmjj.cn/article/cojgdci.html