@@ -27,12 +27,12 @@ <h1>Protoshop</h1>
27
27
< span class ="fa fa-angle-right "> </ span >
28
28
< div class ="show-mobile "> < span class ="fa fa-mobile "> </ span > < br /> View on Mobile</ div >
29
29
</ div >
30
- < form class ="login-form ">
30
+ < form id =" login-form " class ="login-form ">
31
31
< ul >
32
- < li > < input type ="text " placeholder ="Email Address " required /> </ li >
33
- < li > < input type ="text " placeholder ="Nickname " required /> </ li >
34
- < li > < input type ="password " placeholder ="Password " required /> </ li >
35
- < li > < button class ="btn-login "> Sign Up</ button > < a href ="../app/ " class ="link-form "> Login</ a > </ li >
32
+ < li > < input name =" email " type ="text " placeholder ="Email Address " required /> </ li >
33
+ < li > < input name =" nick " type ="text " placeholder ="Nickname " required /> </ li >
34
+ < li > < input name =" pass " type ="password " placeholder ="Password " required /> </ li >
35
+ < li > < button class ="btn-login "> Sign Up</ button > < a id =" login " href ="../app/ " class ="link-form "> Login</ a > </ li >
36
36
</ ul >
37
37
</ form >
38
38
</ div >
@@ -130,10 +130,32 @@ <h3><em>View</em>On Mobile<span class="qrcode-download"></span></h3>
130
130
< i class ="fa fa-coffee "> </ i > < a href ="https://qr.alipay.com/ap27zqsxo3v5q61z1f " title ="求咖灰~~~ " target ="_blank "> Buy me a coffee!</ a > < span class ="qrcode-donate "> </ span > (੭ु๑‾᷄ ⁻̫ ‾᷅)੭ु⁾⁾
131
131
</ div >
132
132
</ div >
133
- < script src ="http://code.jquery.com/jquery-1.11.0.min.js "> </ script >
133
+ < script src ="../app/bower_components/jquery/jquery.js "> </ script >
134
+ < script src ="../app/scripts/libs/md5.js "> </ script >
134
135
< script >
135
136
$ ( function ( ) {
136
-
137
+
138
+ // ENVIRONMENT
139
+ var env ;
140
+ if ( / d e b u g | l o c a l h o s t / . test ( window . location . href ) ) {
141
+ env = 'debug' ;
142
+ } else if ( / c t r i p q a / . test ( window . location . href ) ) {
143
+ env = 'ctqa' ;
144
+ } else {
145
+ env = 'open' ;
146
+ }
147
+
148
+ var apiHosts = {
149
+ debug : 'http://10.2.254.48/debugProtoShop/' ,
150
+ ctqa : 'http://10.2.254.48/ProtoShop/' ,
151
+ open : 'http://api.protoshop.io/'
152
+ } ;
153
+
154
+ var ENV = {
155
+ env : env ,
156
+ apiHost : apiHosts [ env ]
157
+ } ;
158
+
137
159
// Scroll Func
138
160
$ ( 'nav span' ) . on ( 'click' , function ( $e ) {
139
161
scrollTo ( '#splash' ) ;
@@ -159,15 +181,36 @@ <h3><em>View</em>On Mobile<span class="qrcode-download"></span></h3>
159
181
}
160
182
161
183
// Body Class
162
- var env = 'unknown' ;
163
- if ( / d e b u g | l o c a l h o s t / . test ( window . location . href ) ) {
164
- env = 'debug' ;
165
- } else if ( / c t r i p q a / . test ( window . location . href ) ) {
166
- env = 'ctqa' ;
167
- } else {
168
- env = 'open' ;
169
- }
170
- $ ( 'body' ) . addClass ( 'env-' + env ) ;
184
+ $ ( 'body' ) . addClass ( 'env-' + ENV . env ) ;
185
+
186
+ // Register
187
+ $ ( '#login-form' ) . on ( 'submit' , function ( e ) {
188
+ var form = e . target ;
189
+
190
+ // 将密码做 MD5 转换
191
+ var data = {
192
+ email : form . email . value ,
193
+ passwd : V . Security . md5 ( form . pass . value ) ,
194
+ nickname : form . nick . value
195
+ } ;
196
+
197
+ // 注册
198
+ $ . post ( ENV . apiHost + 'register/' , data )
199
+ . success ( function ( res ) {
200
+ switch ( res . status ) {
201
+ case 0 :
202
+ var loggedInUser = res . result [ 0 ] ;
203
+ localStorage . setItem ( 'loggedInUser' , JSON . stringify ( loggedInUser ) ) ;
204
+ window . location . href = $ ( '#login' ) . attr ( 'href' ) ;
205
+ break ;
206
+ default :
207
+ console . log ( 'Registration Error.' ) ;
208
+ }
209
+ } ) ;
210
+
211
+ e . preventDefault ( ) ;
212
+ } ) ;
213
+
171
214
} ) ;
172
215
</ script >
173
216
</ body >
0 commit comments