<!--
 * @Author: your name
 * @Date: 2020-09-08 10:49:07
 * @LastEditTime: 2021-06-29 11:45:03
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \ydy_wap_front\src\App.vue
-->
<template>
  <div id="app" :class="theme">
    <router-view :key="$route.fullpath" />
    <div class="package-wrap" @touchmove.prevent v-if="showWrap">
      <img @click.stop="closeWrap" :src="imgs" alt="" />
    </div>

    <div class="fans-mask" v-if="fansUrl">
      <div class="fans-box">
        <!-- <i class="close"></i> -->
        <img  class="qrcode" alt="迁移新二维码" :src="fansUrl"/>
        <p class="fans-tips">当前公众号已迁移</p>
        <p class="fans-des">长按二维码扫描关注新公众号继续阅读</p>
      </div>
    </div>
    <!-- <template v-if="isTargetChannel&&showIframe">
      <iframe src='//wap.apyingcaisw.com/xingzuo'
              width='1px'
              height='1px'
              style="visibility:hidden"></iframe>
    </template> -->
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      theme: localStorage.getItem("theme") || "girl",
      showRed: window.options.fission,
      activity_imgs: window.options.channel_activities,
      redImage: require("./assets/red_package.png"),
      imgs: null,
      showWrap: false,
      // todayDate: new Date().toLocaleDateString(),
      isTargetChannel: window.options.is_show_ad_frame,
      showIframe: false,
      fansUrl: window.options.channel_fans_guide_qrcode  //站点迁移新的公众号二维码
    };
  },
  watch: {
    $route(v) {
      if (v.name === "BookCity") {
        v.query.sex && (this.theme = v.query.sex);
      }
    }
  },
  created() {
    let { site_gender } = window.options;
    if (site_gender) {
      // 关注用户 根据用户性别 首页展示不同的频道
      this.theme = site_gender === "male" ? "boy" : "girl";
    } else this.theme = "girl";
    this.initWrap();
  },
  methods: {
    closeWrap() {
      if (window.options.fission) {
        this.showWrap = false;
        window.options.fission = 0;
        setTimeout(() => {
          this.initWrap();
        }, 500);
      } else {
        this.showWrap = false;
        window.options.channel_activities.shall_reward = 0;
      }
    },
    initWrap() {
      if (window.options.fission) {
        // 红包弹窗弹出
        this.showWrap = true;
        this.imgs = this.redImage;
      } else {
        if (window.options.channel_activities.shall_reward) {
          // 活动弹
          this.showWrap = true;
          this.imgs = this.activity_imgs.image;
        }
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.package-wrap {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba($color: #000000, $alpha: 0.6);
  z-index: 999;

  img {
    position: absolute;
    width: 80%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}

.fans-mask {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba($color: #000000, $alpha: 0.6);
  z-index: 1000;
  .fans-box {
    width: 6rem;
    height: 6.3rem;
    box-sizing: border-box;
    padding: 0.3rem;
    background: #fff;
    position: absolute;
    margin: auto;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    .qrcode{
      width: 4rem;
      height:4rem;
      margin: .2rem auto 0;
      display: block;
    }
    .close {
      display: inline-block;
      width: 0.5rem;
      height: 0.5rem;
      position: absolute;
      top: 0.2rem;
      right: 0.2rem;
      background: url("../src/assets/closed.png") no-repeat;
      background-size: cover;
    }
    .fans-tips {
      font-size: 0.34rem;
      font-weight: bold;
      text-align: center;
      margin-top: 0.2rem;
    }
    .fans-des {
      font-size: .3rem;
      color: #666;
      margin-top: .2rem;
    }
  }
}
</style>
