view.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view>
  3. <navbar v-model="screenHeight" :iSimmersive="false" :placeholder="true" title="商品评论"></navbar>
  4. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :height="screenHeight+'px'">
  5. <view class="goods-comments clear">
  6. <view class="comments-empty" v-if="comments.length <= 0">该商品还没有评论哦!</view>
  7. <view class="goods-comments-list clear">
  8. <view class="goods-comments-box clear" v-for="(item,index) in comments" :key="index">
  9. <view class="t">
  10. <view class="u">
  11. <view><image :src="item.avatar"></view>
  12. <view>{{item.username}}</view>
  13. </view>
  14. <view class="time">{{item.time}}</view>
  15. </view>
  16. <view class="c">{{item.content}}</view>
  17. <view class="d" v-if="item.reply_content">
  18. <view class="d-1">商家回复</view>
  19. <view class="d-2">{{item.reply_content}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </mescroll-body>
  25. </view>
  26. </template>
  27. <script>
  28. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  29. import navbar from "@/components/navbar/navbar";
  30. export default {
  31. mixins: [MescrollMixin],
  32. components: {
  33. navbar
  34. },
  35. data() {
  36. return {
  37. screenHeight: 0,
  38. options: null,
  39. comments: []
  40. }
  41. },
  42. onLoad(options){
  43. this.options = options;
  44. },
  45. methods: {
  46. downCallback(){
  47. setTimeout(()=>{
  48. this.mescroll.resetUpScroll();
  49. },1200);
  50. },
  51. triggerDownScroll(){
  52. this.mescroll.triggerDownScroll();
  53. },
  54. upCallback(page) {
  55. this.$http.getGoodsComments({
  56. page: page.num,
  57. type: this.options.type,
  58. id: this.options.id
  59. }).then((result)=>{
  60. this.mescroll.endByPage(result.data.list.length, result.data.total);
  61. if(result.status==1){
  62. if(page.num == 1) this.comments = [];
  63. this.comments = this.comments.concat(result.data.list);
  64. }else if(result.status == -1){
  65. this.mescroll.removeEmpty();
  66. }
  67. }).catch(error=>{
  68. this.mescroll.endErr();
  69. });
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .goods-comments{
  76. margin-top: 20rpx;
  77. background-color: #fff;
  78. height: auto;
  79. .title {
  80. height: 80rpx;
  81. line-height: 80rpx;
  82. font-size: 32rpx;
  83. width: 100%;
  84. border-bottom: 2rpx solid #e8e8e8;
  85. view:nth-child(1){
  86. float: left;
  87. color: #333;
  88. padding-left: 30rpx;
  89. }
  90. view:nth-child(2){
  91. float: right;
  92. color: #999;
  93. padding-right: 30rpx;
  94. }
  95. }
  96. .comments-empty { padding: 100rpx 30rpx; text-align: center; font-size: 32rpx; color: #666; }
  97. .goods-comments-list{
  98. .goods-comments-box{
  99. border-bottom: 1px solid #e8e8e8;
  100. min-height: 240rpx;
  101. background-color: #fff;
  102. padding-bottom: 40rpx;
  103. .t {
  104. padding: 0 30rpx;
  105. height: 170rpx;
  106. line-height: 160rpx;
  107. color: #666;
  108. .u{
  109. float: left;
  110. font-size: 30rpx;
  111. view { float: left; }
  112. view:first-child{
  113. width: 96rpx; height: 96rpx;
  114. overflow: hidden; border-radius: 50%;
  115. background-color: #eee; display: inline-block;
  116. position: relative; top: 30rpx;
  117. image {
  118. width: 96rpx; height: 96rpx;
  119. }
  120. }
  121. view:last-child { position: relative; left: 20rpx; }
  122. }
  123. .time{
  124. float: right;
  125. font-size: 28rpx;
  126. }
  127. }
  128. .c{
  129. padding: 0 30rpx 10rpx 30rpx;
  130. font-size: 30rpx; color: #333;
  131. }
  132. .d {
  133. background-color: #f7f7f7;
  134. margin: 0 30rpx;
  135. .d-1 {
  136. padding: 10rpx 30rpx 0 30rpx;
  137. font-size: 30rpx;
  138. }
  139. .d-2 {
  140. padding: 20rpx 30rpx 20rpx 30rpx;
  141. font-size: 28rpx;
  142. }
  143. }
  144. }
  145. }
  146. }
  147. </style>