login_mobile.blade.php 20 KB

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