<!--{include file="<!--{$oetplpath}-->public/widget_header.tpl"}-->
<style type="text/css">
  body{background:#fff;}
</style>
<!--  兼容会员中心绑定 -->
<div class="oe_login_weixin">
  <!--{if $login.status == '1'}-->
  <h3>微信扫码绑定</h3>
  <!--{else}-->
  <h3>微信扫码登录</h3>
  <!--{/if}-->
  <div class="bd">
    <input type="hidden" name="forward" id="forward" value="<!--{$forward}-->" />
    <input type="hidden" name="userid" id="userid" value="<!--{if $login.status == '1'}--><!--{$login.info.userid}--><!--{else}-->0<!--{/if}-->" />
    <!--{if $login.status == '1'}-->
    <!--{assign var="srcurl" value="<!--{$config.siteurl}-->index.php?m=wap&c=passport&a=auth&mod=wechat&wxsalt=<!--{urlencode($wxsalt)}-->&from=wxsalt&forward=&userid=<!--{$login.info.userid}-->"}-->
    <!--{else}-->
    <!--{assign var="srcurl" value="<!--{$config.siteurl}-->index.php?m=wap&c=passport&a=auth&mod=wechat&wxsalt=<!--{urlencode($wxsalt)}-->&from=wxsalt&forward="}-->
    <!--{/if}-->
    <img src="<!--{$oefile}-->?c=scan&a=getqr&size=4&url=<!--{$srcurl|urlencode}-->&r=<!--{$time}-->" />
  </div>
  <div class="hd" id="result_tips">
    <!--{if $login.status == '1'}-->
    <span class="ico"></span>微信扫一扫绑定
    <!--{else}-->
    <span class="ico"></span>微信扫一扫登录
    <!--{/if}-->
  </div>
  
</div>
  
<script type="text/javascript">
$(function(){
    _reqLoginResult();
});
//支付结果请求
function _reqLoginResult() {
    $forward = $("#forward").val();
    $userid = $("#userid").val();
    $.ajax({
        type: "POST",
        url: "<!--{$oefile}-->?c=passport",
        cache: false,
        data: {
            a:"reqswx", wxsalt:"<!--{$wxsalt}-->", userid:$userid, r:get_rndnum(8)
        },
        dataType: "json",
        success: function($data) {
            $json = eval($data);
            $response = $json.response;
            $result = $json.result;
            if ($response == "1") {
                $("#result_tips").html("<span class='ico'></span>微信登录成功");
                setTimeout(function(){
                    if ($forward.length > 0) {
                        window.top.location.href = $forward;
                    }
                    else {
                        window.top.location.reload();
                    }
                }, 200);
                return false;
            }
            else if ($response == "2") {
                //跳到注册页...
                $jump_url = _ROOT_PATH+"index.php?c=passport&a=reg&au_mod=wechat"+
                                        "&openid="+encodeURIComponent($result.openid)+
                                        "&au_unionid="+encodeURIComponent($result.wxunionid)+
                                        "&au_nickname="+encodeURIComponent($result.wxnickname)+
                                        "&au_gender="+encodeURIComponent($result.wxgender)+
                                        "&au_headimgurl="+encodeURIComponent($result.wxheadimg)+
                                        "&forward="+encodeURIComponent($forward);
                window.top.location.href = $jump_url;
                return false;
            }
            
            //8.08.29
            else if ($response == "3") {
                $("#result_tips").html("<span class='ico'></span>微信绑定成功");
                setTimeout(function(){
                    window.top.location.reload();
                }, 300);
                return false;
            }
            else if ($response == "4") {
                $("#result_tips").html("<span class='ico'></span>绑定失败或重复绑定");
                setTimeout(function(){
                    window.top.location.reload();
                }, 300);
                return false;
            }
            else {

            }
            setTimeout(function(){
                _reqLoginResult();
            }, 1000);
        },
        error: function() {

        }
    });
}
</script>
</body>
</html>