<!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/183495/css/main.css" rel="stylesheet" />
    <title>吉林吉农高新技术发展股份有限公司</title>
</head>

<body>
    <div class="app">
        <div class="bg"><img src="/static/183495/img/bg.png" style="width: 100%;"></div>
        <div id="cpsy" class="page">
            <div class="title"><img src="/static/183495/img/sy.png"></div>
            <div class="block" style="padding: 0;text-align:center;">
                <video src="/static/183495/img/video.mp4" controls poster="/static/183495/img/poster.jpg"
                    style="height: 10rem;"></video>
            </div>
            <div class="block">
                <div><span>品种名称 :</span><span id="name"></span></div>
                <div><span>销售区域 :</span><span>全国</span></div>
                <div><span>收货单位 :</span><span id="to_company"></span></div>
                <div><span>总&ensp;经&ensp;销 :</span><span>通榆县黄榆街思源路东北鑫诚3-6号楼南至北第17门</span></div>
                <div><span>登记编号 :</span><span id="standard"></span></div>
            </div>
            <div class="block" style="margin-bottom: 1rem;">
                <div><span>生产经营许可证 :</span><span id="pl"></span></div>
                <div><span>公司名称 :</span><span>吉林吉农高新技术发展股份有限公司<br>吉林红粮种业科技有限公司<br>吉林省常胜种业有限公司</span></div>
                <div><span>厂&emsp;&emsp;家 :</span><span>吉林吉农高新技术发展股份有限公司</span></div>
                <div><span>地&emsp;&emsp;址 :</span><span>吉林省公主岭市科贸西大街303号</span></div>
                <div><span>技术服务电话 :</span><span>133 6447 0496</span></div>
            </div>
            <div id="fw" class="btn" style="margin-top: .5rem;">防伪查询</div>
        </div>
        <div id="fwcx" class="page" style="display: none;">
            <div class="title"><img src="/static/183495/img/fw.png"></div>
            <div class="block">
                <div style="text-align: center;">
                    <img src="" id="labelImg" style="width: 30%;" />
                </div>
                <div class="hr"></div>
                <!-- 三维码 -->
                <div class="p p-3" id="warn_swm">
                    <p>请认真核对实物标签上的烫金三维码是否与上图一致，相符则为正品，否则谨防假冒！</p>
                </div>
                <div class="hr"></div>
                <div class="info">
                    <p>首查时间：<span id="firstTime"></span></p>
                    <p>已查次数：<span id="queryNum">0</span> 次</p>
                </div>
                <div class="tips">
                    该产品为<br><b>吉林吉农高新技术发展股份有限公司</b><br>正品标识！请放心使用！
                </div>
            </div>
            <div class="aidiv">
                <!-- <div class="btn">AI查询</div> -->
                <wx-open-launch-weapp id="launch-btn" style="display: block;">
                    <script type="text/wxtag-template">
                            <style>
                                .btn {
                                    width: 55%;
                                    line-height: 2.5;
                                    border-radius: 20px;
                                    margin: auto;
                                    font-size: 14px;
                                    background: #b20405;
                                    color: white;
                                    text-align: center;
                                }
                            </style>
                            <div class="btn">AI查询</div>
                        </script>
                </wx-open-launch-weapp>
            </div>
            <div id="sy" class="btn" style="margin-top: .5rem;">产品溯源</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/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');
        tj_public.wxInit({
            wx_officail_account_id: 6,
            url: window.location.href
        })


        wx.ready(function () {
            if (uid) {
                tj_public.getAddress(function (lat, lng) {
                    getInfo(lat, lng)
                })
                var uuid = tj_public.getUuid(8, 16);
                tj_public.configLaunchWeappBtn({
                    el: 'launch-btn',
                    username: 'gh_4290b605146b',
                    extraData: {
                        cpid: label_code,
                        uid,
                        uuid,
                        os: 'davis'
                    },
                    onLaunch: function () {
                        tj_public.checkMiniprogramAIStatus(
                            {
                                label_code,
                                consumer_id: uid,
                                uuid,
                            }, function (state) {
                                if (state == 1) {
                                    access();
                                }
                            })
                    }
                })
            }
        })
        wx.error(function (res) {
            if (uid) {
                getInfo(0, 0);
            }
        });

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

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

                        var inventory = res.inventory.filter(function (f) {
                            return f.voucher_type === '销售出库' && f.company_id === 183495
                        })
                        if (inventory.length > 0) {
                            if (inventory[0].to_company != "") {
                                $("#to_company").text(inventory[0].to_company)
                            }
                        }

                        var product_id = res.product_id
                        if (product_id) {
                            $("#proContent").html(decodeURIComponent(res.product_contents))
                            $.ajax({
                                url: '/product/detail/',
                                data: {
                                    id: product_id
                                },
                                success: function (product) {
                                    console.log(product);
                                    var props = product.props;
                                    $("#name").text(product.name);
                                    $("#standard").text(product.standard);
                                    $("#pl").text(product.pl);
                                }
                            })
                        }

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


        $('#fw').on('click', function () {
            $('.page').hide();
            $('#fwcx').show();
        });
        $('#sy').on('click', function () {
            $('.page').hide();
            $('#cpsy').show();
        });

    </script>
</body>

</html>