list.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <!-- 页面 -->
  2. <template>
  3. <s-layout title="全部评价">
  4. <su-tabs
  5. :list="state.type"
  6. :scrollable="false"
  7. @change="onTabsChange"
  8. :current="state.currentTab"
  9. ></su-tabs>
  10. <view class="ss-m-t-20">
  11. <view class="list-item" v-for="item in state.pagination.data" :key="item">
  12. <view class="ss-flex ss-row-between">
  13. <view class="ss-flex">
  14. <image class="avatar" :src="sheep.$url.static(item.user_avatar)" />
  15. <view class="ss-m-l-20 ss-m-r-24 nickname">{{ item.user_nickname }}</view>
  16. <view><uni-rate :readonly="true" size="16" :value="item.level" /></view>
  17. </view>
  18. <view class="create-time">{{ item.create_time?.substring(0, 11) }}</view>
  19. </view>
  20. <view class="ss-m-t-20 content-title">{{ item.content }}</view>
  21. <view class="ss-m-t-40" v-if="item.images?.length">
  22. <scroll-view class="scroll-box" scroll-x scroll-anchoring enable-flex>
  23. <view class="ss-flex">
  24. <view v-for="i in item.images" :key="i" class="ss-m-r-20"
  25. ><image class="content-img" :src="sheep.$url.static(i)" />
  26. </view>
  27. </view>
  28. </scroll-view>
  29. </view>
  30. <!-- <view class="ss-flex ss-row-right">
  31. <text class="cicon-info-o"></text>
  32. <view class="ss-m-l-8 foot-title">举报</view>
  33. </view> -->
  34. </view>
  35. </view>
  36. <s-empty v-if="state.pagination.total === 0" text="暂无数据" icon="/static/data-empty.png" />
  37. <uni-load-more
  38. v-if="state.pagination.total > 0"
  39. :status="state.loadStatus"
  40. :content-text="{
  41. contentdown: '上拉加载更多',
  42. }"
  43. @tap="loadmore"
  44. />
  45. </s-layout>
  46. </template>
  47. <script setup>
  48. import sheep from '@/sheep';
  49. import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  50. import { computed, reactive } from 'vue';
  51. import _ from 'lodash';
  52. const state = reactive({
  53. list: [],
  54. type: [],
  55. currentTab: 0,
  56. pagination: {
  57. data: [],
  58. current_page: 1,
  59. total: 1,
  60. last_page: 1,
  61. },
  62. commentId: 0,
  63. code: 'all',
  64. });
  65. // 切换选项卡
  66. function onTabsChange(e) {
  67. state.pagination = {
  68. data: [],
  69. current_page: 1,
  70. total: 1,
  71. last_page: 1,
  72. };
  73. state.currentTab = e.index;
  74. state.code = e.code;
  75. getList(state.commentId, e.code);
  76. }
  77. async function getType(id) {
  78. const { error, data } = await sheep.$api.goods.getType(id);
  79. if (error === 0) {
  80. state.type = data;
  81. }
  82. }
  83. async function getList(id, code, page = 1, list_rows = 6) {
  84. state.loadStatus = 'loading';
  85. let res = await sheep.$api.goods.comment(id, {
  86. type: code,
  87. list_rows,
  88. page,
  89. });
  90. if (res.error === 0) {
  91. if (page >= 2) {
  92. let orderList = _.concat(state.pagination.data, res.data.data);
  93. state.pagination = {
  94. ...res.data,
  95. data: orderList,
  96. };
  97. } else {
  98. state.pagination = res.data;
  99. }
  100. if (state.pagination.current_page < state.pagination.last_page) {
  101. state.loadStatus = 'more';
  102. } else {
  103. state.loadStatus = 'noMore';
  104. }
  105. }
  106. }
  107. // 加载更多
  108. function loadmore() {
  109. if (state.loadStatus !== 'noMore') {
  110. getList(state.commentId, state.code, state.pagination.current_page + 1);
  111. }
  112. }
  113. onLoad((options) => {
  114. state.commentId = options.id;
  115. getType(state.commentId);
  116. getList(state.commentId);
  117. });
  118. // 上拉加载更多
  119. onReachBottom(() => {
  120. loadmore();
  121. });
  122. </script>
  123. <style lang="scss" scoped>
  124. .list-item {
  125. padding: 32rpx 30rpx 20rpx 20rpx;
  126. background: #fff;
  127. .avatar {
  128. width: 52rpx;
  129. height: 52rpx;
  130. border-radius: 50%;
  131. }
  132. .nickname {
  133. font-size: 26rpx;
  134. font-weight: 500;
  135. color: #999999;
  136. }
  137. .create-time {
  138. font-size: 24rpx;
  139. font-weight: 500;
  140. color: #c4c4c4;
  141. }
  142. .content-title {
  143. font-size: 26rpx;
  144. font-weight: 400;
  145. color: #666666;
  146. line-height: 42rpx;
  147. }
  148. .content-img {
  149. width: 174rpx;
  150. height: 174rpx;
  151. }
  152. .cicon-info-o {
  153. font-size: 26rpx;
  154. color: #c4c4c4;
  155. }
  156. .foot-title {
  157. font-size: 24rpx;
  158. font-weight: 500;
  159. color: #999999;
  160. }
  161. }
  162. .btn-box {
  163. width: 100%;
  164. height: 120rpx;
  165. background: #fff;
  166. border-top: 2rpx solid #eee;
  167. }
  168. .tab-btn {
  169. width: 130rpx;
  170. height: 62rpx;
  171. background: #eeeeee;
  172. border-radius: 31rpx;
  173. font-size: 28rpx;
  174. font-weight: 400;
  175. color: #999999;
  176. border: 1px solid #e5e5e5;
  177. margin-right: 10rpx;
  178. }
  179. </style>