readUsers.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view>
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  4. <view class="user-list">
  5. <view class="item" v-for="(item,index) in dataList" :key="index">
  6. <view class="img-box">
  7. <image :src="item.avatar==null?'../../static/images/detault_head.jpg':item.avatar" mode=""></image>
  8. </view>
  9. <text class="name">{{item.nickname}}</text>
  10. </view>
  11. </view>
  12. </mescroll-body>
  13. </view>
  14. </template>
  15. <script>
  16. import {getArticleViewList} from '@/api/article';
  17. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  18. export default {
  19. mixins: [MescrollMixin],
  20. data() {
  21. return {
  22. articleId:null,
  23. mescroll:null,
  24. // 上拉加载的配置
  25. upOption: {
  26. onScroll:true,
  27. use: true, // 是否启用上拉加载; 默认true
  28. page: {
  29. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  30. size: 10 // 每页数据的数量,默认10
  31. },
  32. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  33. empty: {
  34. icon:'/static/images/no_data.png',
  35. tip: '暂无数据'
  36. }
  37. },
  38. // 列表数据
  39. dataList: [],
  40. };
  41. },
  42. onLoad(option) {
  43. this.articleId=option.articleId;
  44. },
  45. methods:{
  46. mescrollInit(mescroll) {
  47. this.mescroll = mescroll;
  48. },
  49. /*下拉刷新的回调 */
  50. downCallback(mescroll) {
  51. mescroll.resetUpScroll()
  52. },
  53. upCallback(page) {
  54. //联网加载数据
  55. var that = this;
  56. var data = {
  57. articleId:this.articleId,
  58. page: page.num,
  59. pageSize: page.size
  60. };
  61. getArticleViewList(data).then(res => {
  62. if(res.code==200){
  63. //设置列表数据
  64. if (page.num == 1) {
  65. that.dataList = res.data.list;
  66. } else {
  67. that.dataList = that.dataList.concat(res.data.list);
  68. }
  69. that.mescroll.endBySize(res.data.list.length, res.data.total);
  70. }else{
  71. uni.showToast({
  72. icon:'none',
  73. title: "请求失败",
  74. });
  75. that.dataList = null;
  76. that.mescroll.endErr();
  77. }
  78. });
  79. },
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .user-list{
  85. background: #FFFFFF;
  86. padding: 40upx 30upx;
  87. margin-top: 20upx;
  88. .item{
  89. margin-bottom: 40upx;
  90. display: flex;
  91. align-items: center;
  92. &:last-child{
  93. margin-bottom: 0;
  94. }
  95. .img-box{
  96. width: 80upx;
  97. height: 80upx;
  98. border-radius: 50%;
  99. overflow: hidden;
  100. margin-right: 30upx;
  101. image{
  102. width: 100%;
  103. height: 100%;
  104. }
  105. }
  106. .name{
  107. font-size: 34upx;
  108. font-family: PingFang SC;
  109. font-weight: 500;
  110. color: #333333;
  111. }
  112. }
  113. }
  114. </style>