<!DOCTYPE html>
<html>

<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 rel="stylesheet" href="https://res.wx.qq.com/t/wx_fed/weui-source/res/2.5.4/weui.min.css" />
  <link href="/static/css/134666/main.css" rel="stylesheet" />
  <title>川酒集团</title>
</head>

<body>
  <div class="page__bd">
    <div class="weui-tab">
      <div class="weui-tab__panel" id="p2">
        <div class="home page">
          <div class="cp">
            <div id="cpcontent" style="padding: 1rem"></div>
          </div>
        </div>
        <div class="fwcx page">
          <!-- <div class="bg"><img src=" "></div> -->
          <div class="div1">
            <div class="div2">
              <img src="" id="labelImg" style="width: 45%" />
              <!-- 三维码 -->
              <div class="p p-3">
                <p>1、请用手触摸实物标签上的结构三维码是否有物理凹感！</p>
                <p>
                  2、请认真核对实物标签上的结构三维码、序号是否与上图一致！
                </p>
                <p>3、以上两点都相符则为真品，否则谨防假冒!</p>
              </div>
              <!-- 箱标 -->
              <div class="p p-2">
                <p>1、请用手触摸实物标签上的真迹防伪文字是否有物理凹感！</p>
                <p>2、请认真核对实物标签上的信息是否与上图一致！</p>
                <p>3、以上两点都相符则为真品，否则谨防假冒!</p>
              </div>
              <hr style="margin-top: 1rem; margin-bottom: 1rem" />
              <div class="info">
                <p>标签序号：<span id="cpidSpan"></span></p>
                <p>单位名称：四川省川酒集团酱酒有限公司</p>
                <p>首查时间：<span id="firstTime"></span></p>
                <p>已查次数：<span id="queryNum">0</span> 次</p>
              </div>
              <hr style="margin-top: 1rem; margin-bottom: 1rem" />
              <div class="tips">
                <div>
                  <img src="/static/images/134666/forg-icon-genuine.png" style="width: 3rem; margin-right: 0.8rem" />
                  <p style="flex: 1; color: rgb(27, 27, 27)">
                    您所查询的是四川省川酒集团酱酒有限公司的正牌产品标识！感谢您的品尝！
                  </p>
                </div>
              </div>
              <div class="btns">
                <p style="line-height: 1; width: 100%" class="aidiv">
                  您还可以点击下方按钮进行AI身份验证
                </p>
                <!-- <div id="ai" class="aibtn aidiv">AI匹配验证</div> -->
                <wx-open-launch-weapp id="launch-btn" class="aidiv" style="display: block; width: 38%">
                  <script type="text/wxtag-template">
                      <style>
                          .btn {
                              border-radius: 7px;
                              font-size: 14px;
                              width: 100%;
                              line-height: 2.6;
                              background: #e62129;
                              color: white;
                              text-align: center;
                              margin: 1rem auto;
                          }
                      </style>
                      <div class="btn">AI匹配验证</div>
                    </script>
                </wx-open-launch-weapp>
				
                <div class="homebtn">返回主页</div>
              </div>
				
				<div id="product_image" style="margin: 1rem 0; text-align: center; display: none;">
					<img src="" style="width: 100%;"/>
				</div>
            </div>
          </div>
        </div>
        <div class="qyjs page">
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_01.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_02.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_03.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_04.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_05.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_06.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_07.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_08.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_09.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_10.jpg" />
          <img src="/static/images/134666/cp2/b1e8fbeb28f4399139952fe8f645ea4_11.jpg" />
          <div class="homebtn" style="margin: 1rem auto">返回主页</div>
        </div>
        <div class="sy page">
          <div class="bg">
            <div class="wrapper">
              <div class="card hide" id="sy_content">
                <p class="hide">产品名称：<span id="sy_cpmc"></span></p>
                <p class="hide">生产日期：<span id="sy_scrq"></span></p>
                <p class="hide">生产批次：<span id="sy_scpc"></span></p>
                <p class="hide">出厂时间：<span id="sy_ccsj"></span></p>
                <hr />

                <div>
                  <p><b>溯源信息</b></p>
                  <p>
                    本产品于<span id="sy_rk_year"></span>年在[<span>川酒集团生产基地</span>]完成基酒酿造并储存
                  </p>
                  <div id="syinfo"></div>
                </div>
              </div>
              <div class="card hide" id="sy_none">
                <p style="text-align: center">暂无溯源信息</p>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="tabbar">
        <div class="weui-tabbar">
          <div id="cx" class="weui-tabbar__item">
            <div class="weui-tabbar__icon">
              <img src="/static/images/134666/but-forgery.png" />
            </div>
            <p class="weui-tabbar__label">防伪查询</p>
          </div>
          <div id="sy" class="weui-tabbar__item">
            <div class="weui-tabbar__icon">
              <img src="/static/images/134666/but-sy.png" />
            </div>
            <p class="weui-tabbar__label">产品溯源</p>
          </div>
          <div id="qy" class="weui-tabbar__item">
            <div class="weui-tabbar__icon">
              <img src="/static/images/134666/btn-business.png" />
            </div>
            <p class="weui-tabbar__label">公司介绍</p>
          </div>
        </div>
      </div>
    </div>
  </div>

  <script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  <script type="text/javascript" src="https://res.wx.qq.com/t/wx_fed/weui.js/res/1.2.13/weui.min.js"></script>
  <script src="/static/js/jquery-2.1.0.min.js"></script>
  <script src="/static/js/public/public.js"></script>

  <script>
    var loading = weui.loading("加载中");

    tj_public.wxInit({
      wx_officail_account_id: 29,
      url: window.location.href,
    });

    var cpid = tj_public.getCookie("label_code");
    var uid = tj_public.getCookie("TJWXUSR_134666_0");

    var isGaiWai = false;

    if (cpid.startsWith('1247') || cpid.startsWith('1246')) {
      isGaiWai = true
    }

    if (isGaiWai) {
      $('.fwcx').hide()
      $(".page").hide();
      $("#cx").hide()
      $("#qy").addClass('weui-bar__item_on')
      $('.qyjs').show()
      $('.homebtn').hide()
    }

    wx.ready(function () {
      tj_public.getAddress(function (lat, lng) {
        getInfo(lat, lng);
      });
      if (isGaiWai) return

      var uuid = tj_public.getUuid(8, 16);
      tj_public.configLaunchWeappBtn({
        el: "launch-btn",
        username: "gh_4290b605146b",
        extraData: {
          cpid,
          uid,
          uuid,
          os: "davis"
        },
        onLaunch: function () {
          tj_public.checkMiniprogramAIStatus(
            {
              label_code: cpid,
              consumer_id: uid,
              uuid,
            },
            function (state) {
              if (state == 1) {
                access();
              }
            }
          );
        },
      });
    });

    wx.error(function (res) {
      getInfo(0, 0);
    });


    function getInfo(lat, lng) {
      $.ajax({
        url: "/wx/label/scan_record/",
        data: {
          lat: lat,
          lng: lng,
          uid,
          compid: 134666,
          fwcode: cpid,
          contents: 1,
        },
        success: function (res) {
          loading.hide();
          if (res.e === "") {
            $("#cpidSpan").text(res.code);
            if (res.bcode) {
              $("#cpidSpan").text(res.bcode);
            }
            $("#queryNum").text(res.cnt);
            $("#firstTime").text(res.tm_1st);
            $("#labelImg").attr("src", res.img);
            if (res.product_contents && res.product_contents != 'None') {
              $("#cpcontent").html(decodeURIComponent(res.product_contents));
            } else {
              if (!isGaiWai) {
                $("#cx")
                  .addClass("weui-bar__item_on")
                  .siblings(".weui-bar__item_on")
                  .removeClass("weui-bar__item_on");
                $(".homebtn").hide();
                $(".page").hide();
                $(".fwcx").show();
              }
            }
            if (res.inventory.length > 0) {
              var inv = res.inventory[0];
              var shengchandate = new Date(inv.time.replace(/-/g, "/"));

              $("#sy_scrq")
                .text(shengchandate.toLocaleDateString())
                .parent()
                .show();
              $("#sy_scpc").text(inv.voucher_no).parent().show();
              $("#sy_rk_year").text(shengchandate.getFullYear());

              if (res.inventory.length > 1) {
                var inv2 = res.inventory[1];
                var chuchangdate = new Date(inv2.time.replace(/-/g, "/"));
                $("#sy_ccsj")
                  .text(chuchangdate.toLocaleDateString())
                  .parent()
                  .show();
              }

              var html = "";
              for (var r of res.inventory) {
                if (r.voucher_type === "销售出库") {
                  var store = r.store ? r.store : "";
                  html += `
                    <div style="margin-top:10px">
                      <p>${r.time}</p>
                      <p>从[${r.company}${store}]发往[${r.to_company}]，操作员:[${r.user}]</p>
                    </div>
                    `;
                } else if (r.voucher_type === "成品入库") {
                  html += `
                    <div style="margin-top:10px">
                      <p>${r.time}</p>
                      <p>到达[${r.company}]完成[成品入库]，操作员:[${r.user}]</p>
                    </div>
                    `;
                } else {
                  html += `
                    <div style="margin-top:10px">
                      <p>${r.time}</p>
                      <p>[${r.company}]完成[${r.voucher_type}]，操作员:[${r.user}]</p>
                    </div>
                    `;
                }
              }
              $("#syinfo").html(html);
			  var photoPids = [4490,4457,4460,9103,9104]
			  //if(res.product_photo && photoPids.includes(res.product_id)){
			  if(res.product_photo){
				$("#product_image img").attr("src", "/media/"+res.product_photo);
				$("#product_image").show();
			  }
              $("#sy_content").show();
            } else {
              $("#sy_none").show();
            }
          } else {
            $("#sy_none").show();
          }
        },
        error: function () {
          loading.hide();
          alert("网络超时！");
        },
      });
    }

    var pkg = tj_public.getCookie("package");
    if (pkg === "3") {
      $(".p-3").hide();
      $(".p-2").show();
      $(".aidiv").hide();
    }

    function access() {
      $(".aidiv").hide();
      $(".tips").show();
    }

    $(function () {
      $(".weui-tabbar__item").on("click", function () {
        $(this)
          .addClass("weui-bar__item_on")
          .siblings(".weui-bar__item_on")
          .removeClass("weui-bar__item_on");
        $(".page").hide();
        document.body.scrollTop = document.documentElement.scrollTop = 0;
        $(".page").animate({ scrollTop: 0 });
      });
      $("#cx").on("click", function () {
        $(".fwcx").show();
      });
      $("#qy").on("click", function () {
        $(".qyjs").show();
      });
      $("#sy").on("click", function () {
        $(".sy").show();
      });
      $(".homebtn").on("click", function () {
        $(".weui-bar__item_on").removeClass("weui-bar__item_on");
        $(".page").hide();
        document.body.scrollTop = document.documentElement.scrollTop = 0;
        $(".page").animate({ scrollTop: 0 });
        $(".home").show();
      });
    });
  </script>
</body>

</html>