learn.vue 2.98 KB
Newer Older
乐宝呗666's avatar
乐宝呗666 committed
1 2
<template>
  <div class="learn-conatiner">
乐宝呗666's avatar
乐宝呗666 committed
3 4
    <Header title="学习项目" />
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
乐宝呗666's avatar
乐宝呗666 committed
5 6 7 8 9 10 11 12 13 14 15 16 17
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
        offset="5"
      >
        <van-cell
          v-for="(item, index) in list"
          :key="index"
          @click="goDetail(item)"
        >
          <span>{{ item.name }}</span>
18
          <img src="@/assets/images/applets/coming.png" alt />
乐宝呗666's avatar
乐宝呗666 committed
19 20
        </van-cell>
      </van-list>
乐宝呗666's avatar
乐宝呗666 committed
21
    </van-pull-refresh>
乐宝呗666's avatar
乐宝呗666 committed
22 23 24 25 26
    <my-tabbar active="1"></my-tabbar>
  </div>
</template>

<script>
乐宝呗666's avatar
乐宝呗666 committed
27
import Header from "@/components/Header/index.vue";
乐宝呗666's avatar
乐宝呗666 committed
28
export default {
乐宝呗666's avatar
乐宝呗666 committed
29
  components: { Header },
乐宝呗666's avatar
乐宝呗666 committed
30 31
  data() {
    return {
乐宝呗666's avatar
乐宝呗666 committed
32 33 34 35
      loading: false,
      finished: false,
      pageNum: 1,
      pageSize: 10,
36
      flag: true, // 是否是第一次加载
乐宝呗666's avatar
乐宝呗666 committed
37 38
      list: [],
      refreshing: false,
乐宝呗666's avatar
乐宝呗666 committed
39 40
    };
  },
乐宝呗666's avatar
乐宝呗666 committed
41 42
  mounted() {
    this.getList();
乐宝呗666's avatar
乐宝呗666 committed
43
  },
乐宝呗666's avatar
乐宝呗666 committed
44 45 46 47 48 49 50
  methods: {
    // 获取管理员列表
    getList() {
      let vm = this;
      let param = {
        _index: this.pageNum,
        _size: this.pageSize,
乐宝呗666's avatar
乐宝呗666 committed
51
        type: JSON.parse(sessionStorage.getItem("userInfo")).type,
乐宝呗666's avatar
乐宝呗666 committed
52 53 54 55 56
      };
      vm.$https(
        {
          url: "learningProject/getPageList",
          method: "post",
乐宝呗666's avatar
乐宝呗666 committed
57
          authType: this.backToken,
乐宝呗666's avatar
乐宝呗666 committed
58 59 60
        },
        vm.$qs.stringify(param)
      )
乐宝呗666's avatar
乐宝呗666 committed
61 62 63 64 65 66 67 68 69 70 71 72
        .then((res) => {
          if (res.data.resultCode === "200") {
            let data = res.data.data;
            this.loading = false;
            vm.list = this.flag ? data.records : vm.list.concat(data.records);
            this.pageNum = this.pageNum + 1;
            this.finished = data.records.length < this.pageSize;
            this.flag = false;
            this.refreshing = false;
          } else {
            this.$toast(res.data.message);
          }
乐宝呗666's avatar
乐宝呗666 committed
73
        })
乐宝呗666's avatar
乐宝呗666 committed
74
        .catch(function (err) {
乐宝呗666's avatar
乐宝呗666 committed
75 76 77 78 79
          console.log(err);
        });
    },
    // 列表的load上拉加载事件
    onLoad() {
乐宝呗666's avatar
乐宝呗666 committed
80
      if (!this.flag) {
乐宝呗666's avatar
乐宝呗666 committed
81 82 83 84
        console.log("加载数据");
        this.loading = true;
        this.flag = false;
        this.getList();
乐宝呗666's avatar
乐宝呗666 committed
85
      }
乐宝呗666's avatar
乐宝呗666 committed
86 87 88 89 90 91
    },
    onRefresh() {
      // 清空列表数据
      this.finished = false;
      this.flag = true;
      this.loading = true;
乐宝呗666's avatar
乐宝呗666 committed
92
      this.pageNum = 1;
乐宝呗666's avatar
乐宝呗666 committed
93 94 95 96
      this.getList();
    },
    goDetail(item) {
      this.$router.push({ path: "/learnContent", query: { id: item.id } });
乐宝呗666's avatar
乐宝呗666 committed
97 98
    },
  },
乐宝呗666's avatar
乐宝呗666 committed
99 100 101 102 103 104 105
};
</script>

<style lang="scss" scoped>
.learn-conatiner {
  width: 100%;
  height: 100vh;
乐宝呗666's avatar
乐宝呗666 committed
106 107 108
  padding: 50px 16px 60px;
  display: flex;
  flex-direction: column;
乐宝呗666's avatar
乐宝呗666 committed
109
  box-sizing: border-box;
乐宝呗666's avatar
乐宝呗666 committed
110
  .van-pull-refresh {
乐宝呗666's avatar
乐宝呗666 committed
111 112
    overflow-y: auto;
    padding: 0 8px;
乐宝呗666's avatar
乐宝呗666 committed
113 114 115
  }
  .van-cell {
    padding: 0;
乐宝呗666's avatar
乐宝呗666 committed
116
  }
乐宝呗666's avatar
乐宝呗666 committed
117
  .van-cell__value {
乐宝呗666's avatar
乐宝呗666 committed
118 119 120 121 122 123 124 125 126
    display: flex;
    justify-content: space-between;
    background: #f8f8f8;
    border-radius: 33px;
    font-size: 16px;
    padding: 12px;
    color: #333333;
    margin-top: 20px;
    img {
乐宝呗666's avatar
乐宝呗666 committed
127 128
      width: 24px;
      height: 24px;
乐宝呗666's avatar
乐宝呗666 committed
129 130 131 132
    }
  }
}
</style>