123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <template>
- <view>
- <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
- <view class="user-list">
- <view class="item" v-for="(item,index) in dataList" :key="index">
- <view class="img-box">
- <image :src="item.avatar==null?'../../static/images/detault_head.jpg':item.avatar" mode=""></image>
- </view>
- <text class="name">{{item.nickname}}</text>
- </view>
- </view>
- </mescroll-body>
- </view>
- </template>
- <script>
- import {getArticleViewList} from '@/api/article';
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- export default {
- mixins: [MescrollMixin],
- data() {
- return {
- articleId:null,
- mescroll:null,
- // 上拉加载的配置
- upOption: {
- onScroll:true,
- use: true, // 是否启用上拉加载; 默认true
- page: {
- num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
- size: 10 // 每页数据的数量,默认10
- },
- noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
- empty: {
- icon:'/static/images/no_data.png',
- tip: '暂无数据'
- }
- },
- // 列表数据
- dataList: [],
-
- };
- },
- onLoad(option) {
- this.articleId=option.articleId;
- },
- methods:{
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- /*下拉刷新的回调 */
- downCallback(mescroll) {
- mescroll.resetUpScroll()
- },
- upCallback(page) {
- //联网加载数据
- var that = this;
- var data = {
- articleId:this.articleId,
- page: page.num,
- pageSize: page.size
- };
- getArticleViewList(data).then(res => {
- if(res.code==200){
- //设置列表数据
- if (page.num == 1) {
- that.dataList = res.data.list;
-
- } else {
- that.dataList = that.dataList.concat(res.data.list);
-
- }
- that.mescroll.endBySize(res.data.list.length, res.data.total);
-
- }else{
- uni.showToast({
- icon:'none',
- title: "请求失败",
- });
- that.dataList = null;
- that.mescroll.endErr();
- }
- });
- },
-
- }
- }
- </script>
- <style lang="scss">
- .user-list{
- background: #FFFFFF;
- padding: 40upx 30upx;
- margin-top: 20upx;
- .item{
- margin-bottom: 40upx;
- display: flex;
- align-items: center;
- &:last-child{
- margin-bottom: 0;
- }
- .img-box{
- width: 80upx;
- height: 80upx;
- border-radius: 50%;
- overflow: hidden;
- margin-right: 30upx;
- image{
- width: 100%;
- height: 100%;
- }
- }
- .name{
- font-size: 34upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- }
- }
- }
- </style>
|