WorksListView.vue 6.06 KB
<template>
  <div class="viewClass">
    <div class="btn-show-rule" @click="showRuleHandler"></div>
    <div v-if="formData.worksCode">
      <div class="sys-container-panel content top-marin">
        <div class="container-title">人气评选</div>
        <div class="head-line"></div>

        <div class="self-container">
          <div class="leap"></div>
          <div class="self-content">
            <div class="swipe">
              <van-swipe :autoplay="5000">
                <van-swipe-item v-for="(works, index) in formData.worksList" :key="index">
                  <div class="img" v-bind:style="{backgroundImage:'url(' + works.worksUrl + ')'}"></div>
                </van-swipe-item>
              </van-swipe>
            </div>

            <div class="text-container space">
              <div class="text-container inline">
                <div class="label">我的编号:</div>
                <div class="msg">{{formData.worksNo}}</div>
              </div>

              <div class="text-container inline">
                <div class="label">我的人气:</div>
                <div class="msg">{{formData.praiseNumber}}</div>
              </div>

              <div class="text-container inline">
                <div class="label">我的排名:</div>
                <div class="msg">{{indexForm.rank}}</div>
              </div>

              <div class="text-container inline top" @click="praiseHandler">
                <div class="no-praise" :class="{praise : indexForm.isPraiseToday == '1'}"></div>
                <div class="msg primay">{{indexForm.isPraiseToday == '1' ? '今日已投' : '今日未投'}}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="chain-div"></div>
    </div>
    <div
      class="sys-container-panel content list-panel"
      v-bind:class="{'top-marin' : !formData.worksCode}"
    >
      <div class="container-title" v-if="!formData.worksCode">人气评选</div>
      <div class="head-line" v-if="!formData.worksCode"></div>
      <list-view v-on:worksDetail="showWorksDetail"></list-view>

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

<script>
let urls = {
  praise: "/jiajiaCHApi/app/works/praise",
  index: "/jiajiaCHApi/app/index"
};

import ListView from "./ListView";
import { request, httpGet } from "@/api/fetch-api";

import Vue from "vue";
import { Toast } from "vant";
import { Swipe, SwipeItem } from "vant";

Vue.use(Swipe).use(SwipeItem);
Vue.use(Toast);

export default {
  props: ["value"],
  data() {
    return {
      init: false,
      formData: this.value,
      indexForm: {
        rank: 0,
        isPraiseToday: 0,
        worksCode: "",
        isSubcribe: 0
      }
    };
  },
  methods: {
    initActvity() {
      httpGet({ url: urls.index, data: {} }).then(res => {
        this.indexForm = res;
        // this.indexForm.worksCode = "";
      });
    },
    praiseHandler(code) {
      if (!this.init) {
        return;
      }
      if (this.indexForm.isPraiseToday == 1) {
        return;
      }

      let data = {
        worksCode:
          (typeof code).toLowerCase() == "string"
            ? code
            : this.indexForm.worksCode
      };
      Toast.loading({
        mask: true,
        message: "数据提交..."
      });
      request
        .post(urls.praise, data)
        .then(res => {
          Toast.clear();
          this.indexForm.isPraiseToday = 1;
          this.emitPraiseSuccess();
        })
        .catch(res => {
          let msg = res.data.errMsg;
          Toast(msg);
        });
    },
    emitPraiseSuccess() {
      this.$emit("praiseSuccess");
    },
    showRuleHandler() {
      this.$emit("showRule");
    },
    showWorksDetail(params) {
      this.$emit("worksDetail", params);
    }
  },
  created() {
    this.initActvity();
  },
  components: {
    ListView
  }
};
</script>

<style lang="scss" scoped>
.viewClass {
  position: relative;

  .chain-div {
    width: 315px;
    height: 50px;
    background: url(../../../assets/imgs/list-chain-link.png);
    background-size: 100%;
    position: absolute;
    left: 217px;
    top: 360px;
    z-index: 800;
  }
}

.top-marin {
  margin: 85px auto 15px auto !important;
}
.content {
  padding-bottom: 30px;

  .head-line {
    height: 80px;
  }
}

.self-container {
  width: 630px;
  height: 265px;
  border-radius: 20px;
  background-color: #71c634;
  margin: 0px auto 0 auto;
  position: relative;
  padding-top: 5px;

  .self-content {
    display: flex;
  }

  .leap {
    width: 149px;
    height: 129px;
    background: url(../../../assets/imgs/leap-04.png);
    background-size: 100%;
    position: absolute;
    right: -5px;
    bottom: 0px;
  }

  .swipe {
    width: 265px;
    height: 200px;
    border: 2px solid #45a402;
    border-radius: 20px;
    margin: 32px;
    overflow: hidden;

    div {
      line-height: 200px;
      height: 200px;
      text-align: center;
      width: 265px;
    }
    .img {
      margin: auto;
      //   width: 235px;
      height: 190px;
      width: 265px;
      background-size: cover;
    }
  }

  .space {
    margin-top: 32px;
  }

  .top {
    margin-top: 18px !important;
  }

  .inline {
    display: flex;
    margin-bottom: 10px;
    align-items: center;

    .label {
      color: #fff;
      font-weight: 400;
      font-size: 30px;
    }
    .msg {
      color: #0e6f4e;
      font-weight: bold;
      font-size: 30px;
    }

    .primay {
      font-weight: 500;
      font-size: 24px;
    }

    .no-praise {
      margin-right: 10px;
      width: 34px;
      height: 30px;
      background: url(../../../assets/imgs/list-no-praise.png) no-repeat;
      background-size: 100%;
    }

    .praise {
      width: 34px;
      height: 30px;
      background: url(../../../assets/imgs/list-praised.png) no-repeat !important;
      background-size: 100% !important;
    }
  }
}

.list-panel {
  min-height: 600px;
}

.bottom-line {
  height: 10px;
}

.btn-show-rule {
  width: 170px;
  height: 52px;
  background: url(../../../assets/imgs/list-btn-rule.png);
  background-size: 100%;
  position: fixed;
  left: 0;
  top: 30px;
  z-index: 1000;
}
</style>