<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>熊猫美妆F码</title>
    <meta name="format-detection" content="telephone=no" />
    <script src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/flexible.js?<?php echo bonus_version(); ?>"></script>
    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/css/main.css?<?php echo bonus_version(); ?>"/>
</head>
<body>
<div class="container-fluid bg_write layout_center p_relative">
    <div>
        <img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/images/content_bg.png" alt="熊猫美妆"/>
    </div>
    <div class="prompt_text t_left">
        <ul class="layout_center">
            <li>1.领取后进入APP“F码专区”购买</li>
            <li>2.请注意F码使用有效期</li>
            <li>3.商品退货后F码不退</li>
            <li>4.可以继续分享该链接给好友领取F码</li>
        </ul>
    </div>
    <div class="bind_tel_box p_absolute bg_write">
        <div class="fcode t_center layout_center fcode_init_bg"><?php echo $output['fcode']['fc_code']; ?></div>
        <div class="tel layout_center">
            <div class="mobile_box p_relative"><input type="number" placeholder="手机号" class="mobile block" id="tel_number"/></div>
            <div class="overflow get_box p_relative">
                <div class="f_left yz_box"><input type="number" placeholder="请输入验证码" class="yzcode block" id="yanz"/></div>
                <div class="f_left get_yz p_relative"><button type="button" class="block btn_yz t_center" id="hack">获取验证码</button></div>
            </div>
        </div>
        <div>
            <button class="btn btn_submit block t_center layout_center" id="bind">提交领取</button>
        </div>
    </div>

    <div class="p_absolute advert bg_write">
        <div class="f_left logo">
            <img src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/images/logo.png" alt="logo"/>
        </div>
        <div class="f_left">
            <h4>熊猫美妆</h4>
            <p>专柜美妆&nbsp;&nbsp;内买平台</p>
        </div>
        <div class="f_right">
            <a href="javascript:void(0)" class="btn btn_down block t_center" id="link">立即下载</a>
        </div>
    </div>
</div>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/js/zepto.min.js?<?php echo bonus_version(); ?>"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/fcode/js/fcode.js?<?php echo bonus_version(); ?>"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js?<?php echo bonus_version(); ?>"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/wx_share.js?<?php echo bonus_version(); ?>"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/layer.js?<?php echo bonus_version(); ?>"></script>
<script type="text/javascript">
    $(function(){
        $('#link').attr('href',app());

        $('body').height($('body')[0].clientHeight);

        $('#hack').on('tap',function()
        {
            var validate = new Validate();
            var mobile=validate.mobile('#tel_number');
            if(!mobile)
            {
                alert('请输入正确的电话号码');
                return;
            }
            else
            {
                var data = {
                    mobile:$('#tel_number').val(),
                    act:'login',
                    op:'getcode',
                    type:'getfcode',
                    client_type:'ajax'
                };
                var countTime = new CountDown(60);
                countTime.countDown();
                ajaxServer('post','/mobile/index.php',data,function(data)
                {
                    if (data.code != 200) {
                        alert(data.message);
                    }
                });
            }
        });

        $('#bind').on('tap',function ()
        {
            var validate = new Validate();
            var fmobile = validate.mobile('#tel_number');
            var fcode = validate.required('#yanz');
            var commonid = '<?php echo $output['fcode']['goods_commonid']; ?>';
            var batch_code = '<?php echo $output['fcode']['batch_code']; ?>';

            if(!fmobile) {
                alert('请输入正确的电话号码');
                return;
            }
            if(!fcode) {
                alert('请输入正确的验证码');
                return;
            }

            var mobile = $('#tel_number').val();
            var code   = $('#yanz').val();

            var data = {
                act:'fcode',
                op:'bind',
                client_type:'ajax',
                common_id:commonid,
                batch_code:batch_code,
                mobile:mobile,
                code:code
            };
            ajaxServer('post','/mobile/index.php',data,function(data)
            {
                if (data.code == 200)
                {
                    var url = "/mobile/index.php?act=fcode&op=index&common_id=" + commonid + "&batch_code=" + batch_code + "&mobile=" + mobile;
                    location.replace(url);
                }
                else {
                    alert(data.message);
                }
            });
        });

        $(document).on('tap',function()
        {
            var eventName=event.target.localName;
            if(eventName.indexOf('input') !== -1 || eventName.indexOf('button') !== -1){
                return;
            }
            $('input').blur();
        });

        var shareData = (function()
        {
            var url = "<?php echo url_helper::fcode_url($output['fcode']['goods_commonid'],$output['fcode']['batch_code']); ?>";
            return  {
                title:"领取熊猫美妆F码",
                desc:'享<?php echo "{$output['price']}元购{$output['name']}"; ?>福利\n\n点击领取',
                link:url,
                imgUrl:"<?php echo $output['image']; ?>"
            };
        })();
        weiXinShare.init(shareData);
    });
</script>
</body>
</html>