fans.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view>
  3. <mescroll-body top="40" bottom="40" @init="mescrollInit" @down="downCallback" @up="upCallback" :option="{}">
  4. <view class="fans-list">
  5. <view class="fans-item" v-for="(item,index) in list" :key="item.id">
  6. <image class="fans-avatar" :src="item.fansUserPortrait" mode="">
  7. </image>
  8. <view class="fans-content">
  9. <view class="fans-name">{{item.fansUserName}}</view>
  10. <view class="fans-organization">{{item.date}}</view>
  11. </view>
  12. <view class="fans-icon"
  13. @click="$navigateTo('/pages/chat/chat?userId='+item.fansUserId+'&userName='+item.fansUserName)">
  14. <uni-icons type="chat-filled" color="#fff" size="22"></uni-icons>
  15. </view>
  16. </view>
  17. </view>
  18. </mescroll-body>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. getFansListByPage
  24. } from '@/request/api/my.js'
  25. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  26. export default {
  27. mixins: [MescrollMixin], // 使用mixin
  28. data() {
  29. return {
  30. list: []
  31. }
  32. },
  33. methods: {
  34. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  35. upCallback(page) {
  36. getFansListByPage(page.num, 10).then(res => {
  37. if (res.code === 200) {
  38. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  39. if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
  40. let data = res.data.dataList;
  41. this.list = this.list.concat(data); //追加新数据
  42. } else {
  43. this.mescroll.endErr();
  44. }
  45. }).catch(() => {
  46. //联网失败, 结束加载
  47. this.mescroll.endErr();
  48. })
  49. },
  50. }
  51. }
  52. </script>
  53. <style lang="scss">
  54. .fans-list {
  55. padding: 0 30rpx;
  56. box-sizing: border-box;
  57. .fans-item {
  58. height: 140rpx;
  59. background-color: #ffffff;
  60. border-radius: 8px;
  61. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
  62. display: flex;
  63. align-items: center;
  64. padding: 0 30rpx;
  65. }
  66. .fans-avatar {
  67. width: 100rpx;
  68. height: 100rpx;
  69. border-radius: 100rpx;
  70. }
  71. .fans-content {
  72. flex: 1;
  73. width: 0;
  74. margin-left: 20rpx;
  75. }
  76. .fans-name {
  77. font-size: 32rpx;
  78. }
  79. .fans-organization {
  80. color: $uni-secondary-color;
  81. font-weight: 300;
  82. margin-top: 4rpx;
  83. font-size: 24rpx;
  84. }
  85. .fans-icon {
  86. width: 80rpx;
  87. height: 80rpx;
  88. border-radius: 50%;
  89. background: $uni-primary;
  90. text-align: center;
  91. line-height: 80rpx;
  92. }
  93. }
  94. </style>