<!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" />
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.4.0/weui.min.css">
    <link href="/static/css/public/reset.css" rel="stylesheet" />
    <link href="/static/css/public/public.css" rel="stylesheet" />
    <script src="/static/js/public/reset.js"></script>
    <link href="/static/css/public/swiper.css" rel="stylesheet" />
    <link href="/static/203604/css/main.css" rel="stylesheet" />
    <title>西安妙之门酒业有限公司</title>
</head>

<body>
    <div class="app">
        <div class="swiper-container" id="case" style="width: 100%;">
            <div class="swiper-wrapper" style="width: 100%;">
                <div class="swiper-slide" style="width: 100%;">
                    <img src="/static/203604/img/b1.jpg" style="width: 100%;" />
                </div>
                <div class="swiper-slide">
                    <img src="/static/203604/img/b2.jpg" style="width: 100%;" />
                </div>
                <div class="swiper-slide">
                    <img src="/static/203604/img/b3.jpg" style="width: 100%;" />
                </div>
            </div>
            <div class="swiper-pagination"></div>
        </div>
        <div class="container">
            <div class="sy_syinfo">
                <p class="fhinfo">
                    <span class="info cpmc">产品名称: </span><span id="sy_pro" class="item"></span>
                </p>
                <p class="fhinfo">
                    <span class="info ckrq">出库日期: </span><span id="sy_fh" class="item"></span>
                </p>
                <p class="fhinfo">
                    <span class="info jxsmc">经销商名称: </span><span id="sy_jxs" class="item"></span>
                </p>
                <p>
                    <span class="info scsm">首次扫码时间: </span><span id="firstTime" class="item"></span>
                </p>
                <p>
                    <span class="info smrs">扫码人数: </span><span id="sy_rs" class="item"></span>
                </p>
                <p>
                    <span class="info smcs">扫码次数: </span><span id="queryNum" class="item"></span>
                </p>
            </div>
            <div class="btn-flow" id="btn-flow">
                <div style="border-bottom: 1px solid rgb(0,138,244); margin-right: 5px;">生产工艺信息</div>
                <img id="icon-flow" src="/static/203604/img/show.png"
                    style="width: 15px; transform: rotate(-90deg); margin-top: 1px;" />
            </div>
            <div id="flow" style="margin-bottom: 100px;" hidden>
                <img src="/static/203604/img/flow.png" style="width: 100%" />
            </div>
        </div>
    </div>

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

        tj_public.showLoading();
        // tj_public.hideLoading();
        var uid = tj_public.getCookie('TJWX_consumer_id');
        var label_code = tj_public.getCookie('label_code');
        var jmcpid = tj_public.getCookie('jmcpid');
        var label = jmcpid ? jmcpid : label_code;
        tj_public.wxInit({
            wx_officail_account_id: 6,
            url: window.location.href
        })


        var mySwiper = new Swiper('#case', {
            loop: true,
            autoplay: true,
            pagination: {
                el: '.swiper-pagination',
            },
        });

        var open = 0;
        $('#btn-flow').on('click', function () {
            if (open == 0) {
                $('#flow').show();
                $("#icon-flow").css("transform", "rotate(0deg)");
                open = 1;
            }
            else {
                $('#flow').hide();
                $("#icon-flow").css("transform", "rotate(-90deg)");
                open = 0;
            }
        });


        wx.ready(function () {
            if (uid) {
                tj_public.getAddress(function (lat, lng) {
                    getInfo(lat, lng)
                })
            }
        })
        wx.error(function (res) {
            if (uid) {
                getInfo(0, 0);
            }
        });

        // getInfo(0, 0)
        function getInfo(lat, lng) {
            $.ajax({
                url: '/wx/label/scan_record/',
                data: { lat: lat, lng: lng, uid: uid, compid: 203604, fwcode: label_code, contents: 1 },
                success: function (res) {
                    if (res.e === '') {
                        tj_public.hideLoading();
                        $("#queryNum").text(res.cnt);
                        $("#sy_rs").text(res.cnt);
                        if (res.tm_1st) {
                            $("#firstTime").text(res.tm_1st);
                        }
                        else {
                            var myDate = new Date();
                            $("#firstTime").text(myDate.toLocaleString());
                        }

                        $("#sy_pro").text(res.product_name);
                        if (res.inventory.length > 0) {
                            for (var inv of res.inventory) {
                                if (inv.voucher_type === '销售出库' && inv.company_id === 203604) {
                                    $("#sy_pro").text(inv.product);
                                    $("#sy_fh").text(inv.time);
                                    $("#sy_jxs").text(inv.company);
                                    // $(".fhinfo").show();
                                }
                            }
                            if ($("#sy_jxs").text() != '') {
                                $(".fhinfo").show();
                            }
                        }

                    } else {
                        alert('网络超时！')
                    }
                }, error: function () {
                    alert('网络超时！')
                }
            })
        }

    </script>
</body>

</html>