<template>
  <div class="templatePush" id="temp" :style="{ 'backgroundColor': pageData.mainJson.pageBgcol }">
    <div class="bannerBox">
      <img class="banner" :src="imgUrl + pageData.mainJson.bannerImg" alt="">
    </div>
    <!-- 统一认证组件 -->
    <tong-ren @btnClick='openIframe' :pageData="pageData" @phoneNum="phoneFuction">
    </tong-ren>
    <div class="memberBtnC" @click="toMemUrl()">
      如已订购，请领取会员
    </div>

    <div class="contentBox" v-if="pageData.mainJson.explainImg"
      :style="{ 'backgroundColor': pageData.mainJson.orderBgcol, 'color': pageData.mainJson.pageTextcol }">
      <div class="roundBox long">
        <div class="mini" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="small" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="model" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="text"
          :style="{ 'backgroundColor': pageData.mainJson.orderBdcol, 'color': pageData.mainJson.orderBgcol }">
          {{ pageData.mainProduct.memberName }}</div>
        <div class="model" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="small" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="mini" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
      </div>
      <div class="guidancePic">
        <img :src="imgUrl + pageData.mainJson.explainImg" style="width: 100%;height:100%" />
      </div>
    </div>
    <div class="contentBox" v-if="pageData.mainProduct.givePhoneInfo"
      :style="{ 'backgroundColor': pageData.mainJson.orderBgcol, 'color': pageData.mainJson.pageTextcol }">
      <div class="roundBox">
        <div class="mini" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="small" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="model" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="text"
          :style="{ 'backgroundColor': pageData.mainJson.orderBdcol, 'color': pageData.mainJson.orderBgcol }">
          产品说明</div>
        <div class="model" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="small" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
        <div class="mini" :style="{ 'backgroundColor': pageData.mainJson.orderBdcol }">
        </div>
      </div>
      <div class="main" v-html="pageData.mainProduct.givePhoneInfo">
      </div>
    </div>
    <div class="tabBtn"
      :style="{ 'backgroundColor': pageData.mainJson.orderBgcol, 'color': pageData.mainJson.pageTextcol }">
      <div class="tabBox" v-for="(item, index) in tabArr" :key="index" @click="tabClick(item)">
        <div class="img">
          <img :src="item.icon" alt="" />
        </div>
        <div>{{ item.tabName }}</div>
      </div>
    </div>
    <!-- 登录弹框组件 -->
    <login-modal v-model="showLogin" :type="type" :text="text" @getIsBuy="getIsBuy"></login-modal>
    <!-- 订购超时 -->
    <timeout-modal v-model="showTimeout"></timeout-modal>
    <!-- 退订弹框组件 -->
    <unbuy-modal v-model="showUnbuy" :pageData="pageData" @childData="getChildData"></unbuy-modal>
    <!-- 遮罩 -->
    <newZheZhao v-if="showZhezhao" isZheZhao="1" :indexNum="indexNum"></newZheZhao>
    <!-- 订购成功提示  -->
    <handel-modal v-model="handelShow" @jihuo="jihuoChange"></handel-modal>
    <!-- 退出挽留 -->
    <exit-modal v-model="exitShow" />
    <!-- 会员弹框 -->
    <member-modal v-model="memberShow" />
    <!-- 会员二维码弹框 -->
    <member-code v-model="memberCode" />
  </div>
</template>
<script>
import common from "../../common/common";
import timeoutModal from "../../components/timeoutModal.vue";
import unbuyModal from "../../components/unbuyModal.vue";
import newZheZhao from "../../components/newZheZhao.vue";
import loginModal from "../../components/login.vue";
import tongRen from "./components/tongRen.vue";
import addR from "../../common/addRecord";
import wx from "weixin-js-sdk";
import handelModal from "../../componentsNew/handelModal.vue";
export default {
  mixins: [common],
  components: {
    timeoutModal,
    tongRen,
    unbuyModal,
    newZheZhao,
    loginModal,
    handelModal
  },
  data () {
    return {
      imgUrl: process.env.VUE_APP_IMGS_URL,
      showTimeout: false,
      showUnbuy: false,
      showLogin: false,
      unBuyDrainage: false,
      handelShow: false,
      isApplet: false,
      unBuyDrainageText: "",
      phone: "",
      isBuy: "未订购",
      tabArr: [],
      type: "",
      text: "",
      thisMemUrl: "https://cplus.mige.tv/receive-product/"
    }
  },
  created () {
    document.title = this.pageData.mainProduct.productName;
    // if (this.$route.query.phone) {
    //   this.phone = this.$route.query.phone
    // }
    if (this.pageData.remarks.tabArr && this.pageData.remarks.tabArr.length > 0) {
      this.tabArr = this.pageData.remarks.tabArr
      let arr = []
      this.tabArr.forEach(val => {
        if (val.tabName == '会员领取') {
          let obj = {}
          obj.tabName = val.tabName
          obj.tabUrlBasics = val.tabUrlBasics
          obj.tabUrlApplet = val.tabUrlApplet
          obj.icon = require("./components/img/huiyuan.png")
          arr.push(obj)
          this.thisMemUrl = val.tabUrlBasics
        }
        if (val.tabName == '流量激活') {
          let obj = {}
          obj.tabName = val.tabName
          obj.tabUrlBasics = val.tabUrlBasics
          obj.tabUrlApplet = val.tabUrlApplet
          obj.icon = require("./components/img/liuliang.png")
          arr.push(obj)
        }
        if (val.tabName == '退订产品') {
          let obj = {}
          obj.tabName = val.tabName
          obj.tabUrlBasics = val.tabUrlBasics
          obj.tabUrlApplet = val.tabUrlApplet
          obj.icon = require("./components/img/tuiding.png")
          arr.push(obj)
        }
      })
      this.tabArr = arr
    } else {
      if (this.pageData.remarks.memberBtn == '1') {
        let obj = {}
        obj.tabUrlBasics = ""
        obj.tabUrlApplet = ""
        obj.icon = require("./components/img/huiyuan.png")
        obj.tabName = '会员领取'
        this.tabArr.push(obj)
      }
      if (this.pageData.remarks.memberBtn == '1') {
        let obj = {}
        obj.tabUrlBasics = ""
        obj.tabUrlApplet = ""
        obj.icon = require("./components/img/liuliang.png")
        obj.tabName = '流量激活'
        this.tabArr.push(obj)
      }
      if (this.pageData.remarks.tuidingBtn == '1') {
        let obj = {}
        obj.tabUrlBasics = ""
        obj.tabUrlApplet = ""
        obj.icon = require("./components/img/tuiding.png")
        obj.tabName = '退订产品'
        this.tabArr.push(obj)
      }
    }
    //
    // setTimeout(()=>{
    //     this.isBuy = '已订购';
    // },1000)
  },
  mounted () {
    addR.showSP();
    wx.miniProgram.getEnv(res => {
      this.isApplet = res.miniprogram
    })
  },
  methods: {
    phoneFuction (e) {
      this.phone = e
    },
    getChildData (data) {
      this.isBuy = data;
    },
    toMemUrl () {
      console.log(this.thisMemUrl)
      location.href = this.thisMemUrl
    },
    async beforeLogin (type) {
      this.type = type;
      if (this.user.userid) {
        if (type === "member") {
          this.toLink(type);
        } else if (type === "unBUy") {
          addR.unBuyClick();
          this.showUnbuy = true;
        }
      } else if (type === "unBUy") {
        addR.unBuyClick();
        this.showUnbuy = true;
      } else {
        addR.loginClick();
        this.showLogin = true;
      }
    },
  }
}
</script>
<style lang='scss'>
.templatePush {
  // background-color: #042B85;
  color: #0d0d0d;
  min-height: 100vh;
  font-family: PingFang SC;
  width: 100vw;
  overflow-x: hidden;

  @keyframes scale {
    from {
      transform: scale(1);
    }

    to {
      transform: scale(0.8);
    }
  }

  .memberBtnC {
    width: 396px;
    height: 66px;
    background: linear-gradient(0deg, #fbd75b 0%, #fbf3d4 100%);
    border-radius: 33px;
    font-size: 34px;
    font-family: PingFang SC;
    font-weight: 800;
    color: rgba(250, 102, 32, 1);
    line-height: 66px;
    text-align: center;
    margin: 30px auto 40px auto;
  }

  .iframe {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 9999;
  }

  .bannerBox {
    width: 100%;
    height: auto;

    .banner {
      width: 100%;
      height: 100%;
    }
  }

  .inputBox {
    width: 603px;
    height: 91px;
    background: #ffffff;
    border-radius: 46px;
    margin: 18px auto 0 auto;
    box-sizing: border-box;
    padding-left: 44px;
    padding-right: 44px;

    .input {
      width: 100%;
      margin: 0;
      padding: 0;
      border: none;
      outline: none;
      height: 100%;
      font-size: 33px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #000000;
      opacity: 0.7;
      line-height: 79px;
    }

    .input::placeholder {
      color: #b0acac;
      font-weight: 500;
    }
  }

  .btnBox {
    width: 603px;
    height: 96px;
    margin: 30px auto 40px auto;
    border-radius: 35px;
    animation-name: scale;
    animation-duration: 0.3s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-direction: alternate-reverse;

    .btnText {
      width: 100%;
      height: 100%;
      border-radius: 48px;
      text-align: center;
      line-height: 96px;
      font-size: 50px;
      font-family: HYQiHei;
      font-weight: bold;
    }
  }

  .contentBox {
    width: 640px;
    border-radius: 20px;
    margin: 0 auto;
    // margin-bottom: 68px;
    margin-top: 40px;
    padding: 59px 35px;
    box-sizing: border-box;

    .roundBox {
      min-width: 400px;
      margin: 0 auto;
      display: flex;
      justify-content: center;
      align-items: center;
      line-height: 79px;
      height: 79px;

      .mini {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        margin: 0 5px;
      }

      .small {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        margin: 0 5px;
      }

      .model {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        margin: 0 5px;
      }

      .text {
        min-width: 200px;
        height: 68px;
        text-align: center;
        font-size: 34px;
        font-family: HYQiHei;
        font-weight: bold;
        line-height: 68px;
        border-radius: 39px;
        margin: 0 15px;
        padding: 0 30px;
      }
    }

    .main {
      height: 655px;
      overflow-y: scroll;
      font-size: 22px;
      font-family: HYQiHei;
      font-weight: normal;
      line-height: 33px;
      margin-top: 36px;
    }

    .guidancePic {
      margin-top: 50px;
    }
  }

  .timeout-modal {
    padding: 60px 40px;
    font-size: 28px;
    line-height: 50px;
    text-align: center;
    color: #222222;

    .btn {
      width: 160px;
      line-height: 60px;
      margin: 50px auto 0;
      border-radius: 8px;
      background-color: #1876bc;
      color: #fff;
    }
  }

  .modal {
    box-sizing: border-box;
    position: absolute;
    left: 50%;
    top: 333px;
    transform: translateX(-50%);
    width: 530px;
    background-color: #fff;
    border-radius: 8px;

    .close {
      width: 80px;
      height: 80px;
      position: absolute;
      bottom: -130px;
      left: 50%;
      transform: translateX(-50%);
    }

    .top {
      width: 100%;
      height: 96px;
    }

    .logo {
      width: 92px;
      height: 50px;
      position: absolute;
      top: 22px;
      left: 37px;
    }
  }

  .tabBtn {
    width: 640px;
    height: 138px;
    margin: 40px auto;
    margin-bottom: 80px;
    border-radius: 20px;
    padding: 22px 54px;
    box-sizing: border-box;
    // padding: 40px;
    display: flex;
    justify-content: space-between;

    .tabBox {
      font-size: 26px;
      text-align: center;

      .img {
        // padding: 0 50px;

        img {
          width: 50px;
          height: 50px;
        }
      }
    }
  }
}</style>
