<template>
  <view class="examact">
    <view class="examact-tname">{{ tenantInfo.name }}</view>
    <img
      :src="$method.splitImgHost('oss/images/file/20230320/1679298401443.png')"
      alt=""
      srcset=""
    />
    <view class="examact-btn" @click="collectMerch"> 点击领取真题题库 </view>

    <view class="examact-phone" v-if="tenantInfo.phone">
      报名热线：
      <view>{{ tenantInfo.phone1 }}</view>
      <view>{{ tenantInfo.phone2 }}</view>
    </view>
    <view class="examact-qrcode">
      <tki-qrcode
        :show="true"
        :size="160"
        cid="qrcode1"
        ref="qrcode"
        :val="val"
        :showLoading="false"
        :loadMake="true"
        :usingComponents="true"
      />

      <img
        class="examact-qrcode111"
        :src="'../../static/qrcode/' + tenantInfo.qrcodeUrl"
        alt=""
        srcset=""
      />
    </view>
  </view>
</template>

<script>
const map = {
  "test.jqbao.net": {
    name: "测试云学堂",
    qrcodeUrl: "hnjsxt_act.png",
    goodsId: "7722",
  },
  "120.79.166.78:19006": {
    name: "广东省祥粤建设职业培训学校",
    qrcodeUrl: "h_act.png",
    phone: true,
    phone1: "020-87085982",
    phone2: "020-87085983",
    goodsId: "16370",
    scheme: "http://",
  },
  "h.xyyxt.net": {
    name: "广东省祥粤建设职业培训学校",
    qrcodeUrl: "h_act.png",
    phone: true,
    phone1: "020-87085982",
    phone2: "020-87085983",
    goodsId: "7798",
  },
  "www.hnjsxt.cn": {
    name: "企帮（广州）工程建设咨询服务有限公司",
    qrcodeUrl: "hnjsxt_act.png",
    scheme: "http://",
    learnUrl: "",
    goodsId: "8673",
  },
  "zsh5.zzyxt.net": {
    name: "中山市勘设工程咨询有限公司",
    qrcodeUrl: "zsh5_act.png",
    goodsId: "8678",
  },
  "zh5.zzyxt.net": {
    name: "肇庆市建筑业协会",
    qrcodeUrl: "zh5_act.png",
    goodsId: "8677",
    phone: true,
    phone1: "0758—2285500",
    phone2: "13600220253",
  },
  "sdyxt.gdzzkj.net": {
    name: "佛山市顺德区市政建设工程协会",
    qrcodeUrl: "sdyxt_act.png",
    goodsId: "8673",
  },
  "mh5.zzyxt.net": {
    name: "茂名市建设培训学校",
    qrcodeUrl: "mh5_act.png",
    goodsId: "8679",
  },
  "sxh5.zzyxt.net": {
    name: "山西晋锦建族教育咨询有限公司",
    qrcodeUrl: "sxh5_act.png",
    goodsId: "8676",
  },
  "yfh5.zzyxt.net": {
    name: "云浮市建筑业协会",
    qrcodeUrl: "yf_act.png",
    goodsId: "8672",
  },
  "h.kw-xy.com": {
    name: "深圳市凯文云学堂",
    qrcodeUrl: "kw-xy.png",
    goodsId: "8680",
  },
};
import { actCheck } from "../../common/httpList/act";
import tkiQrcode from "tki-qrcode";
import { tenantId, BASE_URL } from "@/common/request.js";
export default {
  name: "SaasMiniprogramExamact",
  data() {
    return {
      goodsId: "",
      goodsType: "2",
      example:
        "http://localhost:8080/pages5/scan/examact?jump=www.hnjsxt.cn/detail/6",
      jump: undefined,
      sale: "",
      tenantInfo: {},
      t: "",
    };
  },
  onLoad(option) {
    this.jump = option.jump;
    this.sale = option.sale;
    this.tenantInfo = this.backInfo();
    this.goodsId = this.tenantInfo.goodsId;
    this.t = option.t;
    this.t && this.statistics();
  },
  methods: {
    collectMerch() {
      actCheck().then((res) => {
        if (res.data.code === 200) {
          //跳转去对应域名
          this.toDatail();
        } else {
          this.$u.toast(res.data.msg);
        }
      });
    },
    toDatail() {
      if (this.jump) {
        window.location.href =
          this.scheme + this.jump + "?sale=" + (this.sale || "");
        return;
      }
      uni.navigateTo({
        url:
          "/pages3/course/detail?id=" +
          this.goodsId +
          "&goodsType=" +
          this.goodsType +
          "&sale=" +
          (this.sale || "") +
          "&isAct=" +
          1,
      });
    },
    backInfo() {
      let domain = this.jump ? this.jump.split("/")[0] : window.location.host;
      domain = this.$method.checkDomain(domain)
        ? domain
        : "120.79.166.78:19006";
      return map[domain];
    },
    statistics() {
      uni.request({
        url: BASE_URL + "/app/common/save/activity/record/" + this.t,
        method: "get",
        header: {
          TenantId: tenantId,
        },
        success: (res) => {},
        fail: (err) => {},
      });
    },
  },
  components: {
    tkiQrcode,
  },
  computed: {
    scheme() {
      return this.tenantInfo.scheme || "https://";
    },
    val() {
      return (
        this.scheme +
        (this.jump ||
          window.location.host + "/pages/questionBank/index?isAct=1")
      );
    },
  },
};
</script>

<style lang="scss" scoped>
.examact {
  position: relative;
  img {
    width: 100vw;
  }
  .examact-tname {
    position: absolute;
    top: 41rpx;
    left: 48rpx;
    font-size: 36rpx;
    color: #2e3174;
    font-weight: 500;
  }
  .examact-btn {
    width: 620rpx;
    height: 102rpx;
    position: absolute;
    top: 786rpx;
    left: 50%;
    margin-left: -310rpx;
    background: linear-gradient(90deg, #1762ff 0%, #4af7da 100%);
    box-shadow: 0px 9px 12px 0px rgba(50, 84, 130, 0.18);
    border-radius: 200rpx;
    line-height: 104rpx;
    text-align: center;
    font-weight: bold;
    color: #ffffff;
    font-size: 36rpx;
  }
  .examact-qrcode {
    width: 396rpx;
    display: flex;
    position: absolute;
    justify-content: space-between;
    right: 32rpx;
    bottom: 122rpx;
    img {
      width: 180rpx;
      height: 180rpx;
    }
    view {
      background: #ffffff;
      width: 180rpx;
      height: 180rpx;
      padding: 10rpx;
    }
  }
  .examact-phone {
    position: absolute;
    bottom: 46rpx;
    left: 33rpx;
    color: #222222;
    font-size: 30rpx;
    line-height: 40rpx;
  }
}
</style>
