index.vue 3.74 KB
Newer Older
Z's avatar
Z committed
1
<template>
leiqingsong's avatar
leiqingsong committed
2 3
  <div class="lists">
    <div v-for="(item, index) of active" :key="index">
4 5 6 7 8 9 10 11 12
      <van-swipe-cell>
        <div class="list" @click="listClick(index, item)">
          <div class="list-logos">
            <img class="list-logo" :src="item.logo" />
          </div>
          <div class="list-infos">
            <div class="list-title">{{item.templateName}}</div>
            <div class="list-dsc">{{item.des}}</div>
          </div>
Z's avatar
Z committed
13
        </div>
14 15 16 17
        <template #right v-if="index > 1">
          <van-button square type="danger" text="删除" @click="deleteTemplate(item.id, index)" />
        </template>
      </van-swipe-cell>
Z's avatar
Z committed
18
    </div>
leiqingsong's avatar
leiqingsong committed
19 20 21 22 23
    <span class="more" v-if="active.length && !list_finished" @click="handleMore">
      查看更多
      <span class="icon">></span>
    </span>
  </div>
Z's avatar
Z committed
24 25 26
</template>

<script>
leiqingsong's avatar
leiqingsong committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
// ZKit
// const log = console.log.bind(console)
import * as API_Active from "@/api/active";
export default {
  name: "discountIndex",
  data() {
    return {
      list_finished: false,
      active: [
        {
          templateName: "大转盘活动",
          activityType: "wheel",
          logo: "/mainSale/icon-active-1.png",
          des: "有各种物质组成的举行球状天体,叫做星球。星球有一定的形状。",
          reDirect: "turntableDetail"
Z's avatar
Z committed
42
        },
leiqingsong's avatar
leiqingsong committed
43 44 45 46 47 48
        {
          templateName: "送券活动",
          activityType: "coupon",
          logo: "/mainSale/icon-active-2.png",
          des: "有各种物质组成的举行球状天体,叫做星球。星球有一定的形状。",
          reDirect: "couponDetail"
Z's avatar
Z committed
49
        }
leiqingsong's avatar
leiqingsong committed
50 51 52 53 54
      ],
      params: {
        pageNo: 1,
        pageSize: 10
      }
Z's avatar
Z committed
55
    };
leiqingsong's avatar
leiqingsong committed
56 57 58 59 60
  },
  created() {
    this.getTemplate(this.params);
  },
  methods: {
61
    deleteTemplate(tem_id, index) {
leiqingsong's avatar
leiqingsong committed
62
      API_Active.deleteTemplate(tem_id).then(res=>{
63 64 65 66 67 68
        if(res.result === 'success') {
          this.active.splice(index, 1);
          this.$toast('删除成功!');
        }
      })
    },
leiqingsong's avatar
leiqingsong committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    handleMore() {
      this.params.pageNo += 1;
      this.getTemplate(this.params);
    },
    // 获取模板
    getTemplate(params) {
      API_Active.getTemplate(params).then(res => {
        this.active.push(...res.data.list);
        if (res.data.list === []) {
          this.list_finished = true;
        }
      });
    },
    listClick(inIndex, item) {
      // log('--->click: inIndex =', inIndex)
      // log('--->click: reDirect =', this.list.active[inIndex].reDirect)
      if (inIndex < 2) {
        this.$router.push(this.active[inIndex].reDirect);
      } else {
        this.$router.push({
          path: `/createBigWheelActive`,
          query: {
            activityId: item.activityId,
            activityType: item.activityType,
            templateId: item.id
          }
        });
      }
    }
  }
};
Z's avatar
Z committed
100 101 102
</script>

<style scoped>
leiqingsong's avatar
leiqingsong committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
.more {
  font-size: 12px;
  float: right;
}

.lists {
  padding: 4px 16px 20px 16px;
}

.list {
  padding: 12px 0px;
  display: flex;
  flex-direction: row;
  justify-content: start;
  align-items: center;
  border-bottom: 1px solid #eeeeee;
}

.list-logos {
  width: 80px;
  height: 80px;
  background-color: #f8f8f8;

  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}

.list-logo {
  width: 56px;
  height: 56px;
}

.list-infos {
  width: 251px;
  height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: start;

  margin-left: 12px;
}

.list-title {
  font-size: 14px;
  height: 16px;
  line-height: 16px;
  font-weight: bold;
  color: #2d476a;
  width: 100%;
  text-align: left;

  margin-bottom: 8px;
}

.list-dsc {
  font-size: 12px;
  height: 14px;
  line-height: 14px;
  font-weight: normal;
  color: #2d476a;
  width: 100%;
  text-align: left;
  overflow: auto;
}
Z's avatar
Z committed
170
</style>