<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
  <script src="/static/js/public/reset.js"></script>
  <link href="/static/css/public/reset.css" rel="stylesheet" />
  <link href="/static/css/public/public.css" rel="stylesheet" />
  <link href="/static/css/136560/main.css?v=2" rel="stylesheet" />
  <title>养了个毛孩</title>
</head>

<body>
  <div class="cla1" style="position: relative;min-height: 100%;">
    <div style="position: relative">
      <img src="/static/images/136560/fw_03.png" style="position: absolute; top: 5%; left: 5%; width: 30%" />
      <img src="/static/images/136560/fw_07.png" style="position: absolute; top: 28%; left: 5%; width: 60%"
        class="code3" />
      <img src="/static/images/136560/fw_11.png" style="position: absolute; top: 72%; left: 26%; width: 50%" />
      <!-- <img src="" style="position: absolute; top:28% ;left: 60%; width: 45%;"> -->
      <img src="/static/images/136560/BG-1.jpg" style="width: 100%" />
      <img id="fwimg" src="/static/images/136560/code.png"
        style="position:absolute;width: 5rem;right: 1.4rem;top: 26%;;" class="code3" />
      <div class="code2">
        <div class="c2top" id="yes">
          <div class="flex">
            <img src="/static/images/136560/yes.png" style="width: 2.5rem;">
            <div class="block">
              <p>您所查询的是正牌产品！</p>
              <p>尊敬的客户们您好！</p>
              <p>您所购买的是养了个毛孩的正牌产品！</p>
            </div>
          </div>
        </div>
        <div class="c2top" id="no">
          <div class="flex">
            <img src="/static/images/136560/no.png" style="width: 3rem;margin-left: .5rem;">
            <div class="block">
              <p>该防伪密码已被查询<span id="queryNum2">0</span>次，</p>
              <p>首次查询时间为<span id="firstTime2"></span>，</p>
              <p>最后一次查询时间<span id="lastTime">2023-11-08 17:29:29</span></p>
              <p>如非本人查询，</p>
              <p>请仔细核对谨防假冒！</p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="div1">
      <div class="div2">
        <div class="hr"></div>
        <div class="a"></div>
        <div class="hr"></div>
      </div>
    </div>

    <div class="jz code3">
      <p style="
            color: rgb(0, 50, 175);
            font-weight: bold;
            margin-bottom: 0.7rem;
          ">
        防伪验证
      </p>
    </div>
    <div class="tips code3">
      <div class="cx1">
        <p style="color: rgb(26, 26, 26)">
          输入您的标签防伪码查询信息是否官方认证
        </p>
      </div>
      <div class="cx2">
        <input id="input_yzm" type="text" placeholder="请输入6位防伪码" style="
              border-radius: 20px;
              border: 1px solid rgb(168, 168, 168);
              width: 100%;
              margin-bottom: 1.6rem;
              padding: 0.3rem 0.2rem;
              background-color: rgb(241, 241, 241);
              font-size: 18px;
              text-align: center;
            " />
      </div>
      <div class="cx3">
        <div class="btn" onclick="search()">查询</div>
      </div>
    </div>

    <div class="records code2">
      <div class="flex">
        <div class="subtitle">查询记录：</div>
        <div id="fold" style="margin-right: .5rem;">
          <span id="span" style="color:dodgerblue;">收起</span><span id="icon">></span>
        </div>
      </div>
      <div id="records">
      </div>
    </div>

    <img src="/static/images/136560/fw_14.png" class="footerimg" />
    <div class="footer"></div>
  </div>
  <div class="cla2 code3" id="cla2">
    <div class="div4" style="position: relative">
      <div class="div5">
        <img src="/static/images/136560/fw_03.png" style="width: 55%" />
      </div>
      <div class="hr1"></div>
      <div style="z-index: 1; position: relative">
        <div class="info">
          <p>企业名称：上海启想企业管理咨询服务有限公司</p>
          <p>产&emsp;&emsp;地：山东泰安</p>
          <p>产品系列：<span id="proname">全价烘焙猫粮（示意）</span></p>
          <p>渠道来源：<span id="comp">养了个毛孩官方旗舰店</span></p>
        </div>
        <div class="zz">
          <p><b>首查时间</b>：<b id="firstTime"></b></p>
          <p><b>查询次数</b>：<b id="queryNum">0 次</b></p>
        </div>
      </div>
      <div class="hr1"></div>
      <div class="gd" style="z-index: 1; position: relative" onclick="openReportList();">
        点击了解更多
        <img src="/static/images/136560/bt-dj.png" style="width: 20px" />
      </div>

      <img src="/static/images/136560/mh_03.jpg" style="
            position: absolute;
            top: 63.5%;
            left: 72.5%;
            width: 27%;
            z-index: 0;
          " />
    </div>
    <img src="/static/images/136560/close.png" style="width: 33px; margin-top: 1rem" id="btn_close"
      onclick="closeTck()" />
  </div>

  <div class="cla3" style="display: none">
    <div class="nav" onclick="closeReportList();">
      <img src="/static/images/public/fh.png" />
      <span>了解更多</span>
    </div>
    <div class="wrapper" id="reportList"></div>
  </div>

  <div class="cla4" style="display: none;" onclick="closeReportDetail();">
    <div class="wrapper">
      <div class="inner" id="reportDetail"></div>
    </div>
  </div>

  <script src="/static/js/jquery-2.1.0.min.js"></script>
  <script src="/static/js/public/public.js"></script>
  <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
  <script>
    tj_public.wxInit({
      wx_officail_account_id: 6,
      url: window.location.href,
    });
    tj_public.showLoading();

    var lat = 0;
    var lng = 0;
    var pkg = tj_public.getCookie("package");
    var fwcode = tj_public.getCookie("label_code");
    var uid = tj_public.getCookie("TJWXUSR_136560_0");

    wx.ready(function () {
      tj_public.getAddress(function (_lat, _lng) {
        tj_public.hideLoading();
        lat = _lat;
        lng = _lng;
        if (pkg === "3") {
          getInfo();
          $("#btn_close").hide();
        }
        if (fwcode.startsWith("1248")) {
          getInfo();
          $('.code3').hide()
          $('.code2').show()
        }
      });
    });
    wx.error(function (res) {
      tj_public.hideLoading();
      if (pkg === "3") {
        getInfo();
        $("#btn_close").hide();
      }
      if (fwcode.startsWith("1248")) {
        getInfo();
        $('.code3').hide()
        $('.code2').show()
      }
    });

    function getInfo() {
      tj_public.showLoading();
      $.ajax({
        url: "/wx/label/scan_record/",
        data: {
          lat,
          lng,
          uid,
          compid: 136560,
          fwcode,
        },
        success: function (res) {
          if (res.e === "") {
            tj_public.hideLoading();
            $("#spancpid").text(res.code);
            $("#queryNum").text(res.cnt + " 次");
            $("#queryNum2").text(res.cnt);
            var cnt = parseInt(res.cnt);
            if (cnt > 2) {
              $('#no').show()
            }
            else {
              $('#yes').show()
            }
            var myDate = new Date();
            if (res.tm_1st) {
              $("#firstTime").text(res.tm_1st);
              $("#firstTime2").text(res.tm_1st);
            }
            else {
              $("#firstTime").text(myDate.toLocaleString());
              $("#firstTime2").text(myDate.toLocaleString());
            }
            $("#lastTime").text(myDate.toLocaleString());
            //$("#fwimg").attr('src',res.img);
            //$("#fwimg").show();

            if (res.product_name) {
              $("#proname").text(res.product_name);
            }

            if (res.agent_name) {
              $("#comp").text(res.agent_name);
            }


            if (fwcode.startsWith("1248")) {
              getRecords();
            }
            else{
              document.getElementById("cla2").style.display = "flex";
            }
          } else {
            alert("网络超时！");
          }
        },
        error: function () {
          alert("网络超时！");
        },
      });
    }

    function closeTck() {
      document.getElementById("cla2").style.display = "none";
    }
    function search() {
      var o = document.getElementById("input_yzm").value.trim();
      if (o.length == 6) {
        tj_public.showLoading();
        tj_public.checkYzm(function () {
          getInfo();
        });
      } else {
        alert("请输入6位数防伪码");
      }
    }

    var allReports = [];
    var reports = {};
    getInspectionReport();
    function getInspectionReport() {
      $.ajax({
        url: "/company/wx/ajax/inspection_report/?company_id=136560",
        success: function (res) {
          if (res.e == "") {
            for (var r of res.data) {
              if (reports[r.month]) {
                reports[r.month].push(r)
              }
              else {
                reports[r.month] = [r]
              }
            }
            allReports = res.data;
            console.log(reports);
          }
          renderReportList();
        },
      });
    }

    function renderReportList() {
      var html = "";

      for (var r in reports) {
        var innerHtml = '';
        for (var item of reports[r]) {

          innerHtml += `
                <li onclick="openReportDetail(${item.id});">
                  <i></i>
                  <div>${item.title}</div>
                  <img class="icon" src="/static/images/public/jt.png"/>
                </li>
            `
        }

        html += `
          <div class="row">
              <div class="right">${item.month}</div>
              <ul>
                ${innerHtml}
              </ul>
          </div>
          `
      }
      $("#reportList").html(html);
    }

    function openReportList() {
      $('.cla3').fadeIn();
    }

    function closeReportList() {
      $('.cla3').fadeOut();
    }

    function openReportDetail(id) {
      var contents = '';
      for (var i = 0; i < allReports.length; i++) {
        if (allReports[i].id == id) {
          contents = allReports[i].contents;
          break;
        }
      }
      $("#reportDetail").html(decodeURIComponent(contents));
      $(".cla4").fadeIn();
    }
    function closeReportDetail() {
      $(".cla4").fadeOut();
    }



    function getRecords() {
      tj_public.showLoading();
      $.ajax({
        url: "/wx/ajax/label/scan_record/",
        data: {
          labelcode: fwcode,
        },
        success: function (result) {
          tj_public.hideLoading();
          if (result.e === "") {
            var recordHtml = ''
            for (var record of result.records) {
              recordHtml += `
                <div class="item">
                    <img class="avator" src="/static/images/136560/avatar.png" />
                    <div class="ip">${record.wx}</div>
                    <div class="tm">${record.tm}</div>
                </div>
                `
            }
            $("#records").html(recordHtml);
            if (recordHtml == '') {
              $("#fold").hide();
            }
          } else {
            alert('网络超时')
          }
        }, error: function () {
          $("#loading").hide();
          alert('网络超时')
        }
      })
    }

    $('#fold').on('click', function () {
      if ($("#span").text() == '收起') {
        $("#span").text('展开');
        $("#records").hide();
        $("#icon").css('transform', 'rotate(0)');
      } else {
        $("#span").text('收起');
        $("#records").show();
        $("#icon").css('transform', 'rotate(90deg)');
      }
    });


  </script>
</body>

</html>