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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.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/public/animate.min.css" rel="stylesheet" />
    <link href="/static/css/public/Activity.css" rel="stylesheet" />
    <link href="/static/assets/18834/css/index.css" rel="stylesheet" />
    <title>演示活动</title>
    <style>

        .popup {
            display: flex;
            align-items: center;
            justify-content: center;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, .5);
            z-index: 1000;
        }

        .popup .wrapper {
            width: 80%;
            padding: 15px;
            background-color: #fff;
            border-radius: 5px;
            text-align: center;
        }

        .popup .wrapper .title {
            font-size: .85rem;
        }

        .active-tipmsg {
            border-radius: 10px;
            display: flex;
            flex-wrap: nowrap;
            margin: .75rem auto;
            width: 88%;
            background-color: white;
            font-size: .8rem;
            border: 1px solid #f5f5f5;
        }

        .active-input {
            padding: .5rem 0;
            width: 30%;
            background-color: #FFED7D;
            color: #A72211;
            border-bottom-left-radius: 10px;
            border-top-left-radius: 10px;
        }

        .input {
            flex: 1;
            border: none;
            text-align: center;
        }
		.wxgz-container {
			display: flex;
			align-items: center;
			justify-content: center;
			padding: .7rem 0;
			margin-top: 1rem;
			background-color: #FFF;
			font-size: .8rem
		}
		.btn-ai {
			width: 18rem;
			margin: 0 auto 1rem;
			background-color: #FFB800;
		}
		.btn-ai img{
			width:1.6rem;
		}
		.btn-ai span{
			font-size:.9rem;
		}
		.shadowbox {
			box-shadow: 2px 2px 2px #bebebe;
			border-radius: 4px;
		}

    </style>
</head>

<body> 
 <div>
        <div class="com_sign" style="background:none;text-align:left;padding:10px 0 10px 10px">
            <img src="http://www.china315net.com/img/logo.png" style="width:60%">
        </div>
        <img src="http://tjfnew.china315net.com/image/just/j5.jpg" style="width:100%" />
        <div class="content_pad">
            <div class="wonder_click">
                <div class="wonder_click_font">
                    精彩点击
                </div>
                <div class="wonder_click_img">
                    <div onclick="redirectTo('/mall/m/16687/1/')">
                        <img src="/static/assets/18834/img2/qyjs.png" />
                        <br /><span>积分商城</span>
                    </div>
                    <div onclick="redirectTo('/static/html/18834/fwzs.html')">
                        <img src="/static/assets/18834/img2/fwzs.png" />
                        <br /><span>防伪知识</span>
                    </div>
                    <div onclick="redirectTo('/wx/chcx/16687/')">
                        <img src="/static/assets/18834/img2/chcx.png" />
                        <br /><span>窜货查询</span>
                    </div>
                </div>
            </div>
            <div id="btnAISuccess" class="wxgz-container shadowbox btn-ai animated pulse"
                 style="animation-iteration-count:5;display:none;background-color:#008DCA;color:#FFF;" onclick="goAI();">
                <img id="needAI_icon" class="animated tada" src="/static/assets/16687/shualian.png"
                     style="animation-iteration-count:infinite;animation-duration:1.5s" />
                <span id="needAI_text" style="color: white;">该三维码已通过AI验证，请放心使用。</span>
            </div>
            <div id="btnAI" class="wxgz-container shadowbox btn-ai animated pulse"
                 style="animation-iteration-count:5" onclick="goAI();">
                <img id="needAI_icon" class="animated tada" src="/static/assets/16687/slyz.png"
                     style="animation-iteration-count:infinite;animation-duration:1.5s" />
                <span id="needAI_text" style="color: white;">点击进行AI认证</span>
            </div>
            <div class="wx_click" id="follow_wxnum">
                <img src="/static/assets/18834/img2/wx.png" /><span>点击进入公众号</span>
            </div>
            <div class="pro_display_font">产品展示</div>
            <div class="pro_display_img">
                <div>
                    <img src="https://os.china315net.com/Admin/Images/upload/1/190329094236.png"  /><br />
                    <!-- <span>内参酒</span> -->
                </div>
            </div>
            <div class="com_news">
                <div class="com_news_font">
                    企业动态
                </div>
                <div class="com_news_content">

                    <div style="margin-right:2.5%;">
                        <img src="https://os.china315net.com/Admin/Images/commup/1/202007270700086459.jpeg" style="height:5rem;" />
                    </div>
                    <!-- <div></div> -->
                </div>
            </div>
        </div>
        <div class="font_button" id="a3">页脚</div>
    </div>
    <div id="popupAddress" class="popup" style="display: none;">
        <div class="wrapper">
            <p class="title">请认真填写以下信息，以便我们核实！</p>

            <div class="active-tipmsg">
                <div class="active-input">姓名</div>
                <input id="input_name" placeholder="请输入您的姓名" class="input" />
            </div>
            <div class="active-tipmsg">
                <div class="active-input">手机号码</div>
                <input id="input_phone" placeholder="请输入您的手机号码" class="input" />
            </div>
            <div class="active-tipmsg">
                <div class="active-input">收货地址</div>
                <input id="input_address" placeholder="请输入您的收货地址" class="input" />
            </div>
            <div class="points1-btn" id="btn_sure">确定</div>
        </div>
    </div>
    <div class="authorBox" id="authorBox" style="display:none">
        <img class="icon_right" src="/static/images/public/gg.png" />
        <p class="point_authorBox">已通过验证！</p>
    </div>

    <script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.4.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.wxInit({
            wx_officail_account_id: 6,
            url: window.location.href
        })
        wx.ready(function () {
            tj_public.getAddress(function (lat, lng) {
                getInfo(lat, lng)
            })
        })
        wx.error(function (res) {
            getInfo(0, 0)
        });
        let name = '';
        let phone = '';
        let address = '';
        let winner_id = '';

        function getInfo(lat, lng) {
            $.ajax({
                url: '/wx/label/scan_record/',
                data: { lat: lat, lng: lng, uid: '{{consumer_id}}', compid: '16687', fwcode: '{{label_code}}' },
                success: function (res) {
                    if (res.e === '') {
                        tj_public.hideLoading();
						GetActivity();
                    } else {
                        alert('网络超时！')
                    }
                }, error: function () {
                    alert('网络超时！')
                }
            })
        }

        function GetActivity() {
            $.ajax({
                url: '/wx/ajax/get_activity/',
                data: {
                    company_id: 16687
                },
                success: function (res) {
                    if (res.e === '') {
                        if (res.award.code == 200) {
                            winner_id = res.award.winner_id;
                            ShowAward(res.award.data);
                        }
                        else {
                            if (res.award.code === 401) {
                                alert(res.award.reason + ', 奖品:' + res.award.data.name)
                            }
                            else {
                                //alert(res.award.reason)
                            }

                        }
                    }
                }
            })
        }

        function ShowAward(award) {
            if (!winner_id) {
                return;
            }

            let onClickFunc = 'GetAward();';
            if (award.awardcat_id === 1) {
                onClickFunc = 'openAddress();';
            }
            var dom = `
                <div class="ac-container" id="tj_ac">
                    <div class="points1-container">
                        <p class="points1-subtitle">恭喜您，获得${award.name}</p>
                        <div class="points1-btn" onclick="${onClickFunc}">立即领取</div>
                    </div>
                </div>
            `
            document.body.append(document.createRange().createContextualFragment(dom));
        }

        function GetAward() {
            tj_public.showLoading();
            $.ajax({
                type: 'GET',
                data: {
                    winner_id,
                    name,
                    phone,
                    address
                },
                url: '/sales/ajax/winner/redeem/',
                success: function (res) {
                    if (res.e === '') {
                        alert('领取成功！');
                        $("#tj_ac").fadeOut();
                        closeAddress();
                    }
                    else {
                        alert(res.e);
                    }
                    tj_public.hideLoading();

                },
                error: function () {
                    alert('连接服务器失败');
                    tj_public.hideLoading();
                }
            });
        }

        function openAddress() {
            $("#popupAddress").fadeIn();
        }

        function closeAddress(){
            $("#popupAddress").hide();
        }


        $("#btn_sure").click(function () {
            name = $("#input_name").val();
            phone = $("#input_phone").val();
            address = $("#input_address").val();
            if (name.trim().length < 2) {
                alert('请输入正确的姓名！');
                return;
            }
            if (!(/^1[3456789]\d{9}$/.test(phone))) {
                alert('请输入正确的手机号码！');
                return;
            }
            if(address.trim().length<5){
                alert('请填写正确的收货地址！');
                return;
            }
            GetAward();

        })
        function redirectTo(url) {
            window.location.href = url;
        }
		
		let isAccess = tj_public.getQueryString('access');
        if(isAccess ==='1'){
            access();
            history.replaceState(null, null, "?label_code={{label_code}}&access=0");
        }

        function access() {
            $("#authorBox").fadeIn();
            setTimeout(function () {
                 $("#authorBox").fadeOut();
             },3000)
			$("#btnAI").hide();
			$("#btnAISuccess").show();
			 
        }
		function goAI(){
			window.location.href = 'https://tjfnew.china315net.com/tjswm/ai/route/route.ashx?compid=1&cpid={{label_code}}';
		}
    </script>
</body>

</html>