<!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" rel="stylesheet" />
    <title>养了个毛孩</title>
  </head>

  <body>
    <div class="cla1">
      <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%"
        />
        <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%;;"/>
      </div>

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

      <div class="jz">
        <p
          style="
            color: rgb(0, 50, 175);
            font-weight: bold;
            margin-bottom: 0.7rem;
          "
        >
          防伪验证
        </p>
      </div>
      <div class="tips">
        <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>
      <img src="/static/images/136560/fw_14.png" />
    </div>
    <div class="cla2" 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();
          }
        });
      });
      wx.error(function (res) {
        tj_public.hideLoading();
        if (pkg === "3") {
          getInfo();
          $("#btn_close").hide();
        }
      });

      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 + " 次");
              $("#firstTime").text(res.tm_1st);
              //$("#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);
              }
              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();
      }
    </script>
  </body>
</html>
