<!--
 * @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="package-wrap" @touchmove.prevent v-if="showAd">
      <img src="" />
    </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,
      showAd: false,
      showWrap: false,
      // todayDate: new Date().toLocaleDateString(),
      isTargetChannel: window.options.is_show_ad_frame,
      showIframe: false
    };
  },
  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();

    //this.$GoLoginPop().then(()=>{console.log('我真的的去绑定了呢')});
    //setTimeout(()=>{this.$GoLoginPop.close();},4000)
   
  },
  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: 9999;

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