<!--
 * @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">
      <!-- <div class="close-btn" @click="showAd = false">关闭</div> -->
      <img
        src="https://cdn-novel.iycdm.com/zsy_ios_app/user_privacy/20220221155858.png"
        width="100%"
        class="mask-img"
      />
    </div>

    <!-- <template v-if="isTargetChannel&&showIframe">
      <iframe src='//wap.apyingcaisw.com/xingzuo'
              width='1px'
              height='1px'
              style="visibility:hidden"></iframe>
    </template> -->
  </div>
</template>

<script>
import goLogin from "../src/components/gologin";
export default {
  name: "app",
  data() {
    return {
      theme: localStorage.getItem("theme") || "girl",
      showRed: window.options.fission,
      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();

    //sessionSotrage判断展示加桌提醒图
    const showBanner = sessionStorage.getItem("showBanner");
    //获取是否加桌过
    const { is_add_desk } = window.options;
    if (!showBanner && !is_add_desk && !window.navigator.standalone) {
      this.showAd = true;
      sessionStorage.setItem("showBanner", true);
    }
  },
  methods: {
    closeWrap() {
      if (window.options.fission) {
        this.showWrap = false;
        window.options.fission = 0;
        setTimeout(() => {
          this.initWrap();
        }, 500);
      } else {
        this.showWrap = false;
      }
    },
    initWrap() {
      if (window.options.fission) {
        // 红包弹窗弹出
        this.showWrap = true;
        this.imgs = this.redImage;
      }
    }
  }
};
</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;
  .mask-img {
    width: 100%;
    z-index: 100;
  }
  .close-btn {
    width: 1.2rem;
    height: 0.5rem;
    line-height: 0.5rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.6);
    color: #fff;
    font-size: 0.28rem;
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    z-index: 101;
    border-radius: 0.4rem;
  }
  img {
    position: absolute;
    width: 80%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}
</style>
