index.vue 3.93 KB
<template>
  <div class="home">
    <head-view></head-view>

    <div class="sys-container-panel content">
      <div class="container-title">{{title}}</div>
      <div class="head-line"></div>

      <div class="prize-container">
        <div
          class="prize-item"
          v-for="(item,index) in prizeList"
          :key="index"
          :class="{'prize-coupon-bg':item.prizeType=='coupon','prize-normal-bg':item.prizeType!='coupon'}"
        >
          <div class="prize-name">{{item.prizeName}}</div>
          <div
            class="prize-btn"
            @click="viewDetailHandler(item)"
          >{{item.prizeType == 'real' ? '提交信息' : '查看详情'}}</div>
        </div>

        <div class="empty" v-if="init && prizeList.length == 0">
          <div class="empty-icon">
            <van-icon name="warn-o" />
          </div>
          <div class="empty-message">您还没有任何奖品 !</div>
        </div>
      </div>
    </div>

    <div class="bottom-line"></div>

    <bottom-tool v-model="activityIndex"></bottom-tool>
    <draw-model v-if="model.show" v-model="model" v-on:submitSuccess="model.show = false"></draw-model>
  </div>
</template>



<script>
let urls = {
  prizeList: "/jiajiaCHApi/app/prize/list"
};

import { httpGet } from "@/api/fetch-api";
import BottomTool from "@/components/bottom-tools/bottom-tools";
import DrawModel from "@/components/biz-model/draw-model";
import HeadView from "@/components/plugins/head";

import Vue from "vue";
import { Toast } from "vant";
import { Icon } from "vant";

Vue.use(Icon);
Vue.use(Toast);

export default {
  name: "home",
  data() {
    return {
      init: false,
      activityIndex: 4,
      title: "我的奖品",
      remainDrawTime: 0,
      model: {
        show: false,
        drawResult: {}
      },
      indexForm: {},
      prizeList: []
    };
  },
  methods: {
    initActivity() {
      Toast.loading({
        mask: true,
        message: "加载中..."
      });
      httpGet({ url: urls.prizeList, data: null }).then(res => {
        Toast.clear();
        this.init = true;
        this.prizeList = res;
      });
    },
    viewDetailHandler(item) {
      console.log(item);
      this.model.drawResult = item;
      this.model.show = true;
      // let type = item.prizeType;
      // switch (type) {
      //   case "real":
      //     this.model.drawResult = item;
      //     this.model.show = true;
      //     break;
      //   case "coupon":
      //     location.href = global_view_coupon_url;
      //     break;
      //   default:
      //     location.href = global_view_integral_url;
      //     break;
      // }
    }
  },
  components: {
    BottomTool,
    DrawModel,
    HeadView
  },
  mounted() {
    this.initActivity();
  }
};
</script>


<style lang="scss" scoped>
.content {
  margin: 85px auto 60px auto;
  padding-bottom: 60px;
  min-height: 500px;
}

.container-title {
  font-size: 30px;
}

.head-line {
  height: 60px;
}

.bottom-line {
  height: 150px;
  background-color: transparent;
}

.prize-container {
  width: 700;
  margin: auto;
}

.prize-item {
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 590px;
  height: 140px;
  border-radius: 15px;
  padding: 0 30px;
}

.prize-coupon-bg {
  background: url(../../assets/imgs/prize-item-coupon-bg.png);
  background-size: 100%;
}
.prize-normal-bg {
  background: url(../../assets/imgs/prize-item-normal-bg.png);
  background-size: 100%;
}

.prize-name {
  font-size: 24px;
  color: #fff;
  font-weight: bold;
  line-height: 140px;
  height: 140px;
}

.prize-btn {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  width: 140px;
  height: 40px;
  line-height: 40px;
  border-radius: 26px;
  background-color: #f6b843;
  position: relative;
  z-index: 1000;
}

.empty {
  padding-top: 100px;
  height: 300px;

  .empty-icon {
    font-size: 60px;
    color: #a1a1a1;
  }
  .empty-message {
    font-size: 24px;
    color: #a1a1a1;
  }
}
</style>