説明なし

register.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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:'money_phone',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('background','#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('background','linear-gradient(90deg,rgba(255,141,36,1) 0%,rgba(255,208,36,1) 100%)');
  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. $("#maskMoney").css({'visibility': 'visible'});
  117. scrollTop02 = scrollTop;
  118. $('body').css({'position':'fixed',"top":-scrollTop});
  119. }else{
  120. showMsg(res.err)
  121. }
  122. }
  123. });
  124. }
  125. //点击下载app
  126. function goAppEvent () {
  127. countLandingPage({click_source:'download',source:source})
  128. var downLoad = [{
  129. source:'40019',
  130. url:'https://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/BNDXJDqutoutiao06_v1.0.0_2018-11-13_100_jiagu_sign.apk'
  131. },{
  132. source:'40027',
  133. url:'https://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/xiaohuazhu_smss02.apk'
  134. },{
  135. source:'40043',
  136. url:'https://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/qtt_02.apk'
  137. },{
  138. source:'40073',
  139. url:'https://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/ss_uc_02.apk'
  140. },{
  141. source:'40003',
  142. url:'https://kx-loans.oss-cn-beijing.aliyuncs.com/xiaohuazhu/smss_02_40003.apk'
  143. }]
  144. if(source == '40003'){
  145. if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){//小花猪ios下载链接
  146. 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';
  147. return;
  148. }
  149. }
  150. downLoad.forEach(function (item, index) {
  151. if(source == item.source){
  152. window.location.href = item.url;
  153. return;
  154. }
  155. })
  156. }
  157. //埋点
  158. function countLandingPage (data) {
  159. $.ajax({
  160. type:'post',
  161. url:'/user/log/countLandingPage',
  162. dataType:'json',
  163. data:data,
  164. success:function (res) {
  165. console.log(res)
  166. }
  167. })
  168. }
  169. //提示信息
  170. function showMsg(msg) {
  171. var msg = msg;
  172. var msgBox = $('.alert-info');
  173. msgBox.children('p').text(msg);
  174. msgBox.show();
  175. setTimeout(function() {
  176. msgBox.hide();
  177. }, 2000);
  178. }
  179. //获取地址栏参数
  180. function parseQueryString(url) {
  181. var urlObj = {};
  182. var reg = /([^?=&]+)=([^?=&]+)/g;
  183. url.replace(reg, ($0, $1, $2) => {
  184. urlObj[$1] = decodeURIComponent($2);
  185. })
  186. return urlObj;
  187. }