xinyb
3 天以前 3b74e3df72726e188d36393ecfd7964d095ef7e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.yc.sdk.shopping.util.SettingKey"%>
<%@page import="com.yc.utils.SessionKey"%>
<%
 
String hostUrl = SettingKey.getHostUrl(request) ;
String wxQueryString = SettingKey.getQueryStringByWx(request);
boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request);
String oauth2UUID = request.getParameter(SessionKey.OAUTH2UUID) ;
if (oauth2UUID == null || "".equals(oauth2UUID)) {
    out.println( "非法访问!");
    return ;
}
 
//String openId = request.getParameter("openid") ;
String dbid = request.getParameter(SessionKey.DATA_BASE_ID ) ;
String redirect = request.getParameter("redirect"); // 登录后重定向页面,Added by Johns Wang, 2016-02-17
String orgHost = request.getParameter("orghost") ;  //原始主机名 
String oauth2from = request.getParameter("oauth2from") ; 
%>    
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="<%=hostUrl%>/shopping/view/javascript/jquery/jquery-2.1.1.min.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/shopping/view/javascript/jquery/jquery-2.1.1.min.js")%>" type="text/javascript"></script>
<link href="<%=hostUrl%>/shopping/view/javascript/bootstrap/css/bootstrap.min.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/shopping/view/javascript/bootstrap/css/bootstrap.min.css")%>" rel="stylesheet" media="screen" />
<script src="<%=hostUrl%>/shopping/view/javascript/bootstrap/js/bootstrap.min.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/shopping/view/javascript/bootstrap/js/bootstrap.min.js")%>" type="text/javascript"></script>
<link href="<%=hostUrl%>/shopping/view/javascript/font-awesome/css/font-awesome.min.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/shopping/view/javascript/font-awesome/css/font-awesome.min.css")%>" rel="stylesheet" type="text/css" />
 
<link href="<%=hostUrl%>/shopping/view/theme/default/stylesheet/googleapisFont.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/shopping/view/theme/default/stylesheet/googleapisFont.css")%>" rel="stylesheet" type="text/css" />
<link href="<%=hostUrl%>/shopping/view/theme/default/stylesheet/stylesheet.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/shopping/view/theme/default/stylesheet/stylesheet.css")%>" rel="stylesheet">
 
<title>绑定登录用户</title>
</head>
<body>
<div class="container">
<div class="" id="collapse-messages"><div class="panel-body"></div></div>
<div class="row">                
     <div id="content" class="col-sm-12">
     <h1>您第一次使用<%= oauth2from!=null&&oauth2from.equals("wx")?"微信":"" %><%= oauth2from!=null&&oauth2from.equals("qq")?"QQ":"" %>扫码登录,需要绑定登录用户(请在20分钟内完成)</h1>
     <form action="<%=hostUrl %>/oauth2/buildinguser.do?<%= SessionKey.OAUTH2UUID %>=<%=oauth2UUID %><%= (wxQueryString == null||"".equals(wxQueryString)?"":"&" + wxQueryString)  %>" method="post" class="form-horizontal">
     <fieldset>
         <div class="form-group required">
            <label class="col-sm-2 control-label" for="topic">账号:</label>
            <div class="col-sm-10">
              <input type="text" name="account" value="" placeholder="账号" id="input-account" class="form-control" />
            </div>
          </div>
          <div class="form-group required">
            <label class="col-sm-2 control-label" for="pwd">密码:</label>
            <div class="col-sm-10">
              <input type="password" name="pwd" value="" placeholder="密码" id="input-pwd" class="form-control" />
            </div>
          </div>
          
      </fieldset>
       <div class="buttons clearfix">
          <input type="hidden" name="redirect" value="<%= redirect==null?"":redirect %>"/>
          <input type="hidden" name="orghost" value="<%= orgHost==null?"":orgHost %>"/>
          <input type="hidden" name="<%= SessionKey.DATA_BASE_ID %>" value="<%= dbid==null?"":dbid %>"/>
          <div class="pull-right">
            <input type="button" value="提交" id="button-submit" class="btn btn-primary" />
          </div>
        </div>    
        
        </form>
        </div>
    </div>    
</div>
 
 
<script type="text/javascript"><!--
$('#button-submit').on('click', function() {
    //var mydate = $('#input-unvaliddate').val() ;
    //var aa = moment(mydate).format('YYYY-MM-DD hh:mm');
    $.ajax({
        url: '<%=hostUrl %>/oauth2/buildinguser.do?<%= SessionKey.OAUTH2UUID %>=<%=oauth2UUID %><%= (wxQueryString == null||"".equals(wxQueryString)?"":"&" + wxQueryString)  %>',
        type: 'post',
        data: $('input[type=\'text\'],input[type=\'radio\']:checked,input[type=\'checkbox\']:checked,select,textarea,input[type=\'password\'],input[type=\'hidden\']'),
        dataType: 'json',
        beforeSend: function() {
             $('#button-submit').button('loading');
        },
        complete: function() {
            $('#button-submit').button('reset');
        },
        success: function(json) {
            $('.alert, .text-danger').remove();
            if (json['success']) {
                alert(json['success']) ;
            }
            var messagetxt = "" ;
            for (i in json["warning"]) {
                 if (json["warning"][i]["messagetxt"]) {
                   messagetxt += json["warning"][i]["messagetxt"] + "\n\r" ;
                 }
             }
            if (messagetxt != "") {
                $('#collapse-messages .panel-body').prepend('<div class="alert alert-warning">' + messagetxt + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
            }
            
            
            if (json['redirect'] && messagetxt == "") {
                location = json['redirect'];
            } else if (json['error']) {
                
                
                
                if (json['error']['warning']) {
                    $('#collapse-messages .panel-body').prepend('<div class="alert alert-warning">' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                }
                
                for (i in json['error']) {
                    var element = $('#input-' + i.replace('_', '-'));
 
                    if ($(element).parent().hasClass('input-group')) {
                        $(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');
                    } else {
                        $(element).after('<div class="text-danger">' + json['error'][i] + '</div>');
                    }
                }
                
                 // Highlight any found errors
                $('.text-danger').parent().parent().addClass('has-error');
            } 
        },
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
    });
});
//--></script>
</body>
</html>