SsChatReplyCategory.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="ss-chat-reply-category">
  3. <template v-if="records" v-for="item in records">
  4. <view class="item" @tap="questSend(item.itemContent)">{{item.itemContent}}</view>
  5. </template>
  6. <view class="category-footer">
  7. <button class="footer-btn" @tap="loadNext">
  8. <uni-load-more v-if="loading" iconType="circle" :show-text="false" status="loading" color="#7E8AA2"
  9. :icon-size="12" />
  10. {{ finish ? '没有更多了' : '更多' }}
  11. </button>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. RequestApi
  18. } from '@/api/requestApi';
  19. export default {
  20. props: {
  21. categoryId: {
  22. type: Number,
  23. require: true
  24. }
  25. },
  26. data() {
  27. return {
  28. loading: false,
  29. finish: false,
  30. records: [],
  31. pageNum: 1,
  32. pageSize: 6
  33. }
  34. },
  35. mounted() {
  36. this.pageNum = 1;
  37. this.loadCategory();
  38. },
  39. methods: {
  40. loadCategory() {
  41. if (this.loading || this.finish) {
  42. return;
  43. }
  44. RequestApi.getCategory(this.categoryId, this.pageNum, this.pageSize).then(result => {
  45. if (result) {
  46. this.records = this.records.concat(result.records);
  47. if (result.current >= result.pages) {
  48. this.finish = true;
  49. }
  50. this.loading = false;
  51. this.$emit('changeChat');
  52. }
  53. });
  54. },
  55. loadNext() {
  56. this.pageNum++;
  57. this.loadCategory();
  58. },
  59. questSend(msg) {
  60. this.$emit('quickSend', msg);
  61. }
  62. }
  63. }
  64. </script>
  65. <style scoped lang="scss">
  66. .ss-chat-reply-category {
  67. display: block;
  68. flex-wrap: wrap;
  69. margin: 0 -16rpx 32rpx -16rpx;
  70. .item {
  71. padding: 24rpx;
  72. margin: 0 16rpx 24rpx 16rpx;
  73. border: 2rpx solid #d5d6d8;
  74. border-radius: 16rpx;
  75. background-color: #ffffff;
  76. font-size: 28rpx;
  77. }
  78. .category-footer {
  79. text-align: center;
  80. .footer-btn {
  81. border: 0;
  82. height: unset;
  83. padding: 0;
  84. background-color: transparent;
  85. font-size: 24rpx;
  86. color: #7E8AA2;
  87. &::after {
  88. display: none;
  89. }
  90. &:hover {
  91. background-color: #ffffff;
  92. }
  93. }
  94. }
  95. }
  96. </style>