Nav apraksta

registerOne.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. if(qs.source) {source = qs.source}
  8. countLandingPage({click_source:'openLink',source:source})
  9. $(window).scroll(function(){
  10. scrollTop = $(this).scrollTop(); //scrollTop() 方法返回或设置匹配元素的滚动条的垂直位置
  11. })
  12. })
  13. //点击获取验证码
  14. function getYzmEvent () {
  15. var myreg = /^[0-9]{11}$/;
  16. if (!myreg.test($("#phone").val())) {
  17. //手机号码未填写及填写不正确
  18. showMsg('请正确填写手机号')
  19. return;
  20. }
  21. countLandingPage({click_source:'achieve',source:source})
  22. $("#mask").css({'visibility': 'visible'});
  23. $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val() + "&time=" + new Date().getTime())
  24. scrollTop02 = scrollTop;
  25. $('body').css({'position':'fixed',"top":-scrollTop});
  26. }
  27. //关闭弹层
  28. function closePanel(){
  29. $('#mask').css({'visibility': 'hidden'});
  30. //$('#maskMoney').css({'visibility': 'hidden'});
  31. $("#imgYzm").val('');
  32. $("body").css({"position":"initial"});
  33. $(window).scrollTop(scrollTop02);
  34. }
  35. /* 点击更换图片验证码*/
  36. function getChangeCodeImg(){
  37. $('#picCode .modal-inner img').attr("src", "/user/VerifyImage/getImageCode?phone=" + $("#phone").val() + "&time=" + new Date().getTime());
  38. }
  39. // 输入图片验证码后点击确定请求短信验证码
  40. function goResPanel(){
  41. if($("#imgYzm").val() == ''){
  42. showMsg('请输入图片验证码')
  43. return;
  44. }
  45. registerSecond();
  46. }
  47. //发送短信验证码
  48. function registerSecond () {
  49. $.ajax({
  50. type:"post",
  51. url:"/user/user/registerSecond",
  52. dataType:'json',
  53. data:{
  54. phone:$("#phone").val(),
  55. smstype:1,
  56. qrcode:2,
  57. image_code:$("#imgYzm").val(),
  58. source:source
  59. },
  60. success:function (res){
  61. console.log(res)
  62. if(res && res.errno == 0){
  63. closePanel();
  64. countDown = res.rst.wait_time;
  65. count_down = countDown;
  66. var that = this;
  67. $("#getYzm").attr("disabled","true").css({'color':"#ccc"});
  68. $("#getYzm").html(count_down);
  69. count_down = count_down-1;
  70. var time = setInterval(function () {
  71. $("#getYzm").html(count_down);
  72. count_down--;
  73. if(count_down < 0){
  74. $("#getYzm").removeAttr("disabled")
  75. .html('发送验证码')
  76. .css({'color':'#F63439'});
  77. clearInterval(time);
  78. count_down = countDown;
  79. }
  80. },1000)
  81. }else{
  82. showMsg(res.err)
  83. }
  84. }
  85. });
  86. }
  87. //登录
  88. function loginEvent () {
  89. var myreg = /^[0-9]{11}$/;
  90. if (!myreg.test($("#phone").val())) {
  91. //手机号码未填写及填写不正确
  92. showMsg('请正确填写手机号')
  93. return;
  94. }
  95. if($("#phoneYzm").val() == ""){
  96. showMsg('请输入短信验证码')
  97. return;
  98. }
  99. loginCodeEvent();
  100. }
  101. //短信验证码登录
  102. function loginCodeEvent () {
  103. countLandingPage({click_source:'click',source:source})
  104. $.ajax({
  105. type:"post",
  106. url:"/user/user/loginCode",
  107. dataType:'json',
  108. data:{
  109. phone:$("#phone").val(),
  110. code:$("#phoneYzm").val(),
  111. source:source
  112. },
  113. success:function(res) {
  114. console.log(res)
  115. if(res && res.errno == 0){
  116. goAppEvent();//下载
  117. // $("#maskMoney").css({'visibility': 'visible'});
  118. // scrollTop02 = scrollTop;
  119. // $('body').css({'position':'fixed',"top":-scrollTop});
  120. }else{
  121. showMsg(res.err)
  122. }
  123. }
  124. });
  125. }
  126. //点击下载app
  127. function goAppEvent () {
  128. countLandingPage({click_source:'download-1Page',source:source})
  129. showMsg('注册成功')
  130. var downLoad = [{
  131. source:'40085',
  132. url:'http://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/tg_40085.apk'
  133. }]
  134. if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){//小花猪ios下载链接
  135. window.location.href = 'https://itunes.apple.com/cn/app/%E5%B0%8F%E8%8A%B1%E7%8C%AA-%E5%88%86%E6%9C%9F%E6%97%A0%E5%BF%A7-%E9%80%89%E6%8B%A9%E5%A4%9A%E6%A0%B7/id1440274732?mt=8';
  136. return;
  137. }
  138. downLoad.forEach(function (item, index) {
  139. if(source == item.source){
  140. setTimeout(function () {
  141. window.location.href = item.url;
  142. },1000)
  143. return;
  144. }
  145. })
  146. }
  147. //埋点
  148. function countLandingPage (data) {
  149. $.ajax({
  150. type:'post',
  151. url:'/user/log/countLandingPage',
  152. dataType:'json',
  153. data:data,
  154. success:function (res) {
  155. console.log(res)
  156. }
  157. })
  158. }
  159. //提示信息
  160. function showMsg(msg) {
  161. var msg = msg;
  162. var msgBox = $('.alert-info');
  163. msgBox.children('p').text(msg);
  164. msgBox.show();
  165. setTimeout(function() {
  166. msgBox.hide();
  167. }, 2000);
  168. }
  169. //获取地址栏参数
  170. function parseQueryString(url) {
  171. var urlObj = {};
  172. var reg = /([^?=&]+)=([^?=&]+)/g;
  173. url.replace(reg, ($0, $1, $2) => {
  174. urlObj[$1] = decodeURIComponent($2);
  175. })
  176. return urlObj;
  177. }