per_login.blade.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <div class="modal_login_box">
  2. <!--个人会员登录-->
  3. <div class="login-box-per-body">
  4. <div class="login-form">
  5. <div class="form-l">
  6. <div class="switch-title">
  7. <span class="active" data-type="1">普通账户登录</span>
  8. <span data-type="2">手机动态码登录</span>
  9. </div>
  10. <!--普通用户登录-->
  11. <div class="login-type user-login">
  12. <form id="form_account" action="{{route('login.account')}}" method="post">
  13. <input type="hidden" name="ticket" id="ticket">
  14. <input type="hidden" name="bizState" id="bizState">
  15. <input type="hidden" name="randstr" id="randstr">
  16. {{ csrf_field() }}
  17. <div id="account"></div>
  18. <div id="message_account"></div>
  19. <div class="form-group yhm">
  20. <div class="imgbg"></div>
  21. <input class="input-login" type="text" value="" name="account" placeholder="请输入用户名"/>
  22. </div>
  23. <div id="password"></div>
  24. <div class="form-group mm">
  25. <div class="imgbg"></div>
  26. <input class="input-login" type="password" value="" name="password" placeholder="请输入密码"/>
  27. </div>
  28. <div class="txt-group">
  29. <input type="checkbox" name="autoLogin" value="1" checked />
  30. <span class="check-box yes" onclick="checkAutoLogin()">下次自动登录</span>
  31. <span class="txt-r"><a href="{{route('password.request')}}">忘记密码?</a></span>
  32. </div>
  33. <div class="btn-group login-account" >
  34. 登录
  35. </div>
  36. </form>
  37. </div>
  38. <!--手机登录-->
  39. <div class="login-type mob-login" style="display: none;">
  40. <form id="form_mobile" action="{{route('login.sms')}}" method="post">
  41. <input type="hidden" name="ticket" id="ticket1">
  42. <input type="hidden" name="bizState" id="bizState1">
  43. <input type="hidden" name="randstr" id="randstr1">
  44. {{ csrf_field() }}
  45. <div id="mobile"></div>
  46. <div id="message_mobile"></div>
  47. <div class="form-group yhm">
  48. <div class="imgbg"></div>
  49. <input class="input-login" type="text" value="" name="mobile" placeholder="请输入手机号"/>
  50. </div>
  51. <div id="code"></div>
  52. <div class="form-group mm">
  53. <div class="imgbg"></div>
  54. <input class="input-login code" type="text" value="" name="code" placeholder="请输入手机验证码"/>
  55. <input type="button" class="btn-getcode" value="获取验证码"/>
  56. </div>
  57. <div class="txt-group">
  58. <input type="checkbox" name="autoLogin" value="1" checked />
  59. <span class="check-box yes" onclick="checkAutoLogin(this)">下次自动登录</span>
  60. <span class="txt-r"><a href="{{route('password.request')}}">忘记密码?</a></span>
  61. </div>
  62. <div class="btn-group login-mobile" >
  63. 登录
  64. </div>
  65. </form>
  66. </div>
  67. <div class="reg-link-box">
  68. 还没有账号?<a class="reg-txt" href="{{route('register.index')}}">立刻注册</a>
  69. </div>
  70. </div>
  71. <div class="form-r">
  72. <div id="thirdlogin-wechat-web" class="qr-code">
  73. </div>
  74. <div class="appsparent">
  75. <p class="txt">使用合作账号直接登录</p>
  76. <a class="app-icon qq" href=""></a>
  77. </div>
  78. <div class="other-user">
  79. <a href="{{route('login')}}">其他用户登录>></a>
  80. </div>
  81. </div>
  82. <div class="clear"></div>
  83. </div>
  84. </div>
  85. </div>
  86. <script type="text/javascript" src="{{ theme_asset('gt/gt.js') }}"></script>
  87. <script type="text/javascript" src="{{ theme_asset('gt/gt.handle.js') }}"></script>
  88. <script type="text/javascript" src="https://captcha.253.com/TCaptcha.js"></script>
  89. @include('module.widgets.thirdlogin', ['redirect_url'=>$redirect_url])
  90. <script>
  91. $(function () {
  92. // var is_need_geetest=0;//全局,是否使用极验.
  93. // var login_type=1;//登录模式,1用户账号登录,2用户手机登录,3企业登录.
  94. // var gt_call_back=function(captchaObj) {
  95. // captchaObj.onReady(function () {
  96. // //极验加载完成
  97. // });
  98. // captchaObj.onSuccess(function () {
  99. // ajax_login(login_type,captchaObj);
  100. //
  101. // });
  102. // captchaObj.onError(function () {
  103. // show_error(login_type,"请先进行验证");
  104. // });
  105. // captchaObj.onClose(function () {
  106. // show_error(login_type,"请先进行验证");
  107. // });
  108. // $('.login-account').on('click', function () {
  109. // login_type=1;
  110. // clean_message();
  111. // if (is_need_geetest==1){
  112. // captchaObj.bindForm("#form_account");
  113. // captchaObj.verify();
  114. // }
  115. // else{
  116. // ajax_login(login_type,captchaObj);
  117. // }
  118. //
  119. // });
  120. //
  121. // $('.login-mobile').on('click', function () {
  122. // login_type=2;
  123. // clean_message();
  124. // if (is_need_geetest==1){
  125. // captchaObj.bindForm("#form_mobile");
  126. // captchaObj.verify();
  127. // }
  128. // else{
  129. // ajax_login(login_type,captchaObj);
  130. // }
  131. // });
  132. //
  133. // $('.login-company').on('click', function () {
  134. // login_type=3;
  135. // clean_message();
  136. // if (is_need_geetest==1){
  137. // captchaObj.bindForm("#form_company");
  138. // captchaObj.verify();
  139. // }
  140. // else{
  141. // ajax_login(login_type,captchaObj);
  142. // }
  143. // });
  144. // };
  145. //
  146. // gt_init(gt_call_back);//初始化极验
  147. var captcha_callback = function(res){
  148. if(res.hasOwnProperty('errorMessage')){
  149. alert(res.errorMessage)
  150. }
  151. if(res.ret == 0){
  152. console.log('行为验证通过');
  153. $("#ticket").val(res.ticket);
  154. $("#bizState").val(res.bizState);
  155. $("#randstr").val(res.randstr);
  156. ajax_login(1);
  157. }else{
  158. console.log('用户主动关闭验证码')
  159. }
  160. console.log('callback:', res);
  161. }
  162. var mobile_captcha_flag = false;
  163. var mobile_captcha_callback = function(res){
  164. if(res.hasOwnProperty('errorMessage')){
  165. alert(res.errorMessage)
  166. }
  167. if(res.ret == 0){
  168. mobile_captcha_flag = true;
  169. console.log('行为验证通过');
  170. $("#ticket1").val(res.ticket);
  171. $("#bizState1").val(res.bizState);
  172. $("#randstr1").val(res.randstr);
  173. submit_data={
  174. "mobile":$("input[name='mobile']").val(),
  175. "type":"login"
  176. };
  177. $.ajax({
  178. method: 'post',
  179. url: '{{route('sms.send')}}',
  180. data: submit_data,
  181. beforeSend:function () {
  182. // console.log('请求开始');
  183. $(".errinfo").text("");
  184. $(".errinfo").removeClass("errinfo");
  185. },
  186. complete:function() {
  187. console.log('请求结束');
  188. },
  189. success: function (data) {
  190. // console.log(data);
  191. $("#message_mobile").addClass("successinfo");
  192. $("#message_mobile").text("发送成功,请注意查收");
  193. settime();
  194. },
  195. error: function (errorData) {
  196. // console.log(errorData);
  197. if (errorData.status==422) {//验证错误
  198. $.each(errorData.responseJSON.errors,function (key,val) {
  199. $("#"+key).addClass("errinfo");
  200. $("#"+key).text(val[0]);
  201. });
  202. }
  203. else if(errorData.status==400) {//业务错误
  204. $("#message_mobile").addClass("errinfo");
  205. $("#message_mobile").text(errorData.responseJSON.message);
  206. }
  207. }
  208. });
  209. }else{
  210. console.log('用户主动关闭验证码')
  211. }
  212. console.log('callback:', res);
  213. }
  214. var captcha = new TencentCaptcha('196587903', captcha_callback, {});
  215. $('.login-account').on('click', function () {
  216. captcha.show();
  217. });
  218. var mobile_captcha = new TencentCaptcha('196587903', mobile_captcha_callback, {});
  219. $('.btn-getcode').on('click', function () {
  220. mobile_captcha.show();
  221. });
  222. $('.login-mobile').on('click', function () {
  223. login_type=2;
  224. if (mobile_captcha_flag){
  225. ajax_login(2);
  226. }
  227. else{
  228. alert('验证码组件异常')
  229. }
  230. });
  231. $(document).on("click",".switch-title span",function () {
  232. var index = $(this).index();
  233. $(this).addClass("active").siblings("span").removeClass("active");
  234. $(".login-type").eq(index).show().siblings(".login-type").hide();
  235. });
  236. $(".rightab").click(function () {
  237. $(".login-box-per-body").toggle();
  238. $(".login-box-com-body").toggle();
  239. });
  240. $('.btn-getcode').on('click', function () {
  241. submit_data={
  242. "mobile":$("input[name='mobile']").val(),
  243. "type":"login"
  244. };
  245. $.ajax({
  246. method: 'get',
  247. url: '{{url('api/common/sms/send')}}',
  248. data: submit_data,
  249. beforeSend:function () {
  250. // console.log('请求开始');
  251. $(".errinfo").text("");
  252. $(".errinfo").removeClass("errinfo");
  253. },
  254. complete:function() {
  255. console.log('请求结束');
  256. },
  257. success: function (data) {
  258. // console.log(data);
  259. $("#message_mobile").addClass("successinfo");
  260. $("#message_mobile").text("发送成功,请注意查收");
  261. settime();
  262. },
  263. error: function (errorData) {
  264. // console.log(errorData);
  265. if (errorData.status==422) {//验证错误
  266. $.each(errorData.responseJSON.errors,function (key,val) {
  267. $("#"+key).addClass("errinfo");
  268. $("#"+key).text(val[0]);
  269. });
  270. }
  271. else if(errorData.status==400) {//业务错误
  272. $("#message_mobile").addClass("errinfo");
  273. $("#message_mobile").text(errorData.responseJSON.message);
  274. }
  275. }
  276. });
  277. });
  278. function ajax_login(type) {
  279. if (type==1) {
  280. $.ajax({
  281. method: 'post',
  282. url: $("#form_account").attr('action'),
  283. data: $("#form_account").serialize(),
  284. beforeSend:function () {
  285. //console.log('请求开始');
  286. clean_message();
  287. },
  288. complete:function() {
  289. //console.log('请求结束');
  290. },
  291. success: function (data) {
  292. //console.log(data);
  293. //location.href=data.data.redirect_url;
  294. window.location.reload();
  295. },
  296. error: function (errorData) {
  297. if (is_need_geetest==1){
  298. captchaObj.reset();
  299. }
  300. if (errorData.status==422) {//验证错误
  301. $.each(errorData.responseJSON.errors,function (key,val) {
  302. $("#"+key).addClass("errinfo");
  303. $("#"+key).text(val[0]);
  304. });
  305. }
  306. else if(errorData.status==400) {//业务错误
  307. $("#message_account").addClass("errinfo");
  308. $("#message_account").text(errorData.responseJSON.message);
  309. }
  310. }
  311. });
  312. }
  313. else if (type==2) {
  314. $.ajax({
  315. method: 'post',
  316. url: $("#form_mobile").attr('action'),
  317. data: $("#form_mobile").serialize(),
  318. beforeSend:function () {
  319. //console.log('请求开始');
  320. clean_message();
  321. },
  322. complete:function() {
  323. //console.log('请求结束');
  324. },
  325. success: function (data) {
  326. //console.log(data);
  327. //location.href=data.data.redirect_url;
  328. window.location.reload();
  329. },
  330. error: function (errorData) {
  331. //console.log(errorData);
  332. if (is_need_geetest==1){
  333. captchaObj.reset();
  334. }
  335. if (errorData.status==422) {//验证错误
  336. $.each(errorData.responseJSON.errors,function (key,val) {
  337. $("#"+key).addClass("errinfo");
  338. $("#"+key).text(val[0]);
  339. });
  340. }
  341. else if(errorData.status==400) {//业务错误
  342. $("#message_mobile").addClass("errinfo");
  343. $("#message_mobile").text(errorData.responseJSON.message);
  344. is_need_geetest=errorData.responseJSON.errors.is_need_geetest;
  345. }
  346. }
  347. });
  348. }
  349. else if (type==3){
  350. $.ajax({
  351. method: 'post',
  352. url: $("#form_company").attr('action'),
  353. data: $("#form_company").serialize(),
  354. beforeSend:function () {
  355. //console.log('请求开始');
  356. clean_message();
  357. },
  358. complete:function() {
  359. //console.log('请求结束');
  360. },
  361. success: function (data) {
  362. //console.log(data);
  363. //location.href=data.data.redirect_url;
  364. window.location.reload();
  365. },
  366. error: function (errorData) {
  367. //console.log(errorData);
  368. if (is_need_geetest==1){
  369. captchaObj.reset();
  370. }
  371. if (errorData.status==422) {//验证错误
  372. $.each(errorData.responseJSON.errors,function (key,val) {
  373. $("#"+key).addClass("errinfo");
  374. $("#"+key).text(val[0]);
  375. });
  376. }
  377. else if(errorData.status==400) {//业务错误
  378. $("#message_company").addClass("errinfo");
  379. $("#message_company").text(errorData.responseJSON.message);
  380. is_need_geetest=errorData.responseJSON.errors.is_need_geetest;
  381. }
  382. }
  383. });
  384. }
  385. };
  386. function show_error(type,message) {
  387. if (type==1) {
  388. $("#message_account").addClass("errinfo");
  389. $("#message_account").text(message);
  390. }
  391. else if (type==2) {
  392. $("#message_mobile").addClass("errinfo");
  393. $("#message_mobile").text(message);
  394. }
  395. else if (type==3){
  396. $("#message_company").addClass("errinfo");
  397. $("#message_company").text(message);
  398. }
  399. };
  400. function clean_message() {
  401. $(".errinfo").text("");
  402. $(".errinfo").removeClass("errinfo");
  403. $(".successinfo").text("");
  404. $(".successinfo").removeClass("successinfo");
  405. }
  406. });
  407. function checkAutoLogin() {
  408. var isCheck = $(".check-box").hasClass("yes");
  409. if (isCheck) {
  410. $(".check-box").removeClass("yes");
  411. $(".check-box").closest(".txt-group").find("input[name=autoLogin]").prop("checked", false);
  412. } else {
  413. $(".check-box").addClass("yes");
  414. $(".check-box").closest(".txt-group").find("input[name=autoLogin]").prop("checked", true);
  415. }
  416. }
  417. // 倒计时
  418. var countdown = 60;
  419. function settime() {
  420. if (countdown == 0) {
  421. $('.btn-getcode').prop("disabled", false);
  422. $('.btn-getcode').removeClass('btn-disabled');
  423. $('.btn-getcode').val('获取验证码');
  424. countdown = 60;
  425. return;
  426. } else {
  427. $('.btn-getcode').prop("disabled", true);
  428. $('.btn-getcode').addClass('btn-disabled');
  429. $('.btn-getcode').val('重新发送' + countdown + '秒');
  430. countdown--;
  431. }
  432. setTimeout(function() {
  433. settime()
  434. },1000)
  435. }
  436. </script>