| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <template>
- <view class="center">
- <view v-for="(item,index) in dataList" :key="index">
-
- </view>
- </view>
- </template>
- <script>
- import { getEvaluate} from '@/api/course.js'
- export default {
- data() {
- return{
- page: 1,
- limit: 10,
- loadingType: 'more',
- dataList:[]
- }
- },
- onLoad() {
- this.loadData()
- },
- //下拉刷新
- onPullDownRefresh() {
- this.loadData('refresh');
- },
- //监听页面是否滚动到底部加载更多
- onReachBottom() {
- this.loadData();
- },
- methods: {
- async loadData(type = 'add', loading){
- let obj = this;
- if (type === 'add') {
- if (obj.loadingType === 'nomore') {
- return;
- }
- obj.loadingType = 'loading';
- } else {
- obj.loadingType = 'more';
- }
- if (type === 'refresh') {
- // 清空数组
- obj.courseList = [];
- obj.page = 1
- }
- //获取反馈列表
- getEvaluate({
- page: obj.page,
- limit: obj.limit
- }).then(e => {
- console.log(e)
- obj.dataList = obj.dataList.concat(e.data.data);
- console.log(obj.dataList)
- //判断是否还有下一页,有是more 没有是nomore
- if (obj.limit==e.data.length) {
- obj.page++
- obj.loadingType='more'
- } else{
- obj.loadingType='nomore'
- }
- if (type === 'refresh') {
- if (loading == 1) {
- uni.hideLoading();
- } else {
- uni.stopPullDownRefresh();
- }
- }
- })
- },
-
- }
- }
- </script>
- <style lang="scss">
- </style>
|