login.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <?php
  2. namespace app\index;
  3. class login extends Base
  4. {
  5. function index()
  6. {
  7. if ($this->userlogined) {
  8. redirect("/index/user_profile");
  9. }
  10. ?>
  11. <!DOCTYPE html>
  12. <html lang="">
  13. <head>
  14. <title>账号登录 - <?php echo IN_NAME; ?>免费应用内测托管平台|iOS应用Beta测试分发|Android应用内测分发</title>
  15. <meta charset="utf-8" />
  16. <meta name="viewport"
  17. content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  18. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  19. <meta name="renderer" content="webkit" />
  20. <meta name="keywords" content="<?php echo IN_KEYWORDS; ?>" />
  21. <meta property="og:url" content="https://<?php echo $_SERVER["HTTP_HOST"]; ?>/" />
  22. <meta property="og:title" content="<?php echo IN_NAME; ?>" />
  23. <meta name="description" content="<?php echo IN_DESCRIPTION; ?>" />
  24. <?php
  25. $this->static_();
  26. ?>
  27. <link rel="stylesheet" href="/static/index/css/login.css">
  28. </head>
  29. <body>
  30. <?php
  31. $this->header();
  32. ?>
  33. <style>
  34. .em {
  35. font-style: normal;
  36. }
  37. .login-three-home {
  38. height: 84px;
  39. padding: 30px 0 0 0;
  40. width: 355px;
  41. text-align: center;
  42. }
  43. .clearfix:before {
  44. content: ".";
  45. display: block;
  46. height: 0;
  47. overflow: hidden;
  48. visibility: hidden;
  49. }
  50. .login-three-home h3 {
  51. font-size: 12px;
  52. color: #666;
  53. text-align: center;
  54. padding: 5px 0 20px 0;
  55. width: 409px;
  56. height: 14px;
  57. background: url(/qq/image/line.jpg) left center repeat-x;
  58. }
  59. .login-three-home h3 em {
  60. background: #fff;
  61. padding: 0 5px;
  62. }
  63. a#qq {
  64. background-position: 0 -335px;
  65. }
  66. .login-three a,
  67. .login-three-home a {
  68. display: inline-block;
  69. width: 40px;
  70. height: 40px;
  71. margin-right: -50px;
  72. background: url(/qq/image/focus2018.png) no-repeat;
  73. }
  74. </style>
  75. <script src="/static/index/js/jquery.validate.min.js"></script>
  76. <div class="login-common">
  77. <div class="tit">
  78. <div id="acc_login" class="tit" style="display:inline-block;cursor:pointer">账号登录</div>
  79. <?php if (IN_SMS666666) { ?>
  80. &nbsp; &nbsp; &nbsp;
  81. <div id="phone_login" class="tit" style="display:inline-block;color:rgba(118, 144, 181, 1);cursor:pointer">短信登录</div>
  82. <?php } ?>
  83. </div>
  84. <form role="form" id="loginValid" novalidate="novalidate">
  85. <input type="password" style="position: absolute;top: -999px" />
  86. <div class="form-group">
  87. <label class="iconfont icon-user" for="user"></label>
  88. <input type="text" class="form-control input-lg" id="user" name="username"
  89. aria-describedby="helpBlock2"
  90. placeholder="账号名称">
  91. <span class="help-block">请输入正确的账号名称</span>
  92. </div>
  93. <div class="form-group">
  94. <label class="iconfont icon-pwd" for="password"></label>
  95. <input class="form-control input-lg" id="password" name="password" placeholder="登录密码"
  96. type="password">
  97. <span class="help-block">请输入正确的密码</span>
  98. </div>
  99. <div class="btn-action">
  100. <a href="/index/lost" class="fr">忘记密码?</a>
  101. <?php if (IN_SMS666666) { ?>
  102. <a id="phone_login_btn">手机验证码登录</a>
  103. <?php } ?>
  104. </div>
  105. <!-- <div class="checkbox"><input type="checkbox" id="remember-me" checked><span>记住我</span></div> -->
  106. <button type="button" class="ms-btn ms-btn-primary input-lg btn-login" id="submitButton">登录</button>
  107. <div class="clearfix mt15 to-register">
  108. <?php if (IN_REG_ON) { ?>还没有账号?&nbsp;&nbsp;&nbsp;<a href="/index/reg" class="fl">去注册</a>
  109. <?php } ?>
  110. <!-- <a href="/index/lost" class="fr">忘记密码</a> -->
  111. </div>
  112. </form>
  113. <form role="form" id="loginValid_code" novalidate="novalidate" style="display:none">
  114. <font color="#FF0000" style="font-size:20px">未设置短信,请使用左边的账号登录。<br>需要测试短信登录功能请联系客服设置。</font>
  115. <div class="form-group">
  116. <label class="iconfont icon-user" for="phone"></label>
  117. <input type="text" class="form-control input-lg" id="phone" name="phone"
  118. aria-describedby="helpBlock2"
  119. placeholder="手机号码">
  120. <span class="help-block">请输入正确的手机</span>
  121. </div>
  122. <div class="form-group">
  123. <label class="iconfont icon-email"></label>
  124. <div class="clearfix verification-code">
  125. <input type="text" class="form-control input-lg fl" id="code" placeholder="验证码">
  126. <button type="button" class="ms-btn ms-btn-primary input-lg fr" id="sendcode">获取验证码</button>
  127. </div>
  128. <span class="help-block">请输入正确的验证码</span>
  129. </div>
  130. <button type="button" class="ms-btn ms-btn-primary input-lg btn-login" id="submitButton_code">登录</button>
  131. <div class="clearfix mt15 to-register">
  132. <?php if (IN_REG_ON) { ?>还没有账号?&nbsp;&nbsp;&nbsp;<a href="/index/reg" class="fl">去注册</a>
  133. <?php } ?>
  134. </div>
  135. </form>
  136. <!--新增QQ互联登录-->
  137. <?php if (IN_QQ) { ?>
  138. <div class="login-three-home clearfix">
  139. <h3>社交登录</h3> <a onClick="test();" class="login_click" id="qq"></a>
  140. </div>
  141. <?php } ?>
  142. <!--新增QQ互联登录-->
  143. </div>
  144. <script>
  145. $(function() {
  146. countdown = 60;
  147. function settime() {
  148. if (countdown == 0) {
  149. $('#sendcode').attr("disabled", false);
  150. $('#sendcode').html("获取验证码");
  151. countdown = 60;
  152. return;
  153. } else {
  154. $('#sendcode').attr("disabled", true);
  155. $('#sendcode').html("重新发送(" + countdown + ")");
  156. countdown--;
  157. }
  158. setTimeout(function() {
  159. settime()
  160. }, 1000)
  161. }
  162. $('#sendcode').click(function() {
  163. var phone = $('#phone').val();
  164. if (phone) {
  165. $.post('/index/ajax/send_sms_forget', {
  166. phone: phone
  167. }, function(data) {
  168. if (data.code != 200) {
  169. alert(data.msg);
  170. } else {
  171. settime();
  172. alert(data.msg);
  173. }
  174. }, 'json');
  175. }
  176. });
  177. $('#acc_login').click(function() {
  178. $('#phone_login').css('color', 'rgba(118, 144, 181, 1)');
  179. $('#acc_login').css('color', 'rgba(21, 21, 21, 1)');
  180. $('#loginValid').css('display', 'block');
  181. $('#loginValid_code').css('display', 'none');
  182. })
  183. $('#phone_login').click(function() {
  184. $('#phone_login').css('color', 'rgba(21, 21, 21, 1)');
  185. $('#acc_login').css('color', 'rgba(118, 144, 181, 1)');
  186. $('#loginValid').css('display', 'none');
  187. $('#loginValid_code').css('display', 'block');
  188. })
  189. $('#phone_login_btn').click(function() {
  190. $('#phone_login').css('color', 'rgba(21, 21, 21, 1)');
  191. $('#acc_login').css('color', 'rgba(118, 144, 181, 1)');
  192. $('#loginValid').css('display', 'none');
  193. $('#loginValid_code').css('display', 'block');
  194. })
  195. $("#submitButton_code").click(function() {
  196. var phone = $("#phone").val();
  197. var code = $("#code").val();
  198. $.post("/index/ajax/phone_code_login", {
  199. phone: phone,
  200. code: code
  201. },
  202. function(data) {
  203. if (data.code != 200) {
  204. alert(data.msg);
  205. } else {
  206. // if ($('#remember-me').is(':checked')) {
  207. // localStorage.setItem('user', user);
  208. // localStorage.setItem('password', password);
  209. // localStorage.setItem('bit', 'true');
  210. // } else {
  211. localStorage.removeItem('user');
  212. localStorage.removeItem('password');
  213. localStorage.removeItem('bit');
  214. // }
  215. window.location.href = '/index/apps/apps';
  216. }
  217. }, 'json');
  218. });
  219. if (localStorage.getItem('bit') === 'true') {
  220. $('#remember-me').attr('checked', 'checked');
  221. $('#user').val(localStorage.getItem('user'));
  222. $('#password').val(localStorage.getItem('password'));
  223. }
  224. $("#submitButton").click(function() {
  225. var user = $("#user").val();
  226. var password = $("#password").val();
  227. $.post("/index/ajax/login", {
  228. user: user,
  229. password: password
  230. },
  231. function(data) {
  232. if (data.code != 200) {
  233. alert(data.msg);
  234. } else {
  235. if ($('#remember-me').is(':checked')) {
  236. localStorage.setItem('user', user);
  237. localStorage.setItem('password', password);
  238. localStorage.setItem('bit', 'true');
  239. } else {
  240. localStorage.removeItem('user');
  241. localStorage.removeItem('password');
  242. localStorage.removeItem('bit');
  243. }
  244. window.location.href = '/index/apps/apps';
  245. }
  246. }, 'json');
  247. });
  248. document.onkeydown = function(event) {
  249. var e = event || window.event;
  250. if (e && e.keyCode == 13) {
  251. $("#submitButton").click();
  252. }
  253. };
  254. $("#loginValid").validate({
  255. errorPlacement: function(error, element) {
  256. error.appendTo(element.parent().parent());
  257. },
  258. rules: {
  259. "mobile": {
  260. required: true,
  261. mobile: true
  262. },
  263. "password": {
  264. required: true,
  265. minlength: 5
  266. }
  267. },
  268. messages: {
  269. mobile: {
  270. required: "手机号不能为空",
  271. mobile: "请输入正确的手机号"
  272. },
  273. password: {
  274. required: "密码不能为空",
  275. minlength: "密码长度最少5位"
  276. }
  277. },
  278. highlight: function(element) {
  279. $(element).closest('.form-group').addClass('has-error');
  280. },
  281. unhighlight: function(element) {
  282. $(element).closest('.form-group').removeClass('has-error');
  283. },
  284. errorElement: 'label',
  285. errorPlacement: function(error, element) {
  286. if (element.parent('.input-group').length) {
  287. error.insertAfter(element.parent());
  288. } else {
  289. error.insertAfter(element);
  290. }
  291. }
  292. });
  293. });
  294. </script>
  295. <script type="text/javascript">
  296. function test() {
  297. window.open('/index/qlogin/login');
  298. }
  299. </script>
  300. <script>
  301. $(document).ready(function() {
  302. var r = window.setInterval(function() {
  303. $.ajax({
  304. type: 'POST',
  305. url: '/index/qlogin/check',
  306. dataType: 'text',
  307. success: function(str) {
  308. if (str == "ok") {
  309. window.location.reload();
  310. }
  311. }
  312. });
  313. }, 500);
  314. });
  315. </script>
  316. <?php
  317. $this->footer();
  318. ?>
  319. </body>
  320. </html>
  321. <?php
  322. }
  323. }