activeList.vue 4.34 KB
<template>
  <div class="container">
    <div class="title">
      <span>大转盘抽奖</span>
    </div>
    <div class="active">
      <template v-for="(item, index) in activeList">
        <div
          v-if="index < wheelActive_limit"
          class="list"
          :key="item.id"
          @click="toDetail(item.id, item.activityType)"
        >
          <div class="left">
            <img :src="item.logo" alt="logo" style="width:100%;height:100%;" />
          </div>
          <div class="right">
            <h3>{{ item.activityName }}</h3>
            <p>{{ item.des }}</p>
          </div>
        </div>
      </template>
      <span
        class="more"
        v-if="activeList.length && !activeList_finished"
        @click="handleWheelActiveMore"
      >
        查看更多
        <span class="icon">></span>
      </span>
    </div>
    <div v-if="couponList.length > 0" class="fg">送券活动</div>
    <div class="active">
      <div
        class="list"
        v-for="item in couponList"
        :key="item.id"
        @click="toDetail(item.id, item.activityType)"
      >
        <div class="left"></div>
        <div class="right">
          <h3>{{ item.activityName }}</h3>
          <p>{{ item.des }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import * as API_Active from "@/api/active";
export default {
  data() {
    return {
      wheelActive_limit: 3,
      activeList_finished: false,
      activeList: [
        {
          id: 1,
          activityType: "coupon",
          activityName: "砍价",
          des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
        },
        {
          id: 2,
          activityType: "wheel",
          activityName: "集赞",
          des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
        }
      ],
      couponList: [
        {
          id: 1,
          activityType: "coupon",
          activityName: "砍价",
          des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
        },
        {
          id: 2,
          activityType: "wheel",
          activityName: "集赞",
          des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
        }
      ],
      params: {
        pageNo: 1,
        pageSize: 10
      }
    };
  },
  mounted() {
    this.getActiveList(this.params);
  },
  methods: {
    handleWheelActiveMore() {
      this.wheelActive_limit += 3;
      if (this.wheelActive_limit === this.activeList.length - 3) {
        this.activeList_finished = true;
        return;
      }
    },
    // 获取 活动列表
    getActiveList(params) {
      API_Active.getActiveList(params).then(res => {
        console.log("获取到数据");
        this.activeList = res.data.list;
      });
    },
    // 跳转到 活动详情
    toDetail(active_id, type) {
      this.$router.push({
        path: "/activeDetail",
        query: {
          id: active_id,
          active_type: type
        }
      });
    }
  }
};
</script>

<style scoped>
.more {
  float: right;
  margin-bottom: 5px;
  font-size: 12px;
}
.container {
  height: auto;
  background-color: rgba(248, 248, 248, 1);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.title {
  height: 44px;
  background: rgba(248, 248, 248, 1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  font-size: 12px;
  color: rgba(45, 71, 106, 1);
}
.fg {
  padding: 0 16px;
  font-size: 12px;
  color: rgba(45, 71, 106, 1);
  height: 44px;
  line-height: 44px;
}
.icon {
  font-weight: 800;
}
.active {
  background-color: #fff;
  padding: 12px 12px 0 12px;
  box-shadow: 0px 2px 4px 0px rgba(221, 221, 221, 1);
}
.list {
  height: 94px;
  width: 100%;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(238, 238, 238, 1);
  margin-bottom: 14px;
}
.list3 {
  border-bottom: none;
  margin-bottom: 0;
}
.left,
.right {
  height: 80px;
}
.left {
  width: 80px;
  background: rgba(248, 248, 248, 1);
}
.right {
  width: 76%;
  padding-left: 10px;
  background-color: #fff;
}
h3 {
  font-size: 14px;
  font-weight: bold;
  color: rgba(45, 71, 106, 1);
}
p {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(45, 71, 106, 0.8);
}
</style>