comment.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <gracePage :customHeader="false" footerBg="#FFFFFF">
  3. <!-- 页面主体 -->
  4. <view slot="gBody" class="grace-body">
  5. <view class="grace-margin-top">
  6. <text class="grace-title">静态演示</text>
  7. </view>
  8. <view class="grace-comments">
  9. <view class="grace-comments-items">
  10. <image src="https://graceui.oss-cn-beijing.aliyuncs.com/faces/1.png" class="grace-comments-face"></image>
  11. <view class="grace-comments-body">
  12. <view class="grace-comments-header">
  13. <text class="grace-comments-header-text">刘美丽</text>
  14. <text class="grace-comments-info-text">08/10 08:12</text>
  15. </view>
  16. <text class="grace-comments-content">上天呀!我渴望与你相知相惜,长存此心永不褪减。</text>
  17. <text class="grace-comments-replay">某某回复 : 回复文本</text>
  18. <view class="grace-comments-info">
  19. <text class="grace-comments-replay-btn">回复</text>
  20. <text class="grace-comments-header-text grace-icons icon-zan"> 999</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="grace-comments-items">
  25. <image src="https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png" class="grace-comments-face"></image>
  26. <view class="grace-comments-body">
  27. <view class="grace-comments-header">
  28. <text class="grace-comments-header-text">王小宝</text>
  29. </view>
  30. <text class="grace-comments-content">上天呀!我渴望与你相知相惜,长存此心永不褪减。</text>
  31. <view class="grace-comments-imgs">
  32. <view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png" class="grace-comments-img"></image></view>
  33. <view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png" class="grace-comments-img"></image></view>
  34. <view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/2.png" class="grace-comments-img"></image></view>
  35. <view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/1.png" class="grace-comments-img"></image></view>
  36. <view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png" class="grace-comments-img"></image></view>
  37. <view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png" class="grace-comments-img"></image></view>
  38. </view>
  39. <view class="grace-comments-info">
  40. <text class="grace-comments-info-text">08/10 08:1208/10 08:12</text>
  41. <text class="grace-comments-info-text grace-icons icon-zan"> 999</text>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="grace-margin-top">
  47. <text class="grace-title">动态数据演示</text>
  48. </view>
  49. <view class="grace-comments">
  50. <view class="grace-comments-items" v-for="(item, index) in commentContents" :key="index">
  51. <image :src="item.face" class="grace-comments-face"></image>
  52. <view class="grace-comments-body">
  53. <view class="grace-comments-header">
  54. <text class="grace-comments-header-text">{{item.name}}</text>
  55. <text class="grace-comments-header-text grace-icons">&#xe6ea; {{item.zan}}</text>
  56. </view>
  57. <text class="grace-comments-content">{{item.content}}</text>
  58. <view class="grace-comments-imgs" v-if="item.imgs">
  59. <view class="grace-comments-image" v-for="(img, indexImg) in item.imgs" :key="indexImg">
  60. <image :src="img" mode="widthFix" class="grace-comments-img" @click.stop="showImgs(index, indexImg)"></image>
  61. </view>
  62. </view>
  63. <view v-if="item.Reply">
  64. <text v-for="(itemRe, indexRe) in item.Reply" :key="indexRe" class="grace-comments-replay">{{itemRe.name}} : {{itemRe.content}}</text>
  65. </view>
  66. <view class="grace-comments-info">
  67. <text class="grace-comments-replay-btn">回复</text>
  68. <text class="grace-comments-info-text">{{item.date}}</text>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 占位视图 用于避开底部遮盖 -->
  74. <view style="height:120rpx;"></view>
  75. </view>
  76. <!-- 底部提交输入框 -->
  77. <view class="grace-nowrap grace-flex-vcenter grace-bg-white" slot="gFooter">
  78. <view class="grace-footer-input-body">
  79. <text class="grace-footer-input-icon grace-icons icon-write"></text>
  80. <input type="text" value="" v-model="commentContent" placeholder="说点什么吧..." class="grace-footer-input" />
  81. </view>
  82. <text class="grace-footer-subtext grace-blue" @tap="submitCommnets">提交</text>
  83. </view>
  84. </gracePage>
  85. </template>
  86. <script>
  87. import gracePage from "@/lib/graceUI/components/gracePage.vue";
  88. export default {
  89. data() {
  90. return {
  91. // 模拟评论数据 (实际项目来自api请求)
  92. commentContents : [
  93. {
  94. "content":"故国三千里,深宫二十年。一声何满子,双泪落君前。",
  95. "name":"graceUI - 小码",
  96. "face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/1.png",
  97. "date":"08/10 08:00",
  98. "zan" : 188,
  99. "Reply" : [
  100. {'name' : "张晓曦", "content":"不错不错"},
  101. {'name' : "王大陆", "content":"赞了~"},
  102. ]
  103. },
  104. {
  105. "content":"而今渐行渐远,渐觉虽悔难追。漫寄消寄息,终久奚为。也拟重论缱绻,争奈翻覆思维。纵再会,只恐恩情,难似当时。",
  106. "name":"路过繁华",
  107. "face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
  108. "date":"02/10 18:00",
  109. "zan" : 288
  110. },
  111. {
  112. "content":"图片回复,点击图片可以预览......",
  113. "name":"林夕阳",
  114. "imgs" : [
  115. "https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png",
  116. "https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png",
  117. "https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/1.png",
  118. ],
  119. "face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
  120. "date":"08/12 09:00",
  121. "zan" : 955
  122. }
  123. ],
  124. commentContent : ''
  125. }
  126. },
  127. methods:{
  128. submitCommnets : function(){
  129. uni.showToast({
  130. title:"评论内容 : " + this.commentContent,
  131. icon:"none"
  132. });
  133. },
  134. showImgs : function(commentsIndex, imgIndex){
  135. console.log(commentsIndex, imgIndex);
  136. uni.previewImage({
  137. urls:this.commentContents[commentsIndex].imgs,
  138. current:this.commentContents[commentsIndex].imgs[imgIndex]
  139. })
  140. }
  141. },
  142. components:{
  143. gracePage
  144. }
  145. }
  146. </script>
  147. <style>
  148. /* 请根据项目来规划自己的图片大小,请对图片进行等比缩放
  149. .grace-comments-image{width:190rpx; height:138rpx; margin:5rpx; font-size:0; overflow:hidden;}
  150. .grace-comments-img{width:190rpx; height:138rpx; border-radius:3rpx;}
  151. */
  152. </style>