暂无描述

index.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. var countDown = '',count_down = '';
  2. var source = '';
  3. var scrollTop = '';
  4. var scrollTop02 = '';
  5. var qs = parseQueryString(window.location.href);
  6. $().ready(function () {
  7. // document.body.addEventListener('focusout', function () {
  8. // window.scrollTo(0,0);
  9. // scrollToEnd();
  10. // });
  11. if(qs.source) {source = qs.source}
  12. var downLoad = [{
  13. source:'30042',
  14. title:'好借',
  15. img:'./img/doudou.png',
  16. bgImg:'./img/past-trial-bg.png',
  17. color:'#fda31b'
  18. },{
  19. source:'30041',
  20. title:'小雨点网贷',
  21. img:'./img/xiaoyudian.png',
  22. bgImg:'./img/past-trial-bg02.png',
  23. color:'#C32018'
  24. },{
  25. source:'30070',
  26. title:'小树时代',
  27. img:'./img/xiaoshu.png',
  28. bgImg:'./img/past-trial-bg03.png',
  29. color:'#ED6C29'
  30. }]
  31. downLoad.forEach(function (item, index) {
  32. if(source == item.source){
  33. $(".appTitle span").html(item.title)
  34. $(".appTitle img").attr('src',item.img)
  35. $(".bgImg").attr('src',item.bgImg)
  36. $('body').css('background',item.color)
  37. return;
  38. }
  39. })
  40. $(window).scroll(function(){
  41. scrollTop = $(this).scrollTop(); //scrollTop() 方法返回或设置匹配元素的滚动条的垂直位置
  42. })
  43. })
  44. //点击获取验证码
  45. function getYzmEvent () {
  46. var myreg = /^[0-9]{11}$/;
  47. if (!myreg.test($("#phone").val())) {
  48. //手机号码未填写及填写不正确
  49. showMsg('请正确填写手机号')
  50. return;
  51. }
  52. //-----------
  53. countDown = 60;
  54. count_down = countDown;
  55. var that = this;
  56. $("#getYzm").attr("disabled","true").css({'color':"#ccc"});
  57. $("#getYzm").html(count_down);
  58. count_down = count_down-1;
  59. var time = setInterval(function () {
  60. $("#getYzm").html(count_down);
  61. count_down--;
  62. if(count_down < 0){
  63. $("#getYzm").removeAttr("disabled")
  64. .html('发送验证码')
  65. .css({'color':'#F63439'});
  66. clearInterval(time);
  67. count_down = countDown;
  68. }
  69. },1000)
  70. //-----------
  71. // $("#mask").css({'visibility': 'visible'});
  72. // $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val() + "&time=" + new Date().getTime())
  73. // scrollTop02 = scrollTop;
  74. // $('body').css({'position':'fixed',"top":-scrollTop});
  75. }
  76. //关闭弹层
  77. function closePanel(){
  78. $('#mask').css({'visibility': 'hidden'});
  79. //$('#maskMoney').css({'visibility': 'hidden'});
  80. $("#imgYzm").val('');
  81. $("body").css({"position":"initial"});
  82. $(window).scrollTop(scrollTop02);
  83. }
  84. /* 点击更换图片验证码*/
  85. function getChangeCodeImg(){
  86. $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val() + "&time=" + new Date().getTime());
  87. }
  88. // 输入图片验证码后点击确定请求短信验证码
  89. function goResPanel(){
  90. if($("#imgYzm").val() == ''){
  91. showMsg('请输入图片验证码')
  92. return;
  93. }
  94. registerSecond();
  95. }
  96. //发送短信验证码
  97. function registerSecond () {
  98. $.ajax({
  99. type:"post",
  100. url:"/user/user/registerSecond",
  101. dataType:'json',
  102. data:{
  103. phone:$("#phone").val(),
  104. smstype:1,
  105. qrcode:2,
  106. image_code:$("#imgYzm").val(),
  107. source:source
  108. },
  109. success:function (res){
  110. console.log(res)
  111. if(res && res.errno == 0){
  112. closePanel();
  113. countDown = res.rst.wait_time;
  114. count_down = countDown;
  115. var that = this;
  116. $("#getYzm").attr("disabled","true").css({'color':"#ccc"});
  117. $("#getYzm").html(count_down);
  118. count_down = count_down-1;
  119. var time = setInterval(function () {
  120. $("#getYzm").html(count_down);
  121. count_down--;
  122. if(count_down < 0){
  123. $("#getYzm").removeAttr("disabled")
  124. .html('发送验证码')
  125. .css({'color':'#F63439'});
  126. clearInterval(time);
  127. count_down = countDown;
  128. }
  129. },1000)
  130. }else{
  131. showMsg(res.err)
  132. }
  133. }
  134. });
  135. }
  136. //登录
  137. function loginEvent () {
  138. var myreg = /^[0-9]{11}$/;
  139. if (!myreg.test($("#phone").val()) && $("#phone").val() == '15313295256') {
  140. //手机号码未填写及填写不正确
  141. showMsg('请正确填写手机号')
  142. return;
  143. }
  144. if($("#phoneYzm").val() !== "123456"){
  145. showMsg('请正确输入短信验证码')
  146. return;
  147. }
  148. if(source == '30070'){
  149. window.location.href='./borrow-money.html'
  150. }
  151. if(source == '30042'){
  152. window.location.href='./borrow-money02.html'
  153. }
  154. if(source == '30041'){
  155. window.location.href='./borrow-money03.html'
  156. }
  157. // loginCodeEvent();
  158. }
  159. //短信验证码登录
  160. function loginCodeEvent () {
  161. $.ajax({
  162. type:"post",
  163. url:"/user/user/loginCode",
  164. dataType:'json',
  165. data:{
  166. phone:$("#phone").val(),
  167. code:$("#phoneYzm").val(),
  168. source:source
  169. },
  170. success:function(res) {
  171. console.log(res)
  172. if(res && res.errno == 0){
  173. showMsg('注册成功')
  174. window.location.href='./loan.html'
  175. }else{
  176. showMsg(res.err)
  177. }
  178. }
  179. });
  180. }
  181. //提示信息
  182. function showMsg(msg) {
  183. var msg = msg;
  184. var msgBox = $('.alert-info');
  185. msgBox.children('p').text(msg);
  186. msgBox.show();
  187. setTimeout(function() {
  188. msgBox.hide();
  189. }, 2000);
  190. }
  191. //获取地址栏参数
  192. function parseQueryString(url) {
  193. var urlObj = {};
  194. var reg = /([^?=&]+)=([^?=&]+)/g;
  195. url.replace(reg, function($0, $1, $2) {
  196. urlObj[$1] = decodeURIComponent($2);
  197. })
  198. return urlObj;
  199. }